diff --git a/config.php b/config.php index b064edb4b..594769afe 100644 --- a/config.php +++ b/config.php @@ -57,7 +57,7 @@ define('G5_LGXPAY_DIR', 'lgxpay'); define('G5_SNS_DIR', 'sns'); define('G5_SYNDI_DIR', 'syndi'); -define('G5_PHPMAILER_DIR', 'PHPMailer_v2.0.4'); +define('G5_PHPMAILER_DIR', 'PHPMailer'); define('G5_SESSION_DIR', 'session'); define('G5_THEME_DIR', 'theme'); @@ -159,7 +159,8 @@ define('G5_MOBILE_AGENT', 'phone|samsung|lgtel|mobile|[^A]skt|nokia|blackberry // SMTP // lib/mailer.lib.php 에서 사용 -define('G5_SMTP', '127.0.0.1'); +define('G5_SMTP', '127.0.0.1'); +define('G5_SMTP_PORT', '25'); /******************** diff --git a/lib/mailer.lib.php b/lib/mailer.lib.php index 42593a3c3..8d0ff707a 100644 --- a/lib/mailer.lib.php +++ b/lib/mailer.lib.php @@ -1,7 +1,7 @@ IsSMTP(); // telling the class to use SMTP $mail->Host = G5_SMTP; // SMTP server + if(defined('G5_SMTP_PORT') && G5_SMTP_PORT) + $mail->Port = G5_SMTP_PORT; } + $mail->CharSet = 'UTF-8'; $mail->From = $fmail; $mail->FromName = $fname; $mail->Subject = $subject; $mail->AltBody = ""; // optional, comment out and test - $mail->MsgHTML($content); - $mail->AddAddress($to); + $mail->msgHTML($content); + $mail->addAddress($to); if ($cc) - $mail->AddCC($cc); + $mail->addCC($cc); if ($bcc) - $mail->AddBCC($bcc); + $mail->addBCC($bcc); //print_r2($file); exit; if ($file != "") { foreach ($file as $f) { - $mail->AddAttachment($f['path'], $f['name']); + $mail->addAttachment($f['path'], $f['name']); } } - return $mail->Send(); + return $mail->send(); } // 파일을 첨부함 @@ -46,364 +49,7 @@ function attach_file($filename, $tmp_name) // 서버에 업로드 되는 파일은 확장자를 주지 않는다. (보안 취약점) $dest_file = G5_DATA_PATH.'/tmp/'.str_replace('/', '_', $tmp_name); move_uploaded_file($tmp_name, $dest_file); - /* - $fp = fopen($tmp_name, "r"); - $tmpfile = array( - "name" => $filename, - "tmp_name" => $tmp_name, - "data" => fread($fp, filesize($tmp_name))); - fclose($fp); - */ $tmpfile = array("name" => $filename, "path" => $dest_file); return $tmpfile; } - -/* -// 메일 보내기 (파일 여러개 첨부 가능) -// type : text=0, html=1, text+html=2 -function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="") -{ - global $config; - global $g5; - - // 메일발송 사용을 하지 않는다면 - if (!$config['cf_email_use']) return; - - $boundary = uniqid(time()); - - $header = "Message-ID: <".generate_mail_id(preg_replace("/@.+$/i","",$to)).">\r\n". - "From:=?utf-8?B?".base64_encode($fname)."?=<$fmail>\r\n"; - if ($cc) $header .= "Cc: $cc\n"; - if ($bcc) $header .= "Bcc: $bcc\n"; - $header .= "MIME-Version: 1.0\n"; - $header .= "X-Mailer: SIR Mailer 0.94 : {$_SERVER['SERVER_ADDR']} : {$_SERVER['REMOTE_ADDR']} : ".G5_URL." : {$_SERVER['SCRIPT_NAME']} : {$_SERVER['HTTP_REFERER']} \n"; - $header .= "Date: ".date ("D, j M Y H:i:s T",time())."\r\n". - "To: $to\r\n". - "Subject: =?utf-8?B?".base64_encode($subject)."?=\r\n"; - - if ($file == "") { - $header .= "Content-Type: MULTIPART/ALTERNATIVE;\n". - " BOUNDARY=\"$boundary\"\n\n"; - } else { - $header .= "Content-Type: MULTIPART/MIXED;\n". - " BOUNDARY=\"$boundary\"\n\n"; - } - - if ($type == 2) - $content = nl2br($content); - - $strip_content = stripslashes(trim($content)); - $encode_content = chunk_split(base64_encode($strip_content)); - - $body = ""; - $body .= "\n--$boundary\n"; - $body .= "Content-Type: TEXT/PLAIN; charset=utf-8\n"; - $body .= "Content-Transfer-Encoding: BASE64\n\n"; - $body .= $encode_content; - $body .= "\n--$boundary\n"; - - if ($type) { - $body .= "Content-Type: TEXT/HTML; charset=utf-8\n"; - $body .= "Content-Transfer-Encoding: BASE64\n\n"; - $body .= $encode_content; - $body .= "\n--$boundary\n"; - } - - if ($file != "") { - foreach ($file as $f) { - $body .= "n--$boundary\n"; - $body .= "Content-Type: APPLICATION/OCTET-STREAM; name=$fname\n"; - $body .= "Content-Transfer-Encoding: BASE64\n"; - $body .= "Content-Disposition: inline; filename=$fname\n"; - - $body .= "\n"; - $body .= chunk_split(base64_encode($f['data'])); - $body .= "\n"; - } - $body .= "--$boundary--\n"; - } - - $mails['to'] = $to; - $mails['from'] = $fmail; - $mails['text'] = $header.$body; - - if (defined(G5_SMTP)) { - ini_set('SMTP', G5_SMTP); - @mail($to, $subject, $body, $header, "-f $fmail"); - } else { - new maildaemon($mails); - } -} - -// 파일 첨부시 -$fp = fopen(__FILE__, "r"); -$file[] = array( - "name"=>basename(__FILE__), - "data"=>fread($fp, filesize(__FILE__))); -fclose($fp); - -// 메일 유효성 검사 -// core PHP Programming 책 참고 -// hanmail.net , hotmail.com , kebi.com 등이 정상적이지 않음으로 사용 불가 -function verify_email($address, &$error) -{ - global $g5; - - $WAIT_SECOND = 3; // ?초 기다림 - - list($user, $domain) = explode("@", $address); - - // 도메인에 메일 교환기가 존재하는지 검사 - if (checkdnsrr($domain, "MX")) { - // 메일 교환기 레코드들을 얻는다 - if (!getmxrr($domain, $mxhost, $mxweight)) { - $error = '메일 교환기를 회수할 수 없음'; - return false; - } - } else { - // 메일 교환기가 없으면, 도메인 자체가 편지를 받는 것으로 간주 - $mxhost[] = $domain; - $mxweight[] = 1; - } - - // 메일 교환기 호스트의 배열을 만든다. - for ($i=0; $i $stoptime) - break; - } - - // 이 호스트는 응답이 없음. 다음 호스트로 넘어간다 - if (!$gotresponse) continue; - - socket_set_blocking($fp, true); - - // SMTP 서버와의 대화를 시작 - fputs($fp, "HELO {$_SERVER['SERVER_NAME']}\r\n"); - echo "HELO {$_SERVER['SERVER_NAME']}\r\n"; - fgets($fp, 1024); - - // From을 설정 - fputs($fp, "MAIL FROM: \r\n"); - echo "MAIL FROM: \r\n"; - fgets($fp, 1024); - - // 주소를 시도 - fputs($fp, "RCPT TO: <$address>\r\n"); - echo "RCPT TO: <$address>\r\n"; - $line = fgets($fp, 1024); - - // 연결을 닫음 - fputs($fp, "QUIT\r\n"); - fclose($fp); - - if (substr($line, 0, 3) != '250') { - // SMTP 서버가 이 주소를 인식하지 못하므로 잘못된 주소임 - $error = $line; - return false; - } else - // 주소를 인식했음 - return true; - - } - - $error = '메일 교환기에 도달하지 못하였습니다.'; - return false; -} - - -# jsboard 의 메일보내기 class를 추가합니다. 130808 -# http://kldp.net/projects/jsboard/ - -# mail 보내기 함수 2001.11.30 김정균 -# $Id: include/sendmail.php,v 1.4 2009/11/19 05:29:51 oops Exp $ - -# 서버상의 smtp daemon 에 의존하지 않고 직접 발송하는 smtp class -# -# 특정 배열로 class 에 전달을 하여 메일을 발송한다. 배열은 아래을 참조한다. -# -# debug -> debug 를 할지 안할지를 결정한다. -# ofhtml -> 웹상에서 사용할지 쉘상에서 사용할지를 결정한다. -# from -> 메일을 발송하는 사람의 메일주소 -# to -> 메일을 받을 사람의 메일 주소 -# text -> 헤더 내용을 포함한 메일 본문 -# -class maildaemon { - var $failed = 0; - - function __construct($v) { - $this->debug = $v['debug']; - $this->ofhtml = $v['ofhtml']; - if($_SERVER['SERVER_NAME']) $this->helo = $_SERVER['SERVER_NAME']; - if(!$this->helo || preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/i",$this->helo)) - $this->helo = "JSBoardMessage"; - - $this->from = $v['from']; - $this->to = $v['to']; - $this->body = $v['text']."\r\n."; - - //die($v['text']); - $this->newline = $this->ofhtml ? "
\n" : "\n"; - - $this->mx = $this->getMX($this->to); - - if($this->debug) { - echo "DEBUG: ".$this->mx." start".$this->newline; - echo "################################################################".$this->newline; - } - $this->sockets("open"); - $this->send("HELO ".$this->helo); - $this->send("MAIL FROM: <".$this->from.">"); - $this->send("RCPT TO: <".$this->to.">"); - $this->send("data"); - $this->send($this->body); - $this->send("quit"); - $this->sockets("close"); - } - - function getMX($email) { - $dev = explode("@",$email); - $account = $dev[0]; - $host = $dev[1]; - - if(checkdnsrr($host,"MX") && getmxrr($host,$mx,$weight)) { - $idx = 0; - for($i=0;$i $weight[$i]) { - $dest = $weight[$i]; - $idx = $i; - } - } - } else return $host; - return $mx[$idx]; - } - - # 디버그 함수 - # $t -> 1 (debug of socket open,close) - # 0 (regular smtp message) - # $p -> 1 (print detail debug) - # - # return 1 -> success - # return 0 -> failed - # - function debug($str,$t=0,$p=0) { - if($t) { - if(!$str) $this->failed = 1; - if($this->sock) $returnmsg = trim(fgets($this->sock,1024)); - } else { - if(!preg_match("/^(220|221|250|251|354)$/",substr(trim($str),0,3))) - $this->failed = 1; - } - - # DEBUG mode -> 모든 메세지 출력 - if($p) { - if($t) { - $str = "Conncet ".$this->mx; - $str .= $this->failed ? " Failed" : " Success"; - $str .= $this->newline."DEBUG: $returnmsg"; - } - echo "DEBUG: $str".$this->newline; - } - - # DEBUG 모드가 아닐때, 에러 메세지 출력 - if(!$p && $this->failed) { - if($this->ofhtml) echo "\n"; - else "ERROR: $str\n"; - } - } - - function sockets($option=0) { - switch($option) { - case "open" : - $this->sock = @fsockopen($this->mx,25,$this->errno,$this->errstr,30); - $this->debug($this->sock,1,$this->debug); - break; - default : - if($this->sock) fclose($this->sock); - break; - } - } - - function send($str,$chk=0) { - if(!$this->failed) { - if($this->debug) { - if(preg_match("/\r\n/",trim($str))) - $str_debug = trim(str_replace("\r\n","\r\n ",$str)); - else $str_debug = $str; - } - fputs($this->sock,"$str\r\n"); - $recv = trim(fgets($this->sock,1024)); - $recvchk = $recv; - $this->debug($recv,0,$this->debug); - - if(preg_match("/Mail From:/i",$str) && preg_match("/exist|require|error/i",$recvchk) && !$chk) { - $this->failed = 0; - $this->send("MAIL FROM: <".$this->to.">",1); - } - } - } -} - - -function generate_mail_id($uid) { - $id = date("YmdHis",time()); - mt_srand((float) microtime() * 1000000); - $randval = mt_rand(); - $id .= $randval."@$uid"; - return $id; -} - - -function mail_header($to,$from,$title,$mta=0) { - global $langs,$boundary; - - # mail header 를 작성 - $boundary = get_boundary_msg(); - $header = "Message-ID: <".generate_mail_id(preg_replace("/@.+$/i","",$to)).">\r\n". - "From:=?utf-8?B?".base64_encode('보내는사람')."?=<$from>\r\n". - "MIME-Version: 1.0\r\n"; - - if(!$mta) $header .= "Date: ".date ("D, j M Y H:i:s T",time())."\r\n". - "To: $to\r\n". - "Subject: $title\r\n"; - - $header .= "Content-Type: multipart/alternative;\r\n". - " boundary=\"$boundary\"\r\n\r\n"; - - return $header; -} - - -function get_boundary_msg() { - $uniqchr = uniqid(""); - $one = strtoupper($uniqchr[0]); - $two = strtoupper(substr($uniqchr,0,8)); - $three = strtoupper(substr(strrev($uniqchr),0,8)); - return "----=_NextPart_000_000${one}_${two}.${three}"; -} -*/ ?> \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/LICENSE b/plugin/PHPMailer/LICENSE similarity index 97% rename from plugin/PHPMailer_v2.0.4/LICENSE rename to plugin/PHPMailer/LICENSE index 03851a338..8e0763d1c 100644 --- a/plugin/PHPMailer_v2.0.4/LICENSE +++ b/plugin/PHPMailer/LICENSE @@ -1,504 +1,504 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/plugin/PHPMailer/PHPMailerAutoload.php b/plugin/PHPMailer/PHPMailerAutoload.php new file mode 100644 index 000000000..eaa2e3034 --- /dev/null +++ b/plugin/PHPMailer/PHPMailerAutoload.php @@ -0,0 +1,49 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer SPL autoloader. + * @param string $classname The name of the class to load + */ +function PHPMailerAutoload($classname) +{ + //Can't use __DIR__ as it's only in PHP 5.3+ + $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php'; + if (is_readable($filename)) { + require $filename; + } +} + +if (version_compare(PHP_VERSION, '5.1.2', '>=')) { + //SPL autoloading was introduced in PHP 5.1.2 + if (version_compare(PHP_VERSION, '5.3.0', '>=')) { + spl_autoload_register('PHPMailerAutoload', true, true); + } else { + spl_autoload_register('PHPMailerAutoload'); + } +} else { + /** + * Fall back to traditional autoload for old PHP versions + * @param string $classname The name of the class to load + */ + function __autoload($classname) + { + PHPMailerAutoload($classname); + } +} diff --git a/plugin/PHPMailer/README.md b/plugin/PHPMailer/README.md new file mode 100644 index 000000000..0ecfa5dcc --- /dev/null +++ b/plugin/PHPMailer/README.md @@ -0,0 +1,184 @@ +![PHPMailer](https://raw.github.com/PHPMailer/PHPMailer/master/examples/images/phpmailer.png) + +# PHPMailer - A full-featured email creation and transfer class for PHP + +Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer) +[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) +[![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) + +[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) + +## Class Features + +- Probably the world's most popular code for sending email from PHP! +- Used by many open-source projects: WordPress, Drupal, 1CRM, SugarCRM, Yii, Joomla! and many more +- Integrated SMTP support - send without a local mail server +- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs +- Multipart/alternative emails for mail clients that do not read HTML email +- Support for UTF-8 content and 8bit, base64, binary, and quoted-printable encodings +- SMTP authentication with LOGIN, PLAIN, NTLM, CRAM-MD5 and Google's XOAUTH2 mechanisms over SSL and TLS transports +- Error messages in 47 languages! +- DKIM and S/MIME signing support +- Compatible with PHP 5.0 and later +- Much more! + +## Why you might need it + +Many PHP developers utilize email in their code. The only PHP function that supports this is the mail() function. However, it does not provide any assistance for making use of popular features such as HTML-based emails and attachments. + +Formatting email correctly is surprisingly difficult. There are myriad overlapping RFCs, requiring tight adherence to horribly complicated formatting and encoding rules - the vast majority of code that you'll find online that uses the mail() function directly is just plain wrong! +*Please* don't be tempted to do it yourself - if you don't use PHPMailer, there are many other excellent libraries that you should look at before rolling your own - try SwiftMailer, Zend_Mail, eZcomponents etc. + +The PHP mail() function usually sends via a local mail server, typically fronted by a `sendmail` binary on Linux, BSD and OS X platforms, however, Windows usually doesn't include a local mail server; PHPMailer's integrated SMTP implementation allows email sending on Windows platforms without a local mail server. + +## License + +This software is distributed under the [LGPL 2.1](http://www.gnu.org/licenses/lgpl-2.1.html) license. Please read LICENSE for information on the +software availability and distribution. + +## Installation & loading + +PHPMailer is available via [Composer/Packagist](https://packagist.org/packages/phpmailer/phpmailer) (using semantic versioning), so just add this line to your `composer.json` file: + +```json +"phpmailer/phpmailer": "~5.2" +``` + +or + +```sh +composer require phpmailer/phpmailer +``` + +If you want to use the Gmail XOAUTH2 authentication class, you will also need to add a dependency on the `league/oauth2-client` package. + +Alternatively, copy the contents of the PHPMailer folder into somewhere that's in your PHP `include_path` setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub. + +If you're not using composer's autoloader, PHPMailer provides an SPL-compatible autoloader, and that is the preferred way of loading the library - just `require '/path/to/PHPMailerAutoload.php';` and everything should work. The autoloader does not throw errors if it can't find classes so it prepends itself to the SPL list, allowing your own (or your framework's) autoloader to catch errors. SPL autoloading was introduced in PHP 5.1.0, so if you are using a version older than that you will need to require/include each class manually. + +PHPMailer does *not* declare a namespace because namespaces were only introduced in PHP 5.3. + +If you want to use Google's XOAUTH2 authentication mechanism, you need to be running at least PHP 5.4, and load the dependencies listed in `composer.json`. + +### Minimal installation + +While installing the entire package manually or with composer is simple, convenient and reliable, you may want to include only vital files in your project. At the very least you will need [class.phpmailer.php](class.phpmailer.php). If you're using SMTP, you'll need [class.smtp.php](class.smtp.php), and if you're using POP-before SMTP, you'll need [class.pop3.php](class.pop3.php). For all of these, we recommend you use [the autoloader](PHPMailerAutoload.php) too as otherwise you will either have to `require` all classes manually or use some other autoloader. You can skip the [language](language/) folder if you're not showing errors to users and can make do with English-only errors. You may need the additional classes in the [extras](extras/) folder if you are using those features, including NTLM authentication and ics generation. If you're using Google XOAUTH2 you will need `class.phpmaileroauth.php` and `class.oauth.php` classes too, as well as the composer dependencies. + +## A Simple Example + +```php +SMTPDebug = 3; // Enable verbose debug output + +$mail->isSMTP(); // Set mailer to use SMTP +$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers +$mail->SMTPAuth = true; // Enable SMTP authentication +$mail->Username = 'user@example.com'; // SMTP username +$mail->Password = 'secret'; // SMTP password +$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted +$mail->Port = 587; // TCP port to connect to + +$mail->setFrom('from@example.com', 'Mailer'); +$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient +$mail->addAddress('ellen@example.com'); // Name is optional +$mail->addReplyTo('info@example.com', 'Information'); +$mail->addCC('cc@example.com'); +$mail->addBCC('bcc@example.com'); + +$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments +$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name +$mail->isHTML(true); // Set email format to HTML + +$mail->Subject = 'Here is the subject'; +$mail->Body = 'This is the HTML message body in bold!'; +$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; + +if(!$mail->send()) { + echo 'Message could not be sent.'; + echo 'Mailer Error: ' . $mail->ErrorInfo; +} else { + echo 'Message has been sent'; +} +``` + +You'll find plenty more to play with in the [examples](examples/) folder. + +That's it. You should now be ready to use PHPMailer! + +## Localization +PHPMailer defaults to English, but in the [language](language/) folder you'll find numerous (46 at the time of writing!) translations for PHPMailer error messages that you may encounter. Their filenames contain [ISO 639-1](http://en.wikipedia.org/wiki/ISO_639-1) language code for the translations, for example `fr` for French. To specify a language, you need to tell PHPMailer which one to use, like this: + +```php +// To load the French version +$mail->setLanguage('fr', '/optional/path/to/language/directory/'); +``` + +We welcome corrections and new languages - if you're looking for corrections to do, run the [phpmailerLangTest.php](test/phpmailerLangTest.php) script in the tests folder and it will show any missing translations. + +## Documentation + +Examples of how to use PHPMailer for common scenarios can be found in the [examples](examples/) folder. If you're looking for a good starting point, we recommend you start with [the gmail example](examples/gmail.phps). + +There are tips and a troubleshooting guide in the [GitHub wiki](https://github.com/PHPMailer/PHPMailer/wiki). If you're having trouble, this should be the first place you look as it's the most frequently updated. + +Complete generated API documentation is [available online](http://phpmailer.github.io/PHPMailer/). + +You'll find some basic user-level docs in the [docs](docs/) folder, and you can generate complete API-level documentation using the [generatedocs.sh](docs/generatedocs.sh) shell script in the docs folder, though you'll need to install [PHPDocumentor](http://www.phpdoc.org) first. You may find [the unit tests](test/phpmailerTest.php) a good source of how to do various operations such as encryption. + +If the documentation doesn't cover what you need, search the [many questions on StackOverflow](http://stackoverflow.com/questions/tagged/phpmailer), and before you ask a question about "SMTP Error: Could not connect to SMTP host.", [read the troubleshooting guide](https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting). + +## Tests + +There is a PHPUnit test script in the [test](test/) folder. + +Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](https://travis-ci.org/PHPMailer/PHPMailer) + +If this isn't passing, is there something you can do to help? + +## Contributing + +Please submit bug reports, suggestions and pull requests to the [GitHub issue tracker](https://github.com/PHPMailer/PHPMailer/issues). + +We're particularly interested in fixing edge-cases, expanding test coverage and updating translations. + +With the move to the PHPMailer GitHub organisation, you'll need to update any remote URLs referencing the old GitHub location with a command like this from within your clone: + +```sh +git remote set-url upstream https://github.com/PHPMailer/PHPMailer.git +``` + +Please *don't* use the SourceForge or Google Code projects any more. + +## Sponsorship + +Development time and resources for PHPMailer are provided by [Smartmessages.net](https://info.smartmessages.net/), a powerful email marketing system. + +Smartmessages email marketing + +Other contributions are gladly received, whether in beer 🍺, T-shirts 👕, Amazon wishlist raids, or cold, hard cash 💰. + +## Changelog + +See [changelog](changelog.md). + +## History +- PHPMailer was originally written in 2001 by Brent R. Matzelle as a [SourceForge project](http://sourceforge.net/projects/phpmailer/). +- Marcus Bointon (coolbru on SF) and Andy Prevost (codeworxtech) took over the project in 2004. +- Became an Apache incubator project on Google Code in 2010, managed by Jim Jagielski. +- Marcus created his fork on [GitHub](https://github.com/Synchro/PHPMailer). +- Jim and Marcus decide to join forces and use GitHub as the canonical and official repo for PHPMailer. +- PHPMailer moves to the [PHPMailer organisation](https://github.com/PHPMailer) on GitHub. + +### What's changed since moving from SourceForge? +- Official successor to the SourceForge and Google Code projects. +- Test suite. +- Continuous integration with Travis-CI. +- Composer support. +- Public development. +- Additional languages and language strings. +- CRAM-MD5 authentication support. +- Preserves full repo history of authors, commits and branches from the original SourceForge project. diff --git a/plugin/PHPMailer/VERSION b/plugin/PHPMailer/VERSION new file mode 100644 index 000000000..ba678f2d2 --- /dev/null +++ b/plugin/PHPMailer/VERSION @@ -0,0 +1 @@ +5.2.14 \ No newline at end of file diff --git a/plugin/PHPMailer/changelog.md b/plugin/PHPMailer/changelog.md new file mode 100644 index 000000000..486f3289c --- /dev/null +++ b/plugin/PHPMailer/changelog.md @@ -0,0 +1,620 @@ +# ChangeLog + +## Version 5.2.14 (Nov 1st 2015) +* Allow addresses with IDN (Internationalized Domain Name) in PHP 5.3+, thanks to @fbonzon +* Allow access to POP3 errors +* Make all POP3 private properties and methods protected +* **SECURITY** Fix vulnerability that allowed email addresses with line breaks (valid in RFC5322) to pass to SMTP, permitting message injection at the SMTP level. Mitigated in both the address validator and in the lower-level SMTP class. Thanks to Takeshi Terada. +* Updated Brazilian Portuguese translations (Thanks to @phelipealves) + +## Version 5.2.13 (Sep 14th 2015) +* Rename internal oauth class to avoid name clashes +* Improve Estonian translations + +## Version 5.2.12 (Sep 1st 2015) +* Fix incorrect composer package dependencies +* Skip existing embedded image `cid`s in `msgHTML` + +## Version 5.2.11 (Aug 31st 2015) +* Don't switch to quoted-printable for long lines if already using base64 +* Fixed Travis-CI config when run on PHP 7 +* Added Google XOAUTH2 authentication mechanism, thanks to @sherryl4george +* Add address parser for RFC822-format addresses +* Update MS Office MIME types +* Don't convert line breaks when using quoted-printable encoding +* Handle MS Exchange returning an invalid empty AUTH-type list in EHLO +* Don't set name or filename properties on MIME parts that don't have one + +## Version 5.2.10 (May 4th 2015) +* Add custom header getter +* Use `application/javascript` for .js attachments +* Improve RFC2821 compliance for timelimits, especially for end-of-data +* Add Azerbaijani translations (Thanks to @mirjalal) +* Minor code cleanup for robustness +* Add Indonesian translations (Thanks to @ceceprawiro) +* Avoid `error_log` Debugoutput naming clash +* Add ability to parse server capabilities in response to EHLO (useful for SendGrid etc) +* Amended default values for WordWrap to match RFC +* Remove html2text converter class (has incompatible license) +* Provide new mechanism for injecting html to text converters +* Improve pointers to docs and support in README +* Add example file upload script +* Refactor and major cleanup of EasyPeasyICS, now a lot more usable +* Make set() method simpler and more reliable +* Add Malay translation (Thanks to @nawawi) +* Add Bulgarian translation (Thanks to @mialy) +* Add Armenian translation (Thanks to Hrayr Grigoryan) +* Add Slovenian translation (Thanks to Klemen Tušar) +* More efficient word wrapping +* Add support for S/MIME signing with additional CA certificate (thanks to @IgitBuh) +* Fix incorrect MIME structure when using S/MIME signing and isMail() (#372) +* Improved checks and error messages for missing extensions +* Store and report SMTP errors more consistently +* Add MIME multipart preamble for better Outlook compatibility +* Enable TLS encryption automatically if the server offers it +* Provide detailed errors when individual recipients fail +* Report more errors when connecting +* Add extras classes to composer classmap +* Expose stream_context_create options via new SMTPOptions property +* Automatic encoding switch to quoted-printable if message lines are too long +* Add Korean translation (Thanks to @ChalkPE) +* Provide a pointer to troubleshooting docs on SMTP connection failure + +## Version 5.2.9 (Sept 25th 2014) +* **Important: The autoloader is no longer autoloaded by the PHPMailer class** +* Update html2text from https://github.com/mtibben/html2text +* Improve Arabic translations (Thanks to @tarekdj) +* Consistent handling of connection variables in SMTP and POP3 +* PHPDoc cleanup +* Update composer to use PHPUnit 4.1 +* Pass consistent params to callbacks +* More consistent handling of error states and debug output +* Use property defaults, remove constructors +* Remove unreachable code +* Use older regex validation pattern for troublesome PCRE library versions +* Improve PCRE detection in older PHP versions +* Handle debug output consistently, and always in UTF-8 +* Allow user-defined debug output method via a callable +* msgHTML now converts data URIs to embedded images +* SMTP::getLastReply() will now always be populated +* Improved example code in README +* Ensure long filenames in Content-Disposition are encoded correctly +* Simplify SMTP debug output mechanism, clarify levels with constants +* Add SMTP connection check example +* Simplify examples, don't use mysql* functions + +## Version 5.2.8 (May 14th 2014) +* Increase timeout to match RFC2821 section 4.5.3.2 and thus not fail greetdelays, fixes #104 +* Add timestamps to default debug output +* Add connection events and new level 3 to debug output options +* Chinese language update (Thanks to @binaryoung) +* Allow custom Mailer types (Thanks to @michield) +* Cope with spaces around SMTP host specs +* Fix processing of multiple hosts in connect string +* Added Galician translation (Thanks to @donatorouco) +* Autoloader now prepends +* Docs updates +* Add Latvian translation (Thanks to @eddsstudio) +* Add Belarusian translation (Thanks to @amaksymiuk) +* Make autoloader work better on older PHP versions +* Avoid double-encoding if mbstring is overloading mail() +* Add Portuguese translation (Thanks to @Jonadabe) +* Make quoted-printable encoder respect line ending setting +* Improve Chinese translation (Thanks to @PeterDaveHello) +* Add Georgian translation (Thanks to @akalongman) +* Add Greek translation (Thanks to @lenasterg) +* Fix serverHostname on PHP < 5.3 +* Improve performance of SMTP class +* Implement automatic 7bit downgrade +* Add Vietnamese translation (Thanks to @vinades) +* Improve example images, switch to PNG +* Add Croatian translation (Thanks to @hrvoj3e) +* Remove setting the Return-Path and deprecate the Return-path property - it's just wrong! +* Fix language file loading if CWD has changed (@stephandesouza) +* Add HTML5 email validation pattern +* Improve Turkish translations (Thanks to @yasinaydin) +* Improve Romanian translations (Thanks to @aflorea) +* Check php.ini for path to sendmail/qmail before using default +* Improve Farsi translation (Thanks to @MHM5000) +* Don't use quoted-printable encoding for multipart types +* Add Serbian translation (Thanks to ajevremovic at gmail.com) +* Remove useless PHP5 check +* Use SVG for build status badges +* Store MessageDate on creation +* Better default behaviour for validateAddress + +## Version 5.2.7 (September 12th 2013) +* Add Ukrainian translation from @Krezalis +* Support for do_verp +* Fix bug in CRAM-MD5 AUTH +* Propagate Debugoutput option to SMTP class (@Reblutus) +* Determine MIME type of attachments automatically +* Add cross-platform, multibyte-safe pathinfo replacement (with tests) and use it +* Add a new 'html' Debugoutput type +* Clean up SMTP debug output, remove embedded HTML +* Some small changes in header formatting to improve IETF msglint test results +* Update test_script to use some recently changed features, rename to code_generator +* Generated code actually works! +* Update SyntaxHighlighter +* Major overhaul and cleanup of example code +* New PHPMailer graphic +* msgHTML now uses RFC2392-compliant content ids +* Add line break normalization function and use it in msgHTML +* Don't set unnecessary reply-to addresses +* Make fakesendmail.sh a bit cleaner and safer +* Set a content-transfer-encoding on multiparts (fixes msglint error) +* Fix cid generation in msgHTML (Thanks to @digitalthought) +* Fix handling of multiple SMTP servers (Thanks to @NanoCaiordo) +* SMTP->connect() now supports stream context options (Thanks to @stanislavdavid) +* Add support for iCal event alternatives (Thanks to @reblutus) +* Update to Polish language file (Thanks to Krzysztof Kowalewski) +* Update to Norwegian language file (Thanks to @datagutten) +* Update to Hungarian language file (Thanks to @dominicus-75) +* Add Persian/Farsi translation from @jaii +* Make SMTPDebug property type match type in SMTP class +* Add unit tests for DKIM +* Major refactor of SMTP class +* Reformat to PSR-2 coding standard +* Introduce autoloader +* Allow overriding of SMTP class +* Overhaul of PHPDocs +* Fix broken Q-encoding +* Czech language update (Thanks to @nemelu) +* Removal of excess blank lines in messages +* Added fake POP server and unit tests for POP-before-SMTP + +## Version 5.2.6 (April 11th 2013) +* Reflect move to PHPMailer GitHub organisation at https://github.com/PHPMailer/PHPMailer +* Fix unbumped version numbers +* Update packagist.org with new location +* Clean up Changelog + +## Version 5.2.5 (April 6th 2013) +* First official release after move from Google Code +* Fixes for qmail when sending via mail() +* Merge in changes from Google code 5.2.4 release +* Minor coding standards cleanup in SMTP class +* Improved unit tests, now tests S/MIME signing +* Travis-CI support on GitHub, runs tests with fake SMTP server + +## Version 5.2.4 (February 19, 2013) +* Fix tag and version bug. +* un-deprecate isSMTP(), isMail(), IsSendmail() and isQmail(). +* Numerous translation updates + +## Version 5.2.3 (February 8, 2013) +* Fix issue with older PCREs and ValidateAddress() (Bugz: 124) +* Add CRAM-MD5 authentication, thanks to Elijah madden, https://github.com/okonomiyaki3000 +* Replacement of obsolete Quoted-Printable encoder with a much better implementation +* Composer package definition +* New language added: Hebrew + +## Version 5.2.2 (December 3, 2012) +* Some fixes and syncs from https://github.com/Synchro/PHPMailer +* Add Slovak translation, thanks to Michal Tinka + +## Version 5.2.2-rc2 (November 6, 2012) +* Fix SMTP server rotation (Bugz: 118) +* Allow override of autogen'ed 'Date' header (for Drupal's + og_mailinglist module) +* No whitespace after '-f' option (Bugz: 116) +* Work around potential warning (Bugz: 114) + +## Version 5.2.2-rc1 (September 28, 2012) +* Header encoding works with long lines (Bugz: 93) +* Turkish language update (Bugz: 94) +* undefined $pattern in EncodeQ bug squashed (Bugz: 98) +* use of mail() in safe_mode now works (Bugz: 96) +* ValidateAddress() now 'public static' so people can override the + default and use their own validation scheme. +* ValidateAddress() no longer uses broken FILTER_VALIDATE_EMAIL +* Added in AUTH PLAIN SMTP authentication + +## Version 5.2.2-beta2 (August 17, 2012) +* Fixed Postfix VERP support (Bugz: 92) +* Allow action_function callbacks to pass/use + the From address (passed as final param) +* Prevent inf look for get_lines() (Bugz: 77) +* New public var ($UseSendmailOptions). Only pass sendmail() + options iff we really are using sendmail or something sendmail + compatible. (Bugz: 75) +* default setting for LE returned to "\n" due to popular demand. + +## Version 5.2.2-beta1 (July 13, 2012) +* Expose PreSend() and PostSend() as public methods to allow + for more control if serializing message sending. +* GetSentMIMEMessage() only constructs the message copy when + needed. Save memory. +* Only pass params to mail() if the underlying MTA is + "sendmail" (as defined as "having the string sendmail + in its pathname") [#69] +* Attachments now work with Amazon SES and others [Bugz#70] +* Debug output now sent to stdout (via echo) or error_log [Bugz#5] +* New var: Debugoutput (for above) [Bugz#5] +* SMTP reads now Timeout aware (new var: Timeout=15) [Bugz#71] +* SMTP reads now can have a Timelimit associated with them + (new var: Timelimit=30)[Bugz#71] +* Fix quoting issue associated with charsets +* default setting for LE is now RFC compliant: "\r\n" +* Return-Path can now be user defined (new var: ReturnPath) + (the default is "" which implies no change from previous + behavior, which was to use either From or Sender) [Bugz#46] +* X-Mailer header can now be disabled (by setting to a + whitespace string, eg " ") [Bugz#66] +* Bugz closed: #68, #60, #42, #43, #59, #55, #66, #48, #49, + #52, #31, #41, #5. #70, #69 + +## Version 5.2.1 (January 16, 2012) +* Closed several bugs #5 +* Performance improvements +* MsgHTML() now returns the message as required. +* New method: GetSentMIMEMessage() (returns full copy of sent message) + +## Version 5.2 (July 19, 2011) +* protected MIME body and header +* better DKIM DNS Resource Record support +* better aly handling +* htmlfilter class added to extras +* moved to Apache Extras + +## Version 5.1 (October 20, 2009) +* fixed filename issue with AddStringAttachment (thanks to Tony) +* fixed "SingleTo" property, now works with Senmail, Qmail, and SMTP in + addition to PHP mail() +* added DKIM digital signing functionality, new properties: + - DKIM_domain (sets the domain name) + - DKIM_private (holds DKIM private key) + - DKIM_passphrase (holds your DKIM passphrase) + - DKIM_selector (holds the DKIM "selector") + - DKIM_identity (holds the identifying email address) +* added callback function support + - callback function parameters include: + result, to, cc, bcc, subject and body + - see the test/test_callback.php file for usage. +* added "auto" identity functionality + - can automatically add: + - Return-path (if Sender not set) + - Reply-To (if ReplyTo not set) + - can be disabled: + - $mail->SetFrom('yourname@yourdomain.com','First Last',false); + - or by adding the $mail->Sender and/or $mail->ReplyTo properties + +Note: "auto" identity added to help with emails ending up in spam or junk boxes because of missing headers + +## Version 5.0.2 (May 24, 2009) +* Fix for missing attachments when inline graphics are present +* Fix for missing Cc in header when using SMTP (mail was sent, + but not displayed in header -- Cc receiver only saw email To: + line and no Cc line, but did get the email (To receiver + saw same) + +## Version 5.0.1 (April 05, 2009) +* Temporary fix for missing attachments + +## Version 5.0.0 (April 02, 2009) +With the release of this version, we are initiating a new version numbering +system to differentiate from the PHP4 version of PHPMailer. +Most notable in this release is fully object oriented code. + +### class.smtp.php: +* Refactored class.smtp.php to support new exception handling +* code size reduced from 29.2 Kb to 25.6 Kb +* Removed unnecessary functions from class.smtp.php: + - public function Expand($name) { + - public function Help($keyword="") { + - public function Noop() { + - public function Send($from) { + - public function SendOrMail($from) { + - public function Verify($name) { + +### class.phpmailer.php: +* Refactored class.phpmailer.php with new exception handling +* Changed processing functionality of Sendmail and Qmail so they cannot be + inadvertently used +* removed getFile() function, just became a simple wrapper for + file_get_contents() +* added check for PHP version (will gracefully exit if not at least PHP 5.0) +* enhanced code to check if an attachment source is the same as an embedded or + inline graphic source to eliminate duplicate attachments + +### New /test_script +We have written a test script you can use to test the script as part of your +installation. Once you press submit, the test script will send a multi-mime +email with either the message you type in or an HTML email with an inline +graphic. Two attachments are included in the email (one of the attachments +is also the inline graphic so you can see that only one copy of the graphic +is sent in the email). The test script will also display the functional +script that you can copy/paste to your editor to duplicate the functionality. + +### New examples +All new examples in both basic and advanced modes. Advanced examples show + Exception handling. + +### PHPDocumentator (phpdocs) documentation for PHPMailer version 5.0.0 +All new documentation + +## Version 2.3 (November 06, 2008) +* added Arabic language (many thanks to Bahjat Al Mostafa) +* removed English language from language files and made it a default within + class.phpmailer.php - if no language is found, it will default to use + the english language translation +* fixed public/private declarations +* corrected line 1728, $basedir to $directory +* added $sign_cert_file to avoid improper duplicate use of $sign_key_file +* corrected $this->Hello on line 612 to $this->Helo +* changed default of $LE to "\r\n" to comply with RFC 2822. Can be set by the user + if default is not acceptable +* removed trim() from return results in EncodeQP +* /test and three files it contained are removed from version 2.3 +* fixed phpunit.php for compliance with PHP5 +* changed $this->AltBody = $textMsg; to $this->AltBody = html_entity_decode($textMsg); +* We have removed the /phpdoc from the downloads. All documentation is now on + the http://phpmailer.codeworxtech.com website. + +## Version 2.2.1 () July 19 2008 +* fixed line 1092 in class.smtp.php (my apologies, error on my part) + +## Version 2.2 () July 15 2008 +* Fixed redirect issue (display of UTF-8 in thank you redirect) +* fixed error in getResponse function declaration (class.pop3.php) +* PHPMailer now PHP6 compliant +* fixed line 1092 in class.smtp.php (endless loop from missing = sign) + +## Version 2.1 (Wed, June 04 2008) +NOTE: WE HAVE A NEW LANGUAGE VARIABLE FOR DIGITALLY SIGNED S/MIME EMAILS. IF YOU CAN HELP WITH LANGUAGES OTHER THAN ENGLISH AND SPANISH, IT WOULD BE APPRECIATED. + +* added S/MIME functionality (ability to digitally sign emails) + BIG THANKS TO "sergiocambra" for posting this patch back in November 2007. + The "Signed Emails" functionality adds the Sign method to pass the private key + filename and the password to read it, and then email will be sent with + content-type multipart/signed and with the digital signature attached. +* fully compatible with E_STRICT error level + - Please note: + In about half the test environments this development version was subjected + to, an error was thrown for the date() functions used (line 1565 and 1569). + This is NOT a PHPMailer error, it is the result of an incorrectly configured + PHP5 installation. The fix is to modify your 'php.ini' file and include the + date.timezone = Etc/UTC (or your own zone) + directive, to your own server timezone + - If you do get this error, and are unable to access your php.ini file: + In your PHP script, add + `date_default_timezone_set('Etc/UTC');` + - do not try to use + `$myVar = date_default_timezone_get();` + as a test, it will throw an error. +* added ability to define path (mainly for embedded images) + function `MsgHTML($message,$basedir='')` ... where: + `$basedir` is the fully qualified path +* fixed `MsgHTML()` function: + - Embedded Images where images are specified by `://` will not be altered or embedded +* fixed the return value of SMTP exit code ( pclose ) +* addressed issue of multibyte characters in subject line and truncating +* added ability to have user specified Message ID + (default is still that PHPMailer create a unique Message ID) +* corrected unidentified message type to 'application/octet-stream' +* fixed chunk_split() multibyte issue (thanks to Colin Brown, et al). +* added check for added attachments +* enhanced conversion of HTML to text in MsgHTML (thanks to "brunny") + +## Version 2.1.0beta2 (Sun, Dec 02 2007) +* implemented updated EncodeQP (thanks to coolbru, aka Marcus Bointon) +* finished all testing, all known bugs corrected, enhancements tested + +Note: will NOT work with PHP4. + +Please note, this is BETA software **DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS; INTENDED STRICTLY FOR TESTING** + +## Version 2.1.0beta1 +Please note, this is BETA software +** DO NOT USE THIS IN PRODUCTION OR LIVE PROJECTS + INTENDED STRICTLY FOR TESTING + +## Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release +* implements new property to control VERP in class.smtp.php + example (requires instantiating class.smtp.php): + $mail->do_verp = true; +* POP-before-SMTP functionality included, thanks to Richard Davey + (see class.pop3.php & pop3_before_smtp_test.php for examples) +* included example showing how to use PHPMailer with GMAIL +* fixed the missing Cc in SendMail() and Mail() + +## Version 2.0.0 rc1 (Thu, Nov 08 2007), interim release +* dramatically simplified using inline graphics ... it's fully automated and requires no user input +* added automatic document type detection for attachments and pictures +* added MsgHTML() function to replace Body tag for HTML emails +* fixed the SendMail security issues (input validation vulnerability) +* enhanced the AddAddresses functionality so that the "Name" portion is used in the email address +* removed the need to use the AltBody method (set from the HTML, or default text used) +* set the PHP Mail() function as the default (still support SendMail, SMTP Mail) +* removed the need to set the IsHTML property (set automatically) +* added Estonian language file by Indrek Päri +* added header injection patch +* added "set" method to permit users to create their own pseudo-properties like 'X-Headers', etc. +* fixed warning message in SMTP get_lines method +* added TLS/SSL SMTP support. +* PHPMailer has been tested with PHP4 (4.4.7) and PHP5 (5.2.7) +* Works with PHP installed as a module or as CGI-PHP +NOTE: will NOT work with PHP5 in E_STRICT error mode + +## Version 1.73 (Sun, Jun 10 2005) +* Fixed denial of service bug: http://www.cybsec.com/vuln/PHPMailer-DOS.pdf +* Now has a total of 20 translations +* Fixed alt attachments bug: http://tinyurl.com/98u9k + +## Version 1.72 (Wed, May 25 2004) +* Added Dutch, Swedish, Czech, Norwegian, and Turkish translations. +* Received: Removed this method because spam filter programs like + SpamAssassin reject this header. +* Fixed error count bug. +* SetLanguage default is now "language/". +* Fixed magic_quotes_runtime bug. + +## Version 1.71 (Tue, Jul 28 2003) +* Made several speed enhancements +* Added German and Italian translation files +* Fixed HELO/AUTH bugs on keep-alive connects +* Now provides an error message if language file does not load +* Fixed attachment EOL bug +* Updated some unclear documentation +* Added additional tests and improved others + +## Version 1.70 (Mon, Jun 20 2003) +* Added SMTP keep-alive support +* Added IsError method for error detection +* Added error message translation support (SetLanguage) +* Refactored many methods to increase library performance +* Hello now sends the newer EHLO message before HELO as per RFC 2821 +* Removed the boundary class and replaced it with GetBoundary +* Removed queue support methods +* New $Hostname variable +* New Message-ID header +* Received header reformat +* Helo variable default changed to $Hostname +* Removed extra spaces in Content-Type definition (#667182) +* Return-Path should be set to Sender when set +* Adds Q or B encoding to headers when necessary +* quoted-encoding should now encode NULs \000 +* Fixed encoding of body/AltBody (#553370) +* Adds "To: undisclosed-recipients:;" when all recipients are hidden (BCC) +* Multiple bug fixes + +## Version 1.65 (Fri, Aug 09 2002) +* Fixed non-visible attachment bug (#585097) for Outlook +* SMTP connections are now closed after each transaction +* Fixed SMTP::Expand return value +* Converted SMTP class documentation to phpDocumentor format + +## Version 1.62 (Wed, Jun 26 2002) +* Fixed multi-attach bug +* Set proper word wrapping +* Reduced memory use with attachments +* Added more debugging +* Changed documentation to phpDocumentor format + +## Version 1.60 (Sat, Mar 30 2002) +* Sendmail pipe and address patch (Christian Holtje) +* Added embedded image and read confirmation support (A. Ognio) +* Added unit tests +* Added SMTP timeout support (*nix only) +* Added possibly temporary PluginDir variable for SMTP class +* Added LE message line ending variable +* Refactored boundary and attachment code +* Eliminated SMTP class warnings +* Added SendToQueue method for future queuing support + +## Version 1.54 (Wed, Dec 19 2001) +* Add some queuing support code +* Fixed a pesky multi/alt bug +* Messages are no longer forced to have "To" addresses + +## Version 1.50 (Thu, Nov 08 2001) +* Fix extra lines when not using SMTP mailer +* Set WordWrap variable to int with a zero default + +## Version 1.47 (Tue, Oct 16 2001) +* Fixed Received header code format +* Fixed AltBody order error +* Fixed alternate port warning + +## Version 1.45 (Tue, Sep 25 2001) +* Added enhanced SMTP debug support +* Added support for multiple ports on SMTP +* Added Received header for tracing +* Fixed AddStringAttachment encoding +* Fixed possible header name quote bug +* Fixed wordwrap() trim bug +* Couple other small bug fixes + +## Version 1.41 (Wed, Aug 22 2001) +* Fixed AltBody bug w/o attachments +* Fixed rfc_date() for certain mail servers + +## Version 1.40 (Sun, Aug 12 2001) +* Added multipart/alternative support (AltBody) +* Documentation update +* Fixed bug in Mercury MTA + +## Version 1.29 (Fri, Aug 03 2001) +* Added AddStringAttachment() method +* Added SMTP authentication support + +## Version 1.28 (Mon, Jul 30 2001) +* Fixed a typo in SMTP class +* Fixed header issue with Imail (win32) SMTP server +* Made fopen() calls for attachments use "rb" to fix win32 error + +## Version 1.25 (Mon, Jul 02 2001) +* Added RFC 822 date fix (Patrice) +* Added improved error handling by adding a $ErrorInfo variable +* Removed MailerDebug variable (obsolete with new error handler) + +## Version 1.20 (Mon, Jun 25 2001) +* Added quoted-printable encoding (Patrice) +* Set Version as public and removed PrintVersion() +* Changed phpdoc to only display public variables and methods + +## Version 1.19 (Thu, Jun 21 2001) +* Fixed MS Mail header bug +* Added fix for Bcc problem with mail(). *Does not work on Win32* + (See PHP bug report: http://www.php.net/bugs.php?id=11616) +* mail() no longer passes a fifth parameter when not needed + +## Version 1.15 (Fri, Jun 15 2001) +Note: these changes contributed by Patrice Fournier +* Changed all remaining \n to \r\n +* Bcc: header no longer written to message except + when sent directly to sendmail +* Added a small message to non-MIME compliant mail reader +* Added Sender variable to change the Sender email + used in -f for sendmail/mail and in 'MAIL FROM' for smtp mode +* Changed boundary setting to a place it will be set only once +* Removed transfer encoding for whole message when using multipart +* Message body now uses Encoding in multipart messages +* Can set encoding and type to attachments 7bit, 8bit + and binary attachment are sent as is, base64 are encoded +* Can set Encoding to base64 to send 8 bits body + through 7 bits servers + +## Version 1.10 (Tue, Jun 12 2001) +* Fixed win32 mail header bug (printed out headers in message body) + +## Version 1.09 (Fri, Jun 08 2001) +* Changed date header to work with Netscape mail programs +* Altered phpdoc documentation + +## Version 1.08 (Tue, Jun 05 2001) +* Added enhanced error-checking +* Added phpdoc documentation to source + +## Version 1.06 (Fri, Jun 01 2001) +* Added optional name for file attachments + +## Version 1.05 (Tue, May 29 2001) +* Code cleanup +* Eliminated sendmail header warning message +* Fixed possible SMTP error + +## Version 1.03 (Thu, May 24 2001) +* Fixed problem where qmail sends out duplicate messages + +## Version 1.02 (Wed, May 23 2001) +* Added multiple recipient and attachment Clear* methods +* Added Sendmail public variable +* Fixed problem with loading SMTP library multiple times + +## Version 0.98 (Tue, May 22 2001) +* Fixed problem with redundant mail hosts sending out multiple messages +* Added additional error handler code +* Added AddCustomHeader() function +* Added support for Microsoft mail client headers (affects priority) +* Fixed small bug with Mailer variable +* Added PrintVersion() function + +## Version 0.92 (Tue, May 15 2001) +* Changed file names to class.phpmailer.php and class.smtp.php to match + current PHP class trend. +* Fixed problem where body not being printed when a message is attached +* Several small bug fixes + +## Version 0.90 (Tue, April 17 2001) +* Initial public release diff --git a/plugin/PHPMailer/class.phpmailer.php b/plugin/PHPMailer/class.phpmailer.php new file mode 100644 index 000000000..e4dd00bf3 --- /dev/null +++ b/plugin/PHPMailer/class.phpmailer.php @@ -0,0 +1,3883 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer - PHP email creation and transport class. + * @package PHPMailer + * @author Marcus Bointon (Synchro/coolbru) + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + */ +class PHPMailer +{ + /** + * The PHPMailer Version number. + * @var string + */ + public $Version = '5.2.14'; + + /** + * Email priority. + * Options: null (default), 1 = High, 3 = Normal, 5 = low. + * When null, the header is not set at all. + * @var integer + */ + public $Priority = null; + + /** + * The character set of the message. + * @var string + */ + public $CharSet = 'iso-8859-1'; + + /** + * The MIME Content-type of the message. + * @var string + */ + public $ContentType = 'text/plain'; + + /** + * The message encoding. + * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". + * @var string + */ + public $Encoding = '8bit'; + + /** + * Holds the most recent mailer error message. + * @var string + */ + public $ErrorInfo = ''; + + /** + * The From email address for the message. + * @var string + */ + public $From = 'root@localhost'; + + /** + * The From name of the message. + * @var string + */ + public $FromName = 'Root User'; + + /** + * The Sender email (Return-Path) of the message. + * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. + * @var string + */ + public $Sender = ''; + + /** + * The Return-Path of the message. + * If empty, it will be set to either From or Sender. + * @var string + * @deprecated Email senders should never set a return-path header; + * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything. + * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference + */ + public $ReturnPath = ''; + + /** + * The Subject of the message. + * @var string + */ + public $Subject = ''; + + /** + * An HTML or plain text message body. + * If HTML then call isHTML(true). + * @var string + */ + public $Body = ''; + + /** + * The plain-text message body. + * This body can be read by mail clients that do not have HTML email + * capability such as mutt & Eudora. + * Clients that can read HTML will view the normal Body. + * @var string + */ + public $AltBody = ''; + + /** + * An iCal message part body. + * Only supported in simple alt or alt_inline message types + * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator + * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/ + * @link http://kigkonsult.se/iCalcreator/ + * @var string + */ + public $Ical = ''; + + /** + * The complete compiled MIME message body. + * @access protected + * @var string + */ + protected $MIMEBody = ''; + + /** + * The complete compiled MIME message headers. + * @var string + * @access protected + */ + protected $MIMEHeader = ''; + + /** + * Extra headers that createHeader() doesn't fold in. + * @var string + * @access protected + */ + protected $mailHeader = ''; + + /** + * Word-wrap the message body to this number of chars. + * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. + * @var integer + */ + public $WordWrap = 0; + + /** + * Which method to use to send mail. + * Options: "mail", "sendmail", or "smtp". + * @var string + */ + public $Mailer = 'mail'; + + /** + * The path to the sendmail program. + * @var string + */ + public $Sendmail = '/usr/sbin/sendmail'; + + /** + * Whether mail() uses a fully sendmail-compatible MTA. + * One which supports sendmail's "-oi -f" options. + * @var boolean + */ + public $UseSendmailOptions = true; + + /** + * Path to PHPMailer plugins. + * Useful if the SMTP class is not in the PHP include path. + * @var string + * @deprecated Should not be needed now there is an autoloader. + */ + public $PluginDir = ''; + + /** + * The email address that a reading confirmation should be sent to, also known as read receipt. + * @var string + */ + public $ConfirmReadingTo = ''; + + /** + * The hostname to use in the Message-ID header and as default HELO string. + * If empty, PHPMailer attempts to find one with, in order, + * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value + * 'localhost.localdomain'. + * @var string + */ + public $Hostname = ''; + + /** + * An ID to be used in the Message-ID header. + * If empty, a unique id will be generated. + * @var string + */ + public $MessageID = ''; + + /** + * The message Date to be used in the Date header. + * If empty, the current date will be added. + * @var string + */ + public $MessageDate = ''; + + /** + * SMTP hosts. + * Either a single hostname or multiple semicolon-delimited hostnames. + * You can also specify a different port + * for each host by using this format: [hostname:port] + * (e.g. "smtp1.example.com:25;smtp2.example.com"). + * You can also specify encryption type, for example: + * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). + * Hosts will be tried in order. + * @var string + */ + public $Host = 'localhost'; + + /** + * The default SMTP server port. + * @var integer + * @TODO Why is this needed when the SMTP class takes care of it? + */ + public $Port = 25; + + /** + * The SMTP HELO of the message. + * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find + * one with the same method described above for $Hostname. + * @var string + * @see PHPMailer::$Hostname + */ + public $Helo = ''; + + /** + * What kind of encryption to use on the SMTP connection. + * Options: '', 'ssl' or 'tls' + * @var string + */ + public $SMTPSecure = ''; + + /** + * Whether to enable TLS encryption automatically if a server supports it, + * even if `SMTPSecure` is not set to 'tls'. + * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. + * @var boolean + */ + public $SMTPAutoTLS = true; + + /** + * Whether to use SMTP authentication. + * Uses the Username and Password properties. + * @var boolean + * @see PHPMailer::$Username + * @see PHPMailer::$Password + */ + public $SMTPAuth = false; + + /** + * Options array passed to stream_context_create when connecting via SMTP. + * @var array + */ + public $SMTPOptions = array(); + + /** + * SMTP username. + * @var string + */ + public $Username = ''; + + /** + * SMTP password. + * @var string + */ + public $Password = ''; + + /** + * SMTP auth type. + * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5 + * @var string + */ + public $AuthType = ''; + + /** + * SMTP realm. + * Used for NTLM auth + * @var string + */ + public $Realm = ''; + + /** + * SMTP workstation. + * Used for NTLM auth + * @var string + */ + public $Workstation = ''; + + /** + * The SMTP server timeout in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * @var integer + */ + public $Timeout = 300; + + /** + * SMTP class debug output mode. + * Debug output level. + * Options: + * * `0` No output + * * `1` Commands + * * `2` Data and commands + * * `3` As 2 plus connection status + * * `4` Low-level data output + * @var integer + * @see SMTP::$do_debug + */ + public $SMTPDebug = 0; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `
`, appropriate for browser output + * * `error_log` Output to error log as configured in php.ini + * + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * + * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; + * + * @var string|callable + * @see SMTP::$Debugoutput + */ + public $Debugoutput = 'echo'; + + /** + * Whether to keep SMTP connection open after each message. + * If this is set to true then to close the connection + * requires an explicit call to smtpClose(). + * @var boolean + */ + public $SMTPKeepAlive = false; + + /** + * Whether to split multiple to addresses into multiple messages + * or send them all in one message. + * @var boolean + */ + public $SingleTo = false; + + /** + * Storage for addresses when SingleTo is enabled. + * @var array + * @TODO This should really not be public + */ + public $SingleToArray = array(); + + /** + * Whether to generate VERP addresses on send. + * Only applicable when sending via SMTP. + * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path + * @link http://www.postfix.org/VERP_README.html Postfix VERP info + * @var boolean + */ + public $do_verp = false; + + /** + * Whether to allow sending messages with an empty body. + * @var boolean + */ + public $AllowEmpty = false; + + /** + * The default line ending. + * @note The default remains "\n". We force CRLF where we know + * it must be used via self::CRLF. + * @var string + */ + public $LE = "\n"; + + /** + * DKIM selector. + * @var string + */ + public $DKIM_selector = ''; + + /** + * DKIM Identity. + * Usually the email address used as the source of the email + * @var string + */ + public $DKIM_identity = ''; + + /** + * DKIM passphrase. + * Used if your key is encrypted. + * @var string + */ + public $DKIM_passphrase = ''; + + /** + * DKIM signing domain name. + * @example 'example.com' + * @var string + */ + public $DKIM_domain = ''; + + /** + * DKIM private key file path. + * @var string + */ + public $DKIM_private = ''; + + /** + * Callback Action function name. + * + * The function that handles the result of the send email action. + * It is called out by send() for each email sent. + * + * Value can be any php callable: http://www.php.net/is_callable + * + * Parameters: + * boolean $result result of the send action + * string $to email address of the recipient + * string $cc cc email addresses + * string $bcc bcc email addresses + * string $subject the subject + * string $body the email body + * string $from email address of sender + * @var string + */ + public $action_function = ''; + + /** + * What to put in the X-Mailer header. + * Options: An empty string for PHPMailer default, whitespace for none, or a string to use + * @var string + */ + public $XMailer = ''; + + /** + * An instance of the SMTP sender class. + * @var SMTP + * @access protected + */ + protected $smtp = null; + + /** + * The array of 'to' names and addresses. + * @var array + * @access protected + */ + protected $to = array(); + + /** + * The array of 'cc' names and addresses. + * @var array + * @access protected + */ + protected $cc = array(); + + /** + * The array of 'bcc' names and addresses. + * @var array + * @access protected + */ + protected $bcc = array(); + + /** + * The array of reply-to names and addresses. + * @var array + * @access protected + */ + protected $ReplyTo = array(); + + /** + * An array of all kinds of addresses. + * Includes all of $to, $cc, $bcc + * @var array + * @access protected + * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc + */ + protected $all_recipients = array(); + + /** + * An array of names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $all_recipients + * and one of $to, $cc, or $bcc. + * This array is used only for addresses with IDN. + * @var array + * @access protected + * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc + * @see PHPMailer::$all_recipients + */ + protected $RecipientsQueue = array(); + + /** + * An array of reply-to names and addresses queued for validation. + * In send(), valid and non duplicate entries are moved to $ReplyTo. + * This array is used only for addresses with IDN. + * @var array + * @access protected + * @see PHPMailer::$ReplyTo + */ + protected $ReplyToQueue = array(); + + /** + * The array of attachments. + * @var array + * @access protected + */ + protected $attachment = array(); + + /** + * The array of custom headers. + * @var array + * @access protected + */ + protected $CustomHeader = array(); + + /** + * The most recent Message-ID (including angular brackets). + * @var string + * @access protected + */ + protected $lastMessageID = ''; + + /** + * The message's MIME type. + * @var string + * @access protected + */ + protected $message_type = ''; + + /** + * The array of MIME boundary strings. + * @var array + * @access protected + */ + protected $boundary = array(); + + /** + * The array of available languages. + * @var array + * @access protected + */ + protected $language = array(); + + /** + * The number of errors encountered. + * @var integer + * @access protected + */ + protected $error_count = 0; + + /** + * The S/MIME certificate file path. + * @var string + * @access protected + */ + protected $sign_cert_file = ''; + + /** + * The S/MIME key file path. + * @var string + * @access protected + */ + protected $sign_key_file = ''; + + /** + * The optional S/MIME extra certificates ("CA Chain") file path. + * @var string + * @access protected + */ + protected $sign_extracerts_file = ''; + + /** + * The S/MIME password for the key. + * Used only if the key is encrypted. + * @var string + * @access protected + */ + protected $sign_key_pass = ''; + + /** + * Whether to throw exceptions for errors. + * @var boolean + * @access protected + */ + protected $exceptions = false; + + /** + * Unique ID used for message ID and boundaries. + * @var string + * @access protected + */ + protected $uniqueid = ''; + + /** + * Error severity: message only, continue processing. + */ + const STOP_MESSAGE = 0; + + /** + * Error severity: message, likely ok to continue processing. + */ + const STOP_CONTINUE = 1; + + /** + * Error severity: message, plus full stop, critical error reached. + */ + const STOP_CRITICAL = 2; + + /** + * SMTP RFC standard line ending. + */ + const CRLF = "\r\n"; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1 + * @var integer + */ + const MAX_LINE_LENGTH = 998; + + /** + * Constructor. + * @param boolean $exceptions Should we throw external exceptions? + */ + public function __construct($exceptions = false) + { + $this->exceptions = (boolean)$exceptions; + } + + /** + * Destructor. + */ + public function __destruct() + { + //Close any open SMTP connection nicely + if ($this->Mailer == 'smtp') { + $this->smtpClose(); + } + } + + /** + * Call mail() in a safe_mode-aware fashion. + * Also, unless sendmail_path points to sendmail (or something that + * claims to be sendmail), don't pass params (not a perfect fix, + * but it will do) + * @param string $to To + * @param string $subject Subject + * @param string $body Message Body + * @param string $header Additional Header(s) + * @param string $params Params + * @access private + * @return boolean + */ + private function mailPassthru($to, $subject, $body, $header, $params) + { + //Check overloading of mail function to avoid double-encoding + if (ini_get('mbstring.func_overload') & 1) { + $subject = $this->secureHeader($subject); + } else { + $subject = $this->encodeHeader($this->secureHeader($subject)); + } + if (ini_get('safe_mode') || !($this->UseSendmailOptions)) { + $result = @mail($to, $subject, $body, $header); + } else { + $result = @mail($to, $subject, $body, $header, $params); + } + return $result; + } + + /** + * Output debugging info via user-defined method. + * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug). + * @see PHPMailer::$Debugoutput + * @see PHPMailer::$SMTPDebug + * @param string $str + */ + protected function edebug($str) + { + if ($this->SMTPDebug <= 0) { + return; + } + //Avoid clash with built-in function names + if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { + call_user_func($this->Debugoutput, $str, $this->SMTPDebug); + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ) + . "
\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); + echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( + "\n", + "\n \t ", + trim($str) + ) . "\n"; + } + } + + /** + * Sets message type to HTML or plain. + * @param boolean $isHtml True for HTML mode. + * @return void + */ + public function isHTML($isHtml = true) + { + if ($isHtml) { + $this->ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Send messages using SMTP. + * @return void + */ + public function isSMTP() + { + $this->Mailer = 'smtp'; + } + + /** + * Send messages using PHP's mail() function. + * @return void + */ + public function isMail() + { + $this->Mailer = 'mail'; + } + + /** + * Send messages using $Sendmail. + * @return void + */ + public function isSendmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (!stristr($ini_sendmail_path, 'sendmail')) { + $this->Sendmail = '/usr/sbin/sendmail'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'sendmail'; + } + + /** + * Send messages using qmail. + * @return void + */ + public function isQmail() + { + $ini_sendmail_path = ini_get('sendmail_path'); + + if (!stristr($ini_sendmail_path, 'qmail')) { + $this->Sendmail = '/var/qmail/bin/qmail-inject'; + } else { + $this->Sendmail = $ini_sendmail_path; + } + $this->Mailer = 'qmail'; + } + + /** + * Add a "To" address. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addAddress($address, $name = '') + { + return $this->addOrEnqueueAnAddress('to', $address, $name); + } + + /** + * Add a "CC" address. + * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('cc', $address, $name); + } + + /** + * Add a "BCC" address. + * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addBCC($address, $name = '') + { + return $this->addOrEnqueueAnAddress('bcc', $address, $name); + } + + /** + * Add a "Reply-To" address. + * @param string $address The email address to reply to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + */ + public function addReplyTo($address, $name = '') + { + return $this->addOrEnqueueAnAddress('Reply-To', $address, $name); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer + * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still + * be modified after calling this function), addition of such addresses is delayed until send(). + * Addresses that have been added already return false, but do not throw exceptions. + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * @throws phpmailerException + * @return boolean true on success, false if address already used or invalid in some way + * @access protected + */ + protected function addOrEnqueueAnAddress($kind, $address, $name) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (($pos = strrpos($address, '@')) === false) { + // At-sign is misssing. + $error_message = $this->lang('invalid_address') . $address; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + $params = array($kind, $address, $name); + // Enqueue addresses with IDN until we know the PHPMailer::$CharSet. + if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) { + if ($kind != 'Reply-To') { + if (!array_key_exists($address, $this->RecipientsQueue)) { + $this->RecipientsQueue[$address] = $params; + return true; + } + } else { + if (!array_key_exists($address, $this->ReplyToQueue)) { + $this->ReplyToQueue[$address] = $params; + return true; + } + } + return false; + } + // Immediately add standard addresses without IDN. + return call_user_func_array(array($this, 'addAnAddress'), $params); + } + + /** + * Add an address to one of the recipient arrays or to the ReplyTo array. + * Addresses that have been added already return false, but do not throw exceptions. + * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo' + * @param string $address The email address to send, resp. to reply to + * @param string $name + * @throws phpmailerException + * @return boolean true on success, false if address already used or invalid in some way + * @access protected + */ + protected function addAnAddress($kind, $address, $name = '') + { + if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) { + $error_message = $this->lang('Invalid recipient kind: ') . $kind; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + if (!$this->validateAddress($address)) { + $error_message = $this->lang('invalid_address') . $address; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + if ($kind != 'Reply-To') { + if (!array_key_exists(strtolower($address), $this->all_recipients)) { + array_push($this->$kind, array($address, $name)); + $this->all_recipients[strtolower($address)] = true; + return true; + } + } else { + if (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = array($address, $name); + return true; + } + } + return false; + } + + /** + * Parse and validate a string containing one or more RFC822-style comma-separated email addresses + * of the form "display name
" into an array of name/address pairs. + * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. + * Note that quotes in the name part are removed. + * @param string $addrstr The address list string + * @param bool $useimap Whether to use the IMAP extension to parse the list + * @return array + * @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation + */ + public function parseAddresses($addrstr, $useimap = true) + { + $addresses = array(); + if ($useimap and function_exists('imap_rfc822_parse_adrlist')) { + //Use this built-in parser if it's available + $list = imap_rfc822_parse_adrlist($addrstr, ''); + foreach ($list as $address) { + if ($address->host != '.SYNTAX-ERROR.') { + if ($this->validateAddress($address->mailbox . '@' . $address->host)) { + $addresses[] = array( + 'name' => (property_exists($address, 'personal') ? $address->personal : ''), + 'address' => $address->mailbox . '@' . $address->host + ); + } + } + } + } else { + //Use this simpler parser + $list = explode(',', $addrstr); + foreach ($list as $address) { + $address = trim($address); + //Is there a separate name part? + if (strpos($address, '<') === false) { + //No separate name, just use the whole thing + if ($this->validateAddress($address)) { + $addresses[] = array( + 'name' => '', + 'address' => $address + ); + } + } else { + list($name, $email) = explode('<', $address); + $email = trim(str_replace('>', '', $email)); + if ($this->validateAddress($email)) { + $addresses[] = array( + 'name' => trim(str_replace(array('"', "'"), '', $name)), + 'address' => $email + ); + } + } + } + } + return $addresses; + } + + /** + * Set the From and FromName properties. + * @param string $address + * @param string $name + * @param boolean $auto Whether to also set the Sender address, defaults to true + * @throws phpmailerException + * @return boolean + */ + public function setFrom($address, $name = '', $auto = true) + { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + // Don't validate now addresses with IDN. Will be done in send(). + if (($pos = strrpos($address, '@')) === false or + (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and + !$this->validateAddress($address)) { + $error_message = $this->lang('invalid_address') . $address; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto) { + if (empty($this->Sender)) { + $this->Sender = $address; + } + } + return true; + } + + /** + * Return the Message-ID header of the last email. + * Technically this is the value from the last time the headers were created, + * but it's also the message ID of the last sent message except in + * pathological cases. + * @return string + */ + public function getLastMessageID() + { + return $this->lastMessageID; + } + + /** + * Check that a string looks like an email address. + * @param string $address The email address to check + * @param string $patternselect A selector for the validation pattern to use : + * * `auto` Pick best pattern automatically; + * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14; + * * `pcre` Use old PCRE implementation; + * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL; + * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements. + * * `noregex` Don't use a regex: super fast, really dumb. + * @return boolean + * @static + * @access public + */ + public static function validateAddress($address, $patternselect = 'auto') + { + //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321 + if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) { + return false; + } + if (!$patternselect or $patternselect == 'auto') { + //Check this constant first so it works when extension_loaded() is disabled by safe mode + //Constant was added in PHP 5.2.4 + if (defined('PCRE_VERSION')) { + //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2 + if (version_compare(PCRE_VERSION, '8.0.3') >= 0) { + $patternselect = 'pcre8'; + } else { + $patternselect = 'pcre'; + } + } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) { + //Fall back to older PCRE + $patternselect = 'pcre'; + } else { + //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension + if (version_compare(PHP_VERSION, '5.2.0') >= 0) { + $patternselect = 'php'; + } else { + $patternselect = 'noregex'; + } + } + } + switch ($patternselect) { + case 'pcre8': + /** + * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains. + * @link http://squiloople.com/2009/12/20/email-address-validation/ + * @copyright 2009-2010 Michael Rushton + * Feel free to use and redistribute this code. But please keep this copyright notice. + */ + return (boolean)preg_match( + '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' . + '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' . + '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' . + '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*' . + '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)' . + '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}' . + '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:' . + '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', + $address + ); + case 'pcre': + //An older regex that doesn't need a recent PCRE + return (boolean)preg_match( + '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' . + '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' . + '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' . + '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})' . + '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:' . + '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?' . + '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:' . + '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?' . + '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}' . + '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', + $address + ); + case 'html5': + /** + * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements. + * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email) + */ + return (boolean)preg_match( + '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' . + '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD', + $address + ); + case 'noregex': + //No PCRE! Do something _very_ approximate! + //Check the address is 3 chars or longer and contains an @ that's not the first or last char + return (strlen($address) >= 3 + and strpos($address, '@') >= 1 + and strpos($address, '@') != strlen($address) - 1); + case 'php': + default: + return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL); + } + } + + /** + * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the + * "intl" and "mbstring" PHP extensions. + * @return bool "true" if required functions for IDN support are present + */ + public function idnSupported() + { + // @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2. + return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding'); + } + + /** + * Converts IDN in given email address to its ASCII form, also known as punycode, if possible. + * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet. + * This function silently returns unmodified address if: + * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form) + * - Conversion to punycode is impossible (e.g. required PHP functions are not available) + * or fails for any reason (e.g. domain has characters not allowed in an IDN) + * @see PHPMailer::$CharSet + * @param string $address The email address to convert + * @return string The encoded address in ASCII form + */ + public function punyencodeAddress($address) + { + // Verify we have required functions, CharSet, and at-sign. + if ($this->idnSupported() and + !empty($this->CharSet) and + ($pos = strrpos($address, '@')) !== false) { + $domain = substr($address, ++$pos); + // Verify CharSet string is a valid one, and domain properly encoded in this CharSet. + if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) { + $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet); + if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ? + idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) : + idn_to_ascii($domain)) !== false) { + return substr($address, 0, $pos) . $punycode; + } + } + } + return $address; + } + + /** + * Create a message and send it. + * Uses the sending method specified by $Mailer. + * @throws phpmailerException + * @return boolean false on error - See the ErrorInfo property for details of the error. + */ + public function send() + { + try { + if (!$this->preSend()) { + return false; + } + return $this->postSend(); + } catch (phpmailerException $exc) { + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + } + + /** + * Prepare a message for sending. + * @throws phpmailerException + * @return boolean + */ + public function preSend() + { + try { + $this->error_count = 0; // Reset errors + $this->mailHeader = ''; + + // Dequeue recipient and Reply-To addresses with IDN + foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) { + $params[1] = $this->punyencodeAddress($params[1]); + call_user_func_array(array($this, 'addAnAddress'), $params); + } + if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); + } + + // Validate From, Sender, and ConfirmReadingTo addresses + foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) { + $this->$address_kind = trim($this->$address_kind); + if (empty($this->$address_kind)) { + continue; + } + $this->$address_kind = $this->punyencodeAddress($this->$address_kind); + if (!$this->validateAddress($this->$address_kind)) { + $error_message = $this->lang('invalid_address') . $this->$address_kind; + $this->setError($error_message); + $this->edebug($error_message); + if ($this->exceptions) { + throw new phpmailerException($error_message); + } + return false; + } + } + + // Set whether the message is multipart/alternative + if (!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->setMessageType(); + // Refuse to send an empty message unless we are specifically allowing it + if (!$this->AllowEmpty and empty($this->Body)) { + throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); + } + + // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding) + $this->MIMEHeader = ''; + $this->MIMEBody = $this->createBody(); + // createBody may have added some headers, so retain them + $tempheaders = $this->MIMEHeader; + $this->MIMEHeader = $this->createHeader(); + $this->MIMEHeader .= $tempheaders; + + // To capture the complete message when using mail(), create + // an extra header list which createHeader() doesn't fold in + if ($this->Mailer == 'mail') { + if (count($this->to) > 0) { + $this->mailHeader .= $this->addrAppend('To', $this->to); + } else { + $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + $this->mailHeader .= $this->headerLine( + 'Subject', + $this->encodeHeader($this->secureHeader(trim($this->Subject))) + ); + } + + // Sign with DKIM if enabled + if (!empty($this->DKIM_domain) + && !empty($this->DKIM_private) + && !empty($this->DKIM_selector) + && file_exists($this->DKIM_private)) { + $header_dkim = $this->DKIM_Add( + $this->MIMEHeader . $this->mailHeader, + $this->encodeHeader($this->secureHeader($this->Subject)), + $this->MIMEBody + ); + $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . + str_replace("\r\n", "\n", $header_dkim) . self::CRLF; + } + return true; + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + } + + /** + * Actually send a message. + * Send the email via the selected mechanism + * @throws phpmailerException + * @return boolean + */ + public function postSend() + { + try { + // Choose the mailer and send through it + switch ($this->Mailer) { + case 'sendmail': + case 'qmail': + return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody); + case 'smtp': + return $this->smtpSend($this->MIMEHeader, $this->MIMEBody); + case 'mail': + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + default: + $sendMethod = $this->Mailer.'Send'; + if (method_exists($this, $sendMethod)) { + return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody); + } + + return $this->mailSend($this->MIMEHeader, $this->MIMEBody); + } + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + } + return false; + } + + /** + * Send mail using the $Sendmail program. + * @param string $header The message headers + * @param string $body The message body + * @see PHPMailer::$Sendmail + * @throws phpmailerException + * @access protected + * @return boolean + */ + protected function sendmailSend($header, $body) + { + if ($this->Sender != '') { + if ($this->Mailer == 'qmail') { + $sendmail = sprintf('%s -f%s', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf('%s -oi -f%s -t', escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } + } else { + if ($this->Mailer == 'qmail') { + $sendmail = sprintf('%s', escapeshellcmd($this->Sendmail)); + } else { + $sendmail = sprintf('%s -oi -t', escapeshellcmd($this->Sendmail)); + } + } + if ($this->SingleTo) { + foreach ($this->SingleToArray as $toAddr) { + if (!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, 'To: ' . $toAddr . "\n"); + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result == 0), + array($toAddr), + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From + ); + if ($result != 0) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + if (!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + $this->doCallback( + ($result == 0), + $this->to, + $this->cc, + $this->bcc, + $this->Subject, + $body, + $this->From + ); + if ($result != 0) { + throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + return true; + } + + /** + * Send mail using the PHP mail() function. + * @param string $header The message headers + * @param string $body The message body + * @link http://www.php.net/manual/en/book.mail.php + * @throws phpmailerException + * @access protected + * @return boolean + */ + protected function mailSend($header, $body) + { + $toArr = array(); + foreach ($this->to as $toaddr) { + $toArr[] = $this->addrFormat($toaddr); + } + $to = implode(', ', $toArr); + + if (empty($this->Sender)) { + $params = ' '; + } else { + $params = sprintf('-f%s', $this->Sender); + } + if ($this->Sender != '' and !ini_get('safe_mode')) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + } + $result = false; + if ($this->SingleTo && count($toArr) > 1) { + foreach ($toArr as $toAddr) { + $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params); + $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From); + } + } else { + $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params); + $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From); + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if (!$result) { + throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL); + } + return true; + } + + /** + * Get an instance to use for SMTP operations. + * Override this function to load your own SMTP implementation + * @return SMTP + */ + public function getSMTPInstance() + { + if (!is_object($this->smtp)) { + $this->smtp = new SMTP; + } + return $this->smtp; + } + + /** + * Send mail via SMTP. + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * Uses the PHPMailerSMTP class by default. + * @see PHPMailer::getSMTPInstance() to use a different class. + * @param string $header The message headers + * @param string $body The message body + * @throws phpmailerException + * @uses SMTP + * @access protected + * @return boolean + */ + protected function smtpSend($header, $body) + { + $bad_rcpt = array(); + if (!$this->smtpConnect($this->SMTPOptions)) { + throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + if ('' == $this->Sender) { + $smtp_from = $this->From; + } else { + $smtp_from = $this->Sender; + } + if (!$this->smtp->mail($smtp_from)) { + $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); + throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL); + } + + // Attempt to send to all recipients + foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { + foreach ($togroup as $to) { + if (!$this->smtp->recipient($to[0])) { + $error = $this->smtp->getError(); + $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']); + $isSent = false; + } else { + $isSent = true; + } + $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); + } + } + + // Only send the DATA command if we have viable recipients + if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { + throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL); + } + if ($this->SMTPKeepAlive) { + $this->smtp->reset(); + } else { + $this->smtp->quit(); + $this->smtp->close(); + } + //Create error message for any bad addresses + if (count($bad_rcpt) > 0) { + $errstr = ''; + foreach ($bad_rcpt as $bad) { + $errstr .= $bad['to'] . ': ' . $bad['error']; + } + throw new phpmailerException( + $this->lang('recipients_failed') . $errstr, + self::STOP_CONTINUE + ); + } + return true; + } + + /** + * Initiate a connection to an SMTP server. + * Returns false if the operation failed. + * @param array $options An array of options compatible with stream_context_create() + * @uses SMTP + * @access public + * @throws phpmailerException + * @return boolean + */ + public function smtpConnect($options = array()) + { + if (is_null($this->smtp)) { + $this->smtp = $this->getSMTPInstance(); + } + + // Already connected? + if ($this->smtp->connected()) { + return true; + } + + $this->smtp->setTimeout($this->Timeout); + $this->smtp->setDebugLevel($this->SMTPDebug); + $this->smtp->setDebugOutput($this->Debugoutput); + $this->smtp->setVerp($this->do_verp); + $hosts = explode(';', $this->Host); + $lastexception = null; + + foreach ($hosts as $hostentry) { + $hostinfo = array(); + if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { + // Not a valid host entry + continue; + } + // $hostinfo[2]: optional ssl or tls prefix + // $hostinfo[3]: the hostname + // $hostinfo[4]: optional port number + // The host string prefix can temporarily override the current setting for SMTPSecure + // If it's not specified, the default value is used + $prefix = ''; + $secure = $this->SMTPSecure; + $tls = ($this->SMTPSecure == 'tls'); + if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) { + $prefix = 'ssl://'; + $tls = false; // Can't have SSL and TLS at the same time + $secure = 'ssl'; + } elseif ($hostinfo[2] == 'tls') { + $tls = true; + // tls doesn't use a prefix + $secure = 'tls'; + } + //Do we need the OpenSSL extension? + $sslext = defined('OPENSSL_ALGO_SHA1'); + if ('tls' === $secure or 'ssl' === $secure) { + //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled + if (!$sslext) { + throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); + } + } + $host = $hostinfo[3]; + $port = $this->Port; + $tport = (integer)$hostinfo[4]; + if ($tport > 0 and $tport < 65536) { + $port = $tport; + } + if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { + try { + if ($this->Helo) { + $hello = $this->Helo; + } else { + $hello = $this->serverHostname(); + } + $this->smtp->hello($hello); + //Automatically enable TLS encryption if: + // * it's not disabled + // * we have openssl extension + // * we are not already using SSL + // * the server offers STARTTLS + if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) { + $tls = true; + } + if ($tls) { + if (!$this->smtp->startTLS()) { + throw new phpmailerException($this->lang('connect_host')); + } + // We must resend HELO after tls negotiation + $this->smtp->hello($hello); + } + if ($this->SMTPAuth) { + if (!$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->Realm, + $this->Workstation + ) + ) { + throw new phpmailerException($this->lang('authenticate')); + } + } + return true; + } catch (phpmailerException $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + // We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } + } + } + // If we get here, all connection attempts have failed, so close connection hard + $this->smtp->close(); + // As we've caught all exceptions, just report whatever the last one was + if ($this->exceptions and !is_null($lastexception)) { + throw $lastexception; + } + return false; + } + + /** + * Close the active SMTP session if one exists. + * @return void + */ + public function smtpClose() + { + if ($this->smtp !== null) { + if ($this->smtp->connected()) { + $this->smtp->quit(); + $this->smtp->close(); + } + } + } + + /** + * Set the language for error messages. + * Returns false if it cannot load the language file. + * The default language is English. + * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr") + * @param string $lang_path Path to the language file directory, with trailing separator (slash) + * @return boolean + * @access public + */ + public function setLanguage($langcode = 'en', $lang_path = '') + { + // Define full set of translatable strings in English + $PHPMAILER_LANG = array( + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'data_not_accepted' => 'SMTP Error: data not accepted.', + 'empty_message' => 'Message body empty', + 'encoding' => 'Unknown encoding: ', + 'execute' => 'Could not execute: ', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'from_failed' => 'The following From address failed: ', + 'instantiate' => 'Could not instantiate mail function.', + 'invalid_address' => 'Invalid address: ', + 'mailer_not_supported' => ' mailer is not supported.', + 'provide_address' => 'You must provide at least one recipient email address.', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'signing' => 'Signing Error: ', + 'smtp_connect_failed' => 'SMTP connect() failed.', + 'smtp_error' => 'SMTP server error: ', + 'variable_set' => 'Cannot set or reset variable: ', + 'extension_missing' => 'Extension missing: ' + ); + if (empty($lang_path)) { + // Calculate an absolute path so it can work if CWD is not here + $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR; + } + $foundlang = true; + $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php'; + // There is no English translation file + if ($langcode != 'en') { + // Make sure language file path is readable + if (!is_readable($lang_file)) { + $foundlang = false; + } else { + // Overwrite language-specific strings. + // This way we'll never have missing translation keys. + $foundlang = include $lang_file; + } + } + $this->language = $PHPMAILER_LANG; + return (boolean)$foundlang; // Returns false if language not found + } + + /** + * Get the array of strings for the current language. + * @return array + */ + public function getTranslations() + { + return $this->language; + } + + /** + * Create recipient headers. + * @access public + * @param string $type + * @param array $addr An array of recipient, + * where each recipient is a 2-element indexed array with element 0 containing an address + * and element 1 containing a name, like: + * array(array('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User')) + * @return string + */ + public function addrAppend($type, $addr) + { + $addresses = array(); + foreach ($addr as $address) { + $addresses[] = $this->addrFormat($address); + } + return $type . ': ' . implode(', ', $addresses) . $this->LE; + } + + /** + * Format an address for use in a message header. + * @access public + * @param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name + * like array('joe@example.com', 'Joe User') + * @return string + */ + public function addrFormat($addr) + { + if (empty($addr[1])) { // No name provided + return $this->secureHeader($addr[0]); + } else { + return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader( + $addr[0] + ) . '>'; + } + } + + /** + * Word-wrap message. + * For use with mailers that do not automatically perform wrapping + * and for quoted-printable encoded messages. + * Original written by philippe. + * @param string $message The message to wrap + * @param integer $length The line length to wrap to + * @param boolean $qp_mode Whether to run in Quoted-Printable mode + * @access public + * @return string + */ + public function wrapText($message, $length, $qp_mode = false) + { + if ($qp_mode) { + $soft_break = sprintf(' =%s', $this->LE); + } else { + $soft_break = $this->LE; + } + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == 'utf-8'); + $lelen = strlen($this->LE); + $crlflen = strlen(self::CRLF); + + $message = $this->fixEOL($message); + //Remove a trailing line break + if (substr($message, -$lelen) == $this->LE) { + $message = substr($message, 0, -$lelen); + } + + //Split message into lines + $lines = explode($this->LE, $message); + //Message will be rebuilt in here + $message = ''; + foreach ($lines as $line) { + $words = explode(' ', $line); + $buf = ''; + $firstword = true; + foreach ($words as $word) { + if ($qp_mode and (strlen($word) > $length)) { + $space_left = $length - strlen($buf) - $crlflen; + if (!$firstword) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->utf8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == '=') { + $len--; + } elseif (substr($word, $len - 2, 1) == '=') { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf('=%s', self::CRLF); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + if ($length <= 0) { + break; + } + $len = $length; + if ($is_utf8) { + $len = $this->utf8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == '=') { + $len--; + } elseif (substr($word, $len - 2, 1) == '=') { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf('=%s', self::CRLF); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + if (!$firstword) { + $buf .= ' '; + } + $buf .= $word; + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + $firstword = false; + } + $message .= $buf . self::CRLF; + } + + return $message; + } + + /** + * Find the last character boundary prior to $maxLength in a utf-8 + * quoted-printable encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param integer $maxLength Find the last character boundary prior to this length + * @return integer + */ + public function utf8CharBoundary($encodedText, $maxLength) + { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, '='); + if (false !== $encodedCharPos) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { + // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + if ($encodedCharPos > 0) { + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + } + $foundSplitPos = true; + } elseif ($dec >= 192) { + // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { + // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + /** + * Apply word wrapping to the message body. + * Wraps the message body to the number of chars set in the WordWrap property. + * You should only do this to plain-text bodies as wrapping HTML tags may break them. + * This is called automatically by createBody(), so you don't need to call it yourself. + * @access public + * @return void + */ + public function setWordWrap() + { + if ($this->WordWrap < 1) { + return; + } + + switch ($this->message_type) { + case 'alt': + case 'alt_inline': + case 'alt_attach': + case 'alt_inline_attach': + $this->AltBody = $this->wrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->wrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assemble message headers. + * @access public + * @return string The assembled headers + */ + public function createHeader() + { + $result = ''; + + if ($this->MessageDate == '') { + $this->MessageDate = self::rfcDate(); + } + $result .= $this->headerLine('Date', $this->MessageDate); + + // To be created automatically by mail() + if ($this->SingleTo) { + if ($this->Mailer != 'mail') { + foreach ($this->to as $toaddr) { + $this->SingleToArray[] = $this->addrFormat($toaddr); + } + } + } else { + if (count($this->to) > 0) { + if ($this->Mailer != 'mail') { + $result .= $this->addrAppend('To', $this->to); + } + } elseif (count($this->cc) == 0) { + $result .= $this->headerLine('To', 'undisclosed-recipients:;'); + } + } + + $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); + + // sendmail and mail() extract Cc from the header before sending + if (count($this->cc) > 0) { + $result .= $this->addrAppend('Cc', $this->cc); + } + + // sendmail and mail() extract Bcc from the header before sending + if (( + $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' + ) + and count($this->bcc) > 0 + ) { + $result .= $this->addrAppend('Bcc', $this->bcc); + } + + if (count($this->ReplyTo) > 0) { + $result .= $this->addrAppend('Reply-To', $this->ReplyTo); + } + + // mail() sets the subject itself + if ($this->Mailer != 'mail') { + $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); + } + + if ($this->MessageID != '') { + $this->lastMessageID = $this->MessageID; + } else { + $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname()); + } + $result .= $this->headerLine('Message-ID', $this->lastMessageID); + if (!is_null($this->Priority)) { + $result .= $this->headerLine('X-Priority', $this->Priority); + } + if ($this->XMailer == '') { + $result .= $this->headerLine( + 'X-Mailer', + 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)' + ); + } else { + $myXmailer = trim($this->XMailer); + if ($myXmailer) { + $result .= $this->headerLine('X-Mailer', $myXmailer); + } + } + + if ($this->ConfirmReadingTo != '') { + $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>'); + } + + // Add custom headers + foreach ($this->CustomHeader as $header) { + $result .= $this->headerLine( + trim($header[0]), + $this->encodeHeader(trim($header[1])) + ); + } + if (!$this->sign_key_file) { + $result .= $this->headerLine('MIME-Version', '1.0'); + $result .= $this->getMailMIME(); + } + + return $result; + } + + /** + * Get the message MIME type headers. + * @access public + * @return string + */ + public function getMailMIME() + { + $result = ''; + $ismultipart = true; + switch ($this->message_type) { + case 'inline': + $result .= $this->headerLine('Content-Type', 'multipart/related;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'attach': + case 'inline_attach': + case 'alt_attach': + case 'alt_inline_attach': + $result .= $this->headerLine('Content-Type', 'multipart/mixed;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + case 'alt': + case 'alt_inline': + $result .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + default: + // Catches case 'plain': and case '': + $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet); + $ismultipart = false; + break; + } + // RFC1341 part 5 says 7bit is assumed if not specified + if ($this->Encoding != '7bit') { + // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE + if ($ismultipart) { + if ($this->Encoding == '8bit') { + $result .= $this->headerLine('Content-Transfer-Encoding', '8bit'); + } + // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible + } else { + $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding); + } + } + + if ($this->Mailer != 'mail') { + $result .= $this->LE; + } + + return $result; + } + + /** + * Returns the whole MIME message. + * Includes complete headers and body. + * Only valid post preSend(). + * @see PHPMailer::preSend() + * @access public + * @return string + */ + public function getSentMIMEMessage() + { + return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody; + } + + /** + * Assemble the message body. + * Returns an empty string on failure. + * @access public + * @throws phpmailerException + * @return string The assembled message body + */ + public function createBody() + { + $body = ''; + //Create unique IDs and preset boundaries + $this->uniqueid = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $this->uniqueid; + $this->boundary[2] = 'b2_' . $this->uniqueid; + $this->boundary[3] = 'b3_' . $this->uniqueid; + + if ($this->sign_key_file) { + $body .= $this->getMailMIME() . $this->LE; + } + + $this->setWordWrap(); + + $bodyEncoding = $this->Encoding; + $bodyCharSet = $this->CharSet; + //Can we do a 7-bit downgrade? + if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) { + $bodyEncoding = '7bit'; + $bodyCharSet = 'us-ascii'; + } + //If lines are too long, and we're not already using an encoding that will shorten them, + //change to quoted-printable transfer encoding + if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) { + $this->Encoding = 'quoted-printable'; + $bodyEncoding = 'quoted-printable'; + } + + $altBodyEncoding = $this->Encoding; + $altBodyCharSet = $this->CharSet; + //Can we do a 7-bit downgrade? + if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) { + $altBodyEncoding = '7bit'; + $altBodyCharSet = 'us-ascii'; + } + //If lines are too long, change to quoted-printable transfer encoding + if (self::hasLineLongerThanMax($this->AltBody)) { + $altBodyEncoding = 'quoted-printable'; + } + //Use this as a preamble in all multipart message types + $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE; + switch ($this->message_type) { + case 'inline': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[1]); + break; + case 'attach': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'inline_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'alt': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + if (!empty($this->Ical)) { + $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', ''); + $body .= $this->encodeString($this->Ical, $this->Encoding); + $body .= $this->LE . $this->LE; + } + $body .= $this->endBoundary($this->boundary[1]); + break; + case 'alt_inline': + $body .= $mimepre; + $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[2]); + $body .= $this->LE; + $body .= $this->endBoundary($this->boundary[1]); + break; + case 'alt_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->endBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + case 'alt_inline_attach': + $body .= $mimepre; + $body .= $this->textLine('--' . $this->boundary[1]); + $body .= $this->headerLine('Content-Type', 'multipart/alternative;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding); + $body .= $this->encodeString($this->AltBody, $altBodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->textLine('--' . $this->boundary[2]); + $body .= $this->headerLine('Content-Type', 'multipart/related;'); + $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"'); + $body .= $this->LE; + $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding); + $body .= $this->encodeString($this->Body, $bodyEncoding); + $body .= $this->LE . $this->LE; + $body .= $this->attachAll('inline', $this->boundary[3]); + $body .= $this->LE; + $body .= $this->endBoundary($this->boundary[2]); + $body .= $this->LE; + $body .= $this->attachAll('attachment', $this->boundary[1]); + break; + default: + // catch case 'plain' and case '' + $body .= $this->encodeString($this->Body, $bodyEncoding); + break; + } + + if ($this->isError()) { + $body = ''; + } elseif ($this->sign_key_file) { + try { + if (!defined('PKCS7_TEXT')) { + throw new phpmailerException($this->lang('extension_missing') . 'openssl'); + } + // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1 + $file = tempnam(sys_get_temp_dir(), 'mail'); + if (false === file_put_contents($file, $body)) { + throw new phpmailerException($this->lang('signing') . ' Could not write temp file'); + } + $signed = tempnam(sys_get_temp_dir(), 'signed'); + //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197 + if (empty($this->sign_extracerts_file)) { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null + ); + } else { + $sign = @openssl_pkcs7_sign( + $file, + $signed, + 'file://' . realpath($this->sign_cert_file), + array('file://' . realpath($this->sign_key_file), $this->sign_key_pass), + null, + PKCS7_DETACHED, + $this->sign_extracerts_file + ); + } + if ($sign) { + @unlink($file); + $body = file_get_contents($signed); + @unlink($signed); + //The message returned by openssl contains both headers and body, so need to split them up + $parts = explode("\n\n", $body, 2); + $this->MIMEHeader .= $parts[0] . $this->LE . $this->LE; + $body = $parts[1]; + } else { + @unlink($file); + @unlink($signed); + throw new phpmailerException($this->lang('signing') . openssl_error_string()); + } + } catch (phpmailerException $exc) { + $body = ''; + if ($this->exceptions) { + throw $exc; + } + } + } + return $body; + } + + /** + * Return the start of a message boundary. + * @access protected + * @param string $boundary + * @param string $charSet + * @param string $contentType + * @param string $encoding + * @return string + */ + protected function getBoundary($boundary, $charSet, $contentType, $encoding) + { + $result = ''; + if ($charSet == '') { + $charSet = $this->CharSet; + } + if ($contentType == '') { + $contentType = $this->ContentType; + } + if ($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->textLine('--' . $boundary); + $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); + $result .= $this->LE; + // RFC1341 part 5 says 7bit is assumed if not specified + if ($encoding != '7bit') { + $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); + } + $result .= $this->LE; + + return $result; + } + + /** + * Return the end of a message boundary. + * @access protected + * @param string $boundary + * @return string + */ + protected function endBoundary($boundary) + { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Set the message type. + * PHPMailer only supports some preset message types, + * not arbitrary MIME structures. + * @access protected + * @return void + */ + protected function setMessageType() + { + $type = array(); + if ($this->alternativeExists()) { + $type[] = 'alt'; + } + if ($this->inlineImageExists()) { + $type[] = 'inline'; + } + if ($this->attachmentExists()) { + $type[] = 'attach'; + } + $this->message_type = implode('_', $type); + if ($this->message_type == '') { + $this->message_type = 'plain'; + } + } + + /** + * Format a header line. + * @access public + * @param string $name + * @param string $value + * @return string + */ + public function headerLine($name, $value) + { + return $name . ': ' . $value . $this->LE; + } + + /** + * Return a formatted mail line. + * @access public + * @param string $value + * @return string + */ + public function textLine($value) + { + return $value . $this->LE; + } + + /** + * Add an attachment from a path on the filesystem. + * Returns false if the file could not be found or read. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @param string $disposition Disposition to use + * @throws phpmailerException + * @return boolean + */ + public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') + { + try { + if (!@is_file($path)) { + throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); + } + + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($path); + } + + $filename = basename($path); + if ($name == '') { + $name = $filename; + } + + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => $disposition, + 7 => 0 + ); + + } catch (phpmailerException $exc) { + $this->setError($exc->getMessage()); + $this->edebug($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + return true; + } + + /** + * Return the array of attachments. + * @return array + */ + public function getAttachments() + { + return $this->attachment; + } + + /** + * Attach all file, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access protected + * @param string $disposition_type + * @param string $boundary + * @return string + */ + protected function attachAll($disposition_type, $boundary) + { + // Return text of body + $mime = array(); + $cidUniq = array(); + $incl = array(); + + // Add all attachments + foreach ($this->attachment as $attachment) { + // Check if it is a valid disposition_filter + if ($attachment[6] == $disposition_type) { + // Check for string attachment + $string = ''; + $path = ''; + $bString = $attachment[5]; + if ($bString) { + $string = $attachment[0]; + } else { + $path = $attachment[0]; + } + + $inclhash = md5(serialize($attachment)); + if (in_array($inclhash, $incl)) { + continue; + } + $incl[] = $inclhash; + $name = $attachment[2]; + $encoding = $attachment[3]; + $type = $attachment[4]; + $disposition = $attachment[6]; + $cid = $attachment[7]; + if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) { + continue; + } + $cidUniq[$cid] = true; + + $mime[] = sprintf('--%s%s', $boundary, $this->LE); + //Only include a filename property if we have one + if (!empty($name)) { + $mime[] = sprintf( + 'Content-Type: %s; name="%s"%s', + $type, + $this->encodeHeader($this->secureHeader($name)), + $this->LE + ); + } else { + $mime[] = sprintf( + 'Content-Type: %s%s', + $type, + $this->LE + ); + } + // RFC1341 part 5 says 7bit is assumed if not specified + if ($encoding != '7bit') { + $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE); + } + + if ($disposition == 'inline') { + $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE); + } + + // If a filename contains any of these chars, it should be quoted, + // but not otherwise: RFC2183 & RFC2045 5.1 + // Fixes a warning in IETF's msglint MIME checker + // Allow for bypassing the Content-Disposition header totally + if (!(empty($disposition))) { + $encoded_name = $this->encodeHeader($this->secureHeader($name)); + if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) { + $mime[] = sprintf( + 'Content-Disposition: %s; filename="%s"%s', + $disposition, + $encoded_name, + $this->LE . $this->LE + ); + } else { + if (!empty($encoded_name)) { + $mime[] = sprintf( + 'Content-Disposition: %s; filename=%s%s', + $disposition, + $encoded_name, + $this->LE . $this->LE + ); + } else { + $mime[] = sprintf( + 'Content-Disposition: %s%s', + $disposition, + $this->LE . $this->LE + ); + } + } + } else { + $mime[] = $this->LE; + } + + // Encode as string attachment + if ($bString) { + $mime[] = $this->encodeString($string, $encoding); + if ($this->isError()) { + return ''; + } + $mime[] = $this->LE . $this->LE; + } else { + $mime[] = $this->encodeFile($path, $encoding); + if ($this->isError()) { + return ''; + } + $mime[] = $this->LE . $this->LE; + } + } + } + + $mime[] = sprintf('--%s--%s', $boundary, $this->LE); + + return implode('', $mime); + } + + /** + * Encode a file attachment in requested format. + * Returns an empty string on failure. + * @param string $path The full path to the file + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @throws phpmailerException + * @access protected + * @return string + */ + protected function encodeFile($path, $encoding = 'base64') + { + try { + if (!is_readable($path)) { + throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE); + } + $magic_quotes = get_magic_quotes_runtime(); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime(false); + } else { + //Doesn't exist in PHP 5.4, but we don't need to check because + //get_magic_quotes_runtime always returns false in 5.4+ + //so it will never get here + ini_set('magic_quotes_runtime', false); + } + } + $file_buffer = file_get_contents($path); + $file_buffer = $this->encodeString($file_buffer, $encoding); + if ($magic_quotes) { + if (version_compare(PHP_VERSION, '5.3.0', '<')) { + set_magic_quotes_runtime($magic_quotes); + } else { + ini_set('magic_quotes_runtime', $magic_quotes); + } + } + return $file_buffer; + } catch (Exception $exc) { + $this->setError($exc->getMessage()); + return ''; + } + } + + /** + * Encode a string in requested format. + * Returns an empty string on failure. + * @param string $str The text to encode + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @access public + * @return string + */ + public function encodeString($str, $encoding = 'base64') + { + $encoded = ''; + switch (strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->fixEOL($str); + // Make sure it ends with a line break + if (substr($encoded, -(strlen($this->LE))) != $this->LE) { + $encoded .= $this->LE; + } + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->encodeQP($str); + break; + default: + $this->setError($this->lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string optimally. + * Picks shortest of Q, B, quoted-printable or none. + * @access public + * @param string $str + * @param string $position + * @return string + */ + public function encodeHeader($str, $position = 'text') + { + $matchcount = 0; + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + // Can't use addslashes as we don't know the value of magic_quotes_sybase + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + /** @noinspection PhpMissingBreakStatementInspection */ + case 'comment': + $matchcount = preg_match_all('/[()"]/', $str, $matches); + // Intentional fall-through + case 'text': + default: + $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + //There are no chars that need encoding + if ($matchcount == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + // Try to select the encoding which should produce the shortest output + if ($matchcount > strlen($str) / 3) { + // More than a third of the content will need encoding, so B encoding will be most efficient + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->base64EncodeWrapMB($str, "\n"); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->encodeQ($str, $position); + $encoded = $this->wrapText($encoded, $maxlen, true); + $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Check if a string contains multi-byte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return boolean + */ + public function hasMultiBytes($str) + { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return false; + } + } + + /** + * Does a string contain any 8-bit chars (in any charset)? + * @param string $text + * @return boolean + */ + public function has8bitChars($text) + { + return (boolean)preg_match('/[\x80-\xFF]/', $text); + } + + /** + * Encode and wrap long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid + * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283 + * @access public + * @param string $str multi-byte text to wrap encode + * @param string $linebreak string to use as linefeed/end-of-line + * @return string + */ + public function base64EncodeWrapMB($str, $linebreak = null) + { + $start = '=?' . $this->CharSet . '?B?'; + $end = '?='; + $encoded = ''; + if ($linebreak === null) { + $linebreak = $this->LE; + } + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } while (strlen($chunk) > $length); + $encoded .= $chunk . $linebreak; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($linebreak)); + return $encoded; + } + + /** + * Encode a string in quoted-printable format. + * According to RFC2045 section 6.7. + * @access public + * @param string $string The text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment + */ + public function encodeQP($string, $line_max = 76) + { + // Use native function if it's available (>= PHP5.3) + if (function_exists('quoted_printable_encode')) { + return quoted_printable_encode($string); + } + // Fall back to a pure PHP implementation + $string = str_replace( + array('%20', '%0D%0A.', '%0D%0A', '%'), + array(' ', "\r\n=2E", "\r\n", '='), + rawurlencode($string) + ); + return preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string); + } + + /** + * Backward compatibility wrapper for an old QP encoding function that was removed. + * @see PHPMailer::encodeQP() + * @access public + * @param string $string + * @param integer $line_max + * @param boolean $space_conv + * @return string + * @deprecated Use encodeQP instead. + */ + public function encodeQPphp( + $string, + $line_max = 76, + /** @noinspection PhpUnusedParameterInspection */ $space_conv = false + ) { + return $this->encodeQP($string, $line_max); + } + + /** + * Encode a string using Q encoding. + * @link http://tools.ietf.org/html/rfc2047 + * @param string $str the text to encode + * @param string $position Where the text is going to be used, see the RFC for what that means + * @access public + * @return string + */ + public function encodeQ($str, $position = 'text') + { + // There should not be any EOL in the string + $pattern = ''; + $encoded = str_replace(array("\r", "\n"), '', $str); + switch (strtolower($position)) { + case 'phrase': + // RFC 2047 section 5.3 + $pattern = '^A-Za-z0-9!*+\/ -'; + break; + /** @noinspection PhpMissingBreakStatementInspection */ + case 'comment': + // RFC 2047 section 5.2 + $pattern = '\(\)"'; + // intentional fall-through + // for this reason we build the $pattern without including delimiters and [] + case 'text': + default: + // RFC 2047 section 5.1 + // Replace every high ascii, control, =, ? and _ characters + $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; + break; + } + $matches = array(); + if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { + // If the string contains an '=', make sure it's the first thing we replace + // so as to avoid double-encoding + $eqkey = array_search('=', $matches[0]); + if (false !== $eqkey) { + unset($matches[0][$eqkey]); + array_unshift($matches[0], '='); + } + foreach (array_unique($matches[0]) as $char) { + $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); + } + } + // Replace every spaces to _ (more readable than =20) + return str_replace(' ', '_', $encoded); + } + + /** + * Add a string or binary attachment (non-filesystem). + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @param string $disposition Disposition to use + * @return void + */ + public function addStringAttachment( + $string, + $filename, + $encoding = 'base64', + $type = '', + $disposition = 'attachment' + ) { + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($filename); + } + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => $disposition, + 7 => 0 + ); + } + + /** + * Add an embedded (inline) attachment from a file. + * This can include images, sounds, and just about any other document type. + * These differ from 'regular' attachments in that they are intended to be + * displayed inline with the message, not just attached for download. + * This is used in HTML messages that embed the images + * the HTML refers to using the $cid value. + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment; Use this to reference + * the content when using an embedded image in HTML. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File MIME type. + * @param string $disposition Disposition to use + * @return boolean True on successfully adding an attachment + */ + public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline') + { + if (!@is_file($path)) { + $this->setError($this->lang('file_access') . $path); + return false; + } + + // If a MIME type is not specified, try to work it out from the file name + if ($type == '') { + $type = self::filenameToType($path); + } + + $filename = basename($path); + if ($name == '') { + $name = $filename; + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => $disposition, + 7 => $cid + ); + return true; + } + + /** + * Add an embedded stringified attachment. + * This can include images, sounds, and just about any other document type. + * Be sure to set the $type to an image type for images: + * JPEG images use 'image/jpeg', GIF uses 'image/gif', PNG uses 'image/png'. + * @param string $string The attachment binary data. + * @param string $cid Content ID of the attachment; Use this to reference + * the content when using an embedded image in HTML. + * @param string $name + * @param string $encoding File encoding (see $Encoding). + * @param string $type MIME type. + * @param string $disposition Disposition to use + * @return boolean True on successfully adding an attachment + */ + public function addStringEmbeddedImage( + $string, + $cid, + $name = '', + $encoding = 'base64', + $type = '', + $disposition = 'inline' + ) { + // If a MIME type is not specified, try to work it out from the name + if ($type == '' and !empty($name)) { + $type = self::filenameToType($name); + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $name, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => $disposition, + 7 => $cid + ); + return true; + } + + /** + * Check if an inline attachment is present. + * @access public + * @return boolean + */ + public function inlineImageExists() + { + foreach ($this->attachment as $attachment) { + if ($attachment[6] == 'inline') { + return true; + } + } + return false; + } + + /** + * Check if an attachment (non-inline) is present. + * @return boolean + */ + public function attachmentExists() + { + foreach ($this->attachment as $attachment) { + if ($attachment[6] == 'attachment') { + return true; + } + } + return false; + } + + /** + * Check if this message has an alternative body set. + * @return boolean + */ + public function alternativeExists() + { + return !empty($this->AltBody); + } + + /** + * Clear queued addresses of given kind. + * @access protected + * @param string $kind 'to', 'cc', or 'bcc' + * @return void + */ + public function clearQueuedAddresses($kind) + { + $RecipientsQueue = $this->RecipientsQueue; + foreach ($RecipientsQueue as $address => $params) { + if ($params[0] == $kind) { + unset($this->RecipientsQueue[$address]); + } + } + } + + /** + * Clear all To recipients. + * @return void + */ + public function clearAddresses() + { + foreach ($this->to as $to) { + unset($this->all_recipients[strtolower($to[0])]); + } + $this->to = array(); + $this->clearQueuedAddresses('to'); + } + + /** + * Clear all CC recipients. + * @return void + */ + public function clearCCs() + { + foreach ($this->cc as $cc) { + unset($this->all_recipients[strtolower($cc[0])]); + } + $this->cc = array(); + $this->clearQueuedAddresses('cc'); + } + + /** + * Clear all BCC recipients. + * @return void + */ + public function clearBCCs() + { + foreach ($this->bcc as $bcc) { + unset($this->all_recipients[strtolower($bcc[0])]); + } + $this->bcc = array(); + $this->clearQueuedAddresses('bcc'); + } + + /** + * Clear all ReplyTo recipients. + * @return void + */ + public function clearReplyTos() + { + $this->ReplyTo = array(); + $this->ReplyToQueue = array(); + } + + /** + * Clear all recipient types. + * @return void + */ + public function clearAllRecipients() + { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + $this->all_recipients = array(); + $this->RecipientsQueue = array(); + } + + /** + * Clear all filesystem, string, and binary attachments. + * @return void + */ + public function clearAttachments() + { + $this->attachment = array(); + } + + /** + * Clear all custom headers. + * @return void + */ + public function clearCustomHeaders() + { + $this->CustomHeader = array(); + } + + /** + * Add an error message to the error container. + * @access protected + * @param string $msg + * @return void + */ + protected function setError($msg) + { + $this->error_count++; + if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { + $lasterror = $this->smtp->getError(); + if (!empty($lasterror['error'])) { + $msg .= $this->lang('smtp_error') . $lasterror['error']; + if (!empty($lasterror['detail'])) { + $msg .= ' Detail: '. $lasterror['detail']; + } + if (!empty($lasterror['smtp_code'])) { + $msg .= ' SMTP code: ' . $lasterror['smtp_code']; + } + if (!empty($lasterror['smtp_code_ex'])) { + $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex']; + } + } + } + $this->ErrorInfo = $msg; + } + + /** + * Return an RFC 822 formatted date. + * @access public + * @return string + * @static + */ + public static function rfcDate() + { + // Set the time zone to whatever the default is to avoid 500 errors + // Will default to UTC if it's not set properly in php.ini + date_default_timezone_set(@date_default_timezone_get()); + return date('D, j M Y H:i:s O'); + } + + /** + * Get the server hostname. + * Returns 'localhost.localdomain' if unknown. + * @access protected + * @return string + */ + protected function serverHostname() + { + $result = 'localhost.localdomain'; + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } elseif (function_exists('gethostname') && gethostname() !== false) { + $result = gethostname(); + } elseif (php_uname('n') !== false) { + $result = php_uname('n'); + } + return $result; + } + + /** + * Get an error message in the current language. + * @access protected + * @param string $key + * @return string + */ + protected function lang($key) + { + if (count($this->language) < 1) { + $this->setLanguage('en'); // set the default language + } + + if (array_key_exists($key, $this->language)) { + if ($key == 'smtp_connect_failed') { + //Include a link to troubleshooting docs on SMTP connection failure + //this is by far the biggest cause of support questions + //but it's usually not PHPMailer's fault. + return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting'; + } + return $this->language[$key]; + } else { + //Return the key as a fallback + return $key; + } + } + + /** + * Check if an error occurred. + * @access public + * @return boolean True if an error did occur. + */ + public function isError() + { + return ($this->error_count > 0); + } + + /** + * Ensure consistent line endings in a string. + * Changes every end of line from CRLF, CR or LF to $this->LE. + * @access public + * @param string $str String to fixEOL + * @return string + */ + public function fixEOL($str) + { + // Normalise to \n + $nstr = str_replace(array("\r\n", "\r"), "\n", $str); + // Now convert LE as needed + if ($this->LE !== "\n") { + $nstr = str_replace("\n", $this->LE, $nstr); + } + return $nstr; + } + + /** + * Add a custom header. + * $name value can be overloaded to contain + * both header name and value (name:value) + * @access public + * @param string $name Custom header name + * @param string $value Header value + * @return void + */ + public function addCustomHeader($name, $value = null) + { + if ($value === null) { + // Value passed in as name:value + $this->CustomHeader[] = explode(':', $name, 2); + } else { + $this->CustomHeader[] = array($name, $value); + } + } + + /** + * Returns all custom headers. + * @return array + */ + public function getCustomHeaders() + { + return $this->CustomHeader; + } + + /** + * Create a message from an HTML string. + * Automatically makes modifications for inline images and backgrounds + * and creates a plain-text version by converting the HTML. + * Overwrites any existing values in $this->Body and $this->AltBody + * @access public + * @param string $message HTML message string + * @param string $basedir baseline directory for path + * @param boolean|callable $advanced Whether to use the internal HTML to text converter + * or your own custom converter @see PHPMailer::html2text() + * @return string $message + */ + public function msgHTML($message, $basedir = '', $advanced = false) + { + preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images); + if (array_key_exists(2, $images)) { + foreach ($images[2] as $imgindex => $url) { + // Convert data URIs into embedded images + if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) { + $data = substr($url, strpos($url, ',')); + if ($match[2]) { + $data = base64_decode($data); + } else { + $data = rawurldecode($data); + } + $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 + if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) { + $message = str_replace( + $images[0][$imgindex], + $images[1][$imgindex] . '="cid:' . $cid . '"', + $message + ); + } + } elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[A-z]+://#', $url)) { + // Do not change urls for absolute images (thanks to corvuscorax) + // Do not change urls that are already inline images + $filename = basename($url); + $directory = dirname($url); + if ($directory == '.') { + $directory = ''; + } + $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2 + if (strlen($basedir) > 1 && substr($basedir, -1) != '/') { + $basedir .= '/'; + } + if (strlen($directory) > 1 && substr($directory, -1) != '/') { + $directory .= '/'; + } + if ($this->addEmbeddedImage( + $basedir . $directory . $filename, + $cid, + $filename, + 'base64', + self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION)) + ) + ) { + $message = preg_replace( + '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui', + $images[1][$imgindex] . '="cid:' . $cid . '"', + $message + ); + } + } + } + } + $this->isHTML(true); + // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better + $this->Body = $this->normalizeBreaks($message); + $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced)); + if (empty($this->AltBody)) { + $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . + self::CRLF . self::CRLF; + } + return $this->Body; + } + + /** + * Convert an HTML string into plain text. + * This is used by msgHTML(). + * Note - older versions of this function used a bundled advanced converter + * which was been removed for license reasons in #232 + * Example usage: + * + * // Use default conversion + * $plain = $mail->html2text($html); + * // Use your own custom converter + * $plain = $mail->html2text($html, function($html) { + * $converter = new MyHtml2text($html); + * return $converter->get_text(); + * }); + * + * @param string $html The HTML text to convert + * @param boolean|callable $advanced Any boolean value to use the internal converter, + * or provide your own callable for custom conversion. + * @return string + */ + public function html2text($html, $advanced = false) + { + if (is_callable($advanced)) { + return call_user_func($advanced, $html); + } + return html_entity_decode( + trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), + ENT_QUOTES, + $this->CharSet + ); + } + + /** + * Get the MIME type for a file extension. + * @param string $ext File extension + * @access public + * @return string MIME type of file. + * @static + */ + public static function _mime_types($ext = '') + { + $mimes = array( + 'xl' => 'application/excel', + 'js' => 'application/javascript', + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'bin' => 'application/macbinary', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'class' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mpga' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'eml' => 'message/rfc822', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'log' => 'text/plain', + 'text' => 'text/plain', + 'txt' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'vcf' => 'text/vcard', + 'vcard' => 'text/vcard', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mov' => 'video/quicktime', + 'qt' => 'video/quicktime', + 'rv' => 'video/vnd.rn-realvideo', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie' + ); + if (array_key_exists(strtolower($ext), $mimes)) { + return $mimes[strtolower($ext)]; + } + return 'application/octet-stream'; + } + + /** + * Map a file name to a MIME type. + * Defaults to 'application/octet-stream', i.e.. arbitrary binary data. + * @param string $filename A file name or full path, does not need to exist as a file + * @return string + * @static + */ + public static function filenameToType($filename) + { + // In case the path is a URL, strip any query string before getting extension + $qpos = strpos($filename, '?'); + if (false !== $qpos) { + $filename = substr($filename, 0, $qpos); + } + $pathinfo = self::mb_pathinfo($filename); + return self::_mime_types($pathinfo['extension']); + } + + /** + * Multi-byte-safe pathinfo replacement. + * Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe. + * Works similarly to the one in PHP >= 5.2.0 + * @link http://www.php.net/manual/en/function.pathinfo.php#107461 + * @param string $path A filename or path, does not need to exist as a file + * @param integer|string $options Either a PATHINFO_* constant, + * or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2 + * @return string|array + * @static + */ + public static function mb_pathinfo($path, $options = null) + { + $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => ''); + $pathinfo = array(); + if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) { + if (array_key_exists(1, $pathinfo)) { + $ret['dirname'] = $pathinfo[1]; + } + if (array_key_exists(2, $pathinfo)) { + $ret['basename'] = $pathinfo[2]; + } + if (array_key_exists(5, $pathinfo)) { + $ret['extension'] = $pathinfo[5]; + } + if (array_key_exists(3, $pathinfo)) { + $ret['filename'] = $pathinfo[3]; + } + } + switch ($options) { + case PATHINFO_DIRNAME: + case 'dirname': + return $ret['dirname']; + case PATHINFO_BASENAME: + case 'basename': + return $ret['basename']; + case PATHINFO_EXTENSION: + case 'extension': + return $ret['extension']; + case PATHINFO_FILENAME: + case 'filename': + return $ret['filename']; + default: + return $ret; + } + } + + /** + * Set or reset instance properties. + * You should avoid this function - it's more verbose, less efficient, more error-prone and + * harder to debug than setting properties directly. + * Usage Example: + * `$mail->set('SMTPSecure', 'tls');` + * is the same as: + * `$mail->SMTPSecure = 'tls';` + * @access public + * @param string $name The property name to set + * @param mixed $value The value to set the property to + * @return boolean + * @TODO Should this not be using the __set() magic function? + */ + public function set($name, $value = '') + { + if (property_exists($this, $name)) { + $this->$name = $value; + return true; + } else { + $this->setError($this->lang('variable_set') . $name); + return false; + } + } + + /** + * Strip newlines to prevent header injection. + * @access public + * @param string $str + * @return string + */ + public function secureHeader($str) + { + return trim(str_replace(array("\r", "\n"), '', $str)); + } + + /** + * Normalize line breaks in a string. + * Converts UNIX LF, Mac CR and Windows CRLF line breaks into a single line break format. + * Defaults to CRLF (for message bodies) and preserves consecutive breaks. + * @param string $text + * @param string $breaktype What kind of line break to use, defaults to CRLF + * @return string + * @access public + * @static + */ + public static function normalizeBreaks($text, $breaktype = "\r\n") + { + return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text); + } + + /** + * Set the public and private key files and password for S/MIME signing. + * @access public + * @param string $cert_filename + * @param string $key_filename + * @param string $key_pass Password for private key + * @param string $extracerts_filename Optional path to chain certificate + */ + public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '') + { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + $this->sign_extracerts_file = $extracerts_filename; + } + + /** + * Quoted-Printable-encode a DKIM header. + * @access public + * @param string $txt + * @return string + */ + public function DKIM_QP($txt) + { + $line = ''; + for ($i = 0; $i < strlen($txt); $i++) { + $ord = ord($txt[$i]); + if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) { + $line .= $txt[$i]; + } else { + $line .= '=' . sprintf('%02X', $ord); + } + } + return $line; + } + + /** + * Generate a DKIM signature. + * @access public + * @param string $signHeader + * @throws phpmailerException + * @return string + */ + public function DKIM_Sign($signHeader) + { + if (!defined('PKCS7_TEXT')) { + if ($this->exceptions) { + throw new phpmailerException($this->lang('extension_missing') . 'openssl'); + } + return ''; + } + $privKeyStr = file_get_contents($this->DKIM_private); + if ($this->DKIM_passphrase != '') { + $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase); + } else { + $privKey = $privKeyStr; + } + if (openssl_sign($signHeader, $signature, $privKey)) { + return base64_encode($signature); + } + return ''; + } + + /** + * Generate a DKIM canonicalization header. + * @access public + * @param string $signHeader Header + * @return string + */ + public function DKIM_HeaderC($signHeader) + { + $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader); + $lines = explode("\r\n", $signHeader); + foreach ($lines as $key => $line) { + list($heading, $value) = explode(':', $line, 2); + $heading = strtolower($heading); + $value = preg_replace('/\s+/', ' ', $value); // Compress useless spaces + $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value + } + $signHeader = implode("\r\n", $lines); + return $signHeader; + } + + /** + * Generate a DKIM canonicalization body. + * @access public + * @param string $body Message Body + * @return string + */ + public function DKIM_BodyC($body) + { + if ($body == '') { + return "\r\n"; + } + // stabilize line endings + $body = str_replace("\r\n", "\n", $body); + $body = str_replace("\n", "\r\n", $body); + // END stabilize line endings + while (substr($body, strlen($body) - 4, 4) == "\r\n\r\n") { + $body = substr($body, 0, strlen($body) - 2); + } + return $body; + } + + /** + * Create the DKIM header and body in a new message header. + * @access public + * @param string $headers_line Header lines + * @param string $subject Subject + * @param string $body Body + * @return string + */ + public function DKIM_Add($headers_line, $subject, $body) + { + $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms + $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body + $DKIMquery = 'dns/txt'; // Query method + $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) + $subject_header = "Subject: $subject"; + $headers = explode($this->LE, $headers_line); + $from_header = ''; + $to_header = ''; + $current = ''; + foreach ($headers as $header) { + if (strpos($header, 'From:') === 0) { + $from_header = $header; + $current = 'from_header'; + } elseif (strpos($header, 'To:') === 0) { + $to_header = $header; + $current = 'to_header'; + } else { + if (!empty($$current) && strpos($header, ' =?') === 0) { + $$current .= $header; + } else { + $current = ''; + } + } + } + $from = str_replace('|', '=7C', $this->DKIM_QP($from_header)); + $to = str_replace('|', '=7C', $this->DKIM_QP($to_header)); + $subject = str_replace( + '|', + '=7C', + $this->DKIM_QP($subject_header) + ); // Copied header fields (dkim-quoted-printable) + $body = $this->DKIM_BodyC($body); + $DKIMlen = strlen($body); // Length of body + $DKIMb64 = base64_encode(pack('H*', sha1($body))); // Base64 of packed binary SHA-1 hash of body + if ('' == $this->DKIM_identity) { + $ident = ''; + } else { + $ident = ' i=' . $this->DKIM_identity . ';'; + } + $dkimhdrs = 'DKIM-Signature: v=1; a=' . + $DKIMsignatureType . '; q=' . + $DKIMquery . '; l=' . + $DKIMlen . '; s=' . + $this->DKIM_selector . + ";\r\n" . + "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" . + "\th=From:To:Subject;\r\n" . + "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" . + "\tz=$from\r\n" . + "\t|$to\r\n" . + "\t|$subject;\r\n" . + "\tbh=" . $DKIMb64 . ";\r\n" . + "\tb="; + $toSign = $this->DKIM_HeaderC( + $from_header . "\r\n" . + $to_header . "\r\n" . + $subject_header . "\r\n" . + $dkimhdrs + ); + $signed = $this->DKIM_Sign($toSign); + return $dkimhdrs . $signed . "\r\n"; + } + + /** + * Detect if a string contains a line longer than the maximum line length allowed. + * @param string $str + * @return boolean + * @static + */ + public static function hasLineLongerThanMax($str) + { + //+2 to include CRLF line break for a 1000 total + return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str); + } + + /** + * Allows for public read access to 'to' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getToAddresses() + { + return $this->to; + } + + /** + * Allows for public read access to 'cc' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getCcAddresses() + { + return $this->cc; + } + + /** + * Allows for public read access to 'bcc' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getBccAddresses() + { + return $this->bcc; + } + + /** + * Allows for public read access to 'ReplyTo' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getReplyToAddresses() + { + return $this->ReplyTo; + } + + /** + * Allows for public read access to 'all_recipients' property. + * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included. + * @access public + * @return array + */ + public function getAllRecipientAddresses() + { + return $this->all_recipients; + } + + /** + * Perform a callback. + * @param boolean $isSent + * @param array $to + * @param array $cc + * @param array $bcc + * @param string $subject + * @param string $body + * @param string $from + */ + protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from) + { + if (!empty($this->action_function) && is_callable($this->action_function)) { + $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from); + call_user_func_array($this->action_function, $params); + } + } +} + +/** + * PHPMailer exception handler + * @package PHPMailer + */ +class phpmailerException extends Exception +{ + /** + * Prettify error message output + * @return string + */ + public function errorMessage() + { + $errorMsg = '' . $this->getMessage() . "
\n"; + return $errorMsg; + } +} diff --git a/plugin/PHPMailer/class.phpmaileroauth.php b/plugin/PHPMailer/class.phpmaileroauth.php new file mode 100644 index 000000000..f9cd7b42a --- /dev/null +++ b/plugin/PHPMailer/class.phpmaileroauth.php @@ -0,0 +1,196 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailerOAuth - PHPMailer subclass adding OAuth support. + * @package PHPMailer + * @author @sherryl4george + * @author Marcus Bointon (@Synchro) + */ +class PHPMailerOAuth extends PHPMailer +{ + /** + * The OAuth user's email address + * @var string + */ + public $oauthUserEmail = ''; + + /** + * The OAuth refresh token + * @var string + */ + public $oauthRefreshToken = ''; + + /** + * The OAuth client ID + * @var string + */ + public $oauthClientId = ''; + + /** + * The OAuth client secret + * @var string + */ + public $oauthClientSecret = ''; + + /** + * An instance of the PHPMailerOAuthGoogle class. + * @var PHPMailerOAuthGoogle + * @access protected + */ + protected $oauth = null; + + /** + * Get a PHPMailerOAuthGoogle instance to use. + * @return PHPMailerOAuthGoogle + */ + public function getOAUTHInstance() + { + if (!is_object($this->oauth)) { + $this->oauth = new PHPMailerOAuthGoogle( + $this->oauthUserEmail, + $this->oauthClientSecret, + $this->oauthClientId, + $this->oauthRefreshToken + ); + } + return $this->oauth; + } + + /** + * Initiate a connection to an SMTP server. + * Overrides the original smtpConnect method to add support for OAuth. + * @param array $options An array of options compatible with stream_context_create() + * @uses SMTP + * @access public + * @return bool + */ + public function smtpConnect($options = array()) + { + if (is_null($this->smtp)) { + $this->smtp = $this->getSMTPInstance(); + } + + if (is_null($this->oauth)) { + $this->oauth = $this->getOAUTHInstance(); + } + + // Already connected? + if ($this->smtp->connected()) { + return true; + } + + $this->smtp->setTimeout($this->Timeout); + $this->smtp->setDebugLevel($this->SMTPDebug); + $this->smtp->setDebugOutput($this->Debugoutput); + $this->smtp->setVerp($this->do_verp); + $hosts = explode(';', $this->Host); + $lastexception = null; + + foreach ($hosts as $hostentry) { + $hostinfo = array(); + if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) { + // Not a valid host entry + continue; + } + // $hostinfo[2]: optional ssl or tls prefix + // $hostinfo[3]: the hostname + // $hostinfo[4]: optional port number + // The host string prefix can temporarily override the current setting for SMTPSecure + // If it's not specified, the default value is used + $prefix = ''; + $secure = $this->SMTPSecure; + $tls = ($this->SMTPSecure == 'tls'); + if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) { + $prefix = 'ssl://'; + $tls = false; // Can't have SSL and TLS at the same time + $secure = 'ssl'; + } elseif ($hostinfo[2] == 'tls') { + $tls = true; + // tls doesn't use a prefix + $secure = 'tls'; + } + //Do we need the OpenSSL extension? + $sslext = defined('OPENSSL_ALGO_SHA1'); + if ('tls' === $secure or 'ssl' === $secure) { + //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled + if (!$sslext) { + throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL); + } + } + $host = $hostinfo[3]; + $port = $this->Port; + $tport = (integer)$hostinfo[4]; + if ($tport > 0 and $tport < 65536) { + $port = $tport; + } + if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { + try { + if ($this->Helo) { + $hello = $this->Helo; + } else { + $hello = $this->serverHostname(); + } + $this->smtp->hello($hello); + //Automatically enable TLS encryption if: + // * it's not disabled + // * we have openssl extension + // * we are not already using SSL + // * the server offers STARTTLS + if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) { + $tls = true; + } + if ($tls) { + if (!$this->smtp->startTLS()) { + throw new phpmailerException($this->lang('connect_host')); + } + // We must resend HELO after tls negotiation + $this->smtp->hello($hello); + } + if ($this->SMTPAuth) { + if (!$this->smtp->authenticate( + $this->Username, + $this->Password, + $this->AuthType, + $this->Realm, + $this->Workstation, + $this->oauth + ) + ) { + throw new phpmailerException($this->lang('authenticate')); + } + } + return true; + } catch (phpmailerException $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + // We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } + } + } + // If we get here, all connection attempts have failed, so close connection hard + $this->smtp->close(); + // As we've caught all exceptions, just report whatever the last one was + if ($this->exceptions and !is_null($lastexception)) { + throw $lastexception; + } + return false; + } +} diff --git a/plugin/PHPMailer/class.phpmaileroauthgoogle.php b/plugin/PHPMailer/class.phpmaileroauthgoogle.php new file mode 100644 index 000000000..ab6292b82 --- /dev/null +++ b/plugin/PHPMailer/class.phpmaileroauthgoogle.php @@ -0,0 +1,76 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailerOAuthGoogle - Wrapper for League OAuth2 Google provider. + * @package PHPMailer + * @author @sherryl4george + * @author Marcus Bointon (@Synchro) + * @link https://github.com/thephpleague/oauth2-client + */ +class PHPMailerOAuthGoogle +{ + private $oauthUserEmail = ''; + private $oauthRefreshToken = ''; + private $oauthClientId = ''; + private $oauthClientSecret = ''; + + /** + * @param string $UserEmail + * @param string $ClientSecret + * @param string $ClientId + * @param string $RefreshToken + */ + public function __construct( + $UserEmail, + $ClientSecret, + $ClientId, + $RefreshToken + ) { + $this->oauthClientId = $ClientId; + $this->oauthClientSecret = $ClientSecret; + $this->oauthRefreshToken = $RefreshToken; + $this->oauthUserEmail = $UserEmail; + } + + private function getProvider() { + return new League\OAuth2\Client\Provider\Google([ + 'clientId' => $this->oauthClientId, + 'clientSecret' => $this->oauthClientSecret + ]); + } + + private function getGrant() + { + return new \League\OAuth2\Client\Grant\RefreshToken(); + } + + private function getToken() + { + $provider = $this->getProvider(); + $grant = $this->getGrant(); + return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]); + } + + public function getOauth64() + { + $token = $this->getToken(); + return base64_encode("user=" . $this->oauthUserEmail . "\001auth=Bearer " . $token . "\001\001"); + } +} diff --git a/plugin/PHPMailer/class.pop3.php b/plugin/PHPMailer/class.pop3.php new file mode 100644 index 000000000..403b573eb --- /dev/null +++ b/plugin/PHPMailer/class.pop3.php @@ -0,0 +1,407 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2012 - 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer POP-Before-SMTP Authentication Class. + * Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication. + * Does not support APOP. + * @package PHPMailer + * @author Richard Davey (original author) + * @author Marcus Bointon (Synchro/coolbru) + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + */ +class POP3 +{ + /** + * The POP3 PHPMailer Version number. + * @var string + * @access public + */ + public $Version = '5.2.14'; + + /** + * Default POP3 port number. + * @var integer + * @access public + */ + public $POP3_PORT = 110; + + /** + * Default timeout in seconds. + * @var integer + * @access public + */ + public $POP3_TIMEOUT = 30; + + /** + * POP3 Carriage Return + Line Feed. + * @var string + * @access public + * @deprecated Use the constant instead + */ + public $CRLF = "\r\n"; + + /** + * Debug display level. + * Options: 0 = no, 1+ = yes + * @var integer + * @access public + */ + public $do_debug = 0; + + /** + * POP3 mail server hostname. + * @var string + * @access public + */ + public $host; + + /** + * POP3 port number. + * @var integer + * @access public + */ + public $port; + + /** + * POP3 Timeout Value in seconds. + * @var integer + * @access public + */ + public $tval; + + /** + * POP3 username + * @var string + * @access public + */ + public $username; + + /** + * POP3 password. + * @var string + * @access public + */ + public $password; + + /** + * Resource handle for the POP3 connection socket. + * @var resource + * @access protected + */ + protected $pop_conn; + + /** + * Are we connected? + * @var boolean + * @access protected + */ + protected $connected = false; + + /** + * Error container. + * @var array + * @access protected + */ + protected $errors = array(); + + /** + * Line break constant + */ + const CRLF = "\r\n"; + + /** + * Simple static wrapper for all-in-one POP before SMTP + * @param $host + * @param integer|boolean $port The port number to connect to + * @param integer|boolean $timeout The timeout value + * @param string $username + * @param string $password + * @param integer $debug_level + * @return boolean + */ + public static function popBeforeSmtp( + $host, + $port = false, + $timeout = false, + $username = '', + $password = '', + $debug_level = 0 + ) { + $pop = new POP3; + return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level); + } + + /** + * Authenticate with a POP3 server. + * A connect, login, disconnect sequence + * appropriate for POP-before SMTP authorisation. + * @access public + * @param string $host The hostname to connect to + * @param integer|boolean $port The port number to connect to + * @param integer|boolean $timeout The timeout value + * @param string $username + * @param string $password + * @param integer $debug_level + * @return boolean + */ + public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0) + { + $this->host = $host; + // If no port value provided, use default + if (false === $port) { + $this->port = $this->POP3_PORT; + } else { + $this->port = (integer)$port; + } + // If no timeout value provided, use default + if (false === $timeout) { + $this->tval = $this->POP3_TIMEOUT; + } else { + $this->tval = (integer)$timeout; + } + $this->do_debug = $debug_level; + $this->username = $username; + $this->password = $password; + // Reset the error log + $this->errors = array(); + // connect + $result = $this->connect($this->host, $this->port, $this->tval); + if ($result) { + $login_result = $this->login($this->username, $this->password); + if ($login_result) { + $this->disconnect(); + return true; + } + } + // We need to disconnect regardless of whether the login succeeded + $this->disconnect(); + return false; + } + + /** + * Connect to a POP3 server. + * @access public + * @param string $host + * @param integer|boolean $port + * @param integer $tval + * @return boolean + */ + public function connect($host, $port = false, $tval = 30) + { + // Are we already connected? + if ($this->connected) { + return true; + } + + //On Windows this will raise a PHP Warning error if the hostname doesn't exist. + //Rather than suppress it with @fsockopen, capture it cleanly instead + set_error_handler(array($this, 'catchWarning')); + + if (false === $port) { + $port = $this->POP3_PORT; + } + + // connect to the POP3 server + $this->pop_conn = fsockopen( + $host, // POP3 Host + $port, // Port # + $errno, // Error Number + $errstr, // Error Message + $tval + ); // Timeout (seconds) + // Restore the error handler + restore_error_handler(); + + // Did we connect? + if (false === $this->pop_conn) { + // It would appear not... + $this->setError(array( + 'error' => "Failed to connect to server $host on port $port", + 'errno' => $errno, + 'errstr' => $errstr + )); + return false; + } + + // Increase the stream time-out + stream_set_timeout($this->pop_conn, $tval, 0); + + // Get the POP3 server response + $pop3_response = $this->getResponse(); + // Check for the +OK + if ($this->checkResponse($pop3_response)) { + // The connection is established and the POP3 server is talking + $this->connected = true; + return true; + } + return false; + } + + /** + * Log in to the POP3 server. + * Does not support APOP (RFC 2828, 4949). + * @access public + * @param string $username + * @param string $password + * @return boolean + */ + public function login($username = '', $password = '') + { + if (!$this->connected) { + $this->setError('Not connected to POP3 server'); + } + if (empty($username)) { + $username = $this->username; + } + if (empty($password)) { + $password = $this->password; + } + + // Send the Username + $this->sendString("USER $username" . self::CRLF); + $pop3_response = $this->getResponse(); + if ($this->checkResponse($pop3_response)) { + // Send the Password + $this->sendString("PASS $password" . self::CRLF); + $pop3_response = $this->getResponse(); + if ($this->checkResponse($pop3_response)) { + return true; + } + } + return false; + } + + /** + * Disconnect from the POP3 server. + * @access public + */ + public function disconnect() + { + $this->sendString('QUIT'); + //The QUIT command may cause the daemon to exit, which will kill our connection + //So ignore errors here + try { + @fclose($this->pop_conn); + } catch (Exception $e) { + //Do nothing + }; + } + + /** + * Get a response from the POP3 server. + * $size is the maximum number of bytes to retrieve + * @param integer $size + * @return string + * @access protected + */ + protected function getResponse($size = 128) + { + $response = fgets($this->pop_conn, $size); + if ($this->do_debug >= 1) { + echo "Server -> Client: $response"; + } + return $response; + } + + /** + * Send raw data to the POP3 server. + * @param string $string + * @return integer + * @access protected + */ + protected function sendString($string) + { + if ($this->pop_conn) { + if ($this->do_debug >= 2) { //Show client messages when debug >= 2 + echo "Client -> Server: $string"; + } + return fwrite($this->pop_conn, $string, strlen($string)); + } + return 0; + } + + /** + * Checks the POP3 server response. + * Looks for for +OK or -ERR. + * @param string $string + * @return boolean + * @access protected + */ + protected function checkResponse($string) + { + if (substr($string, 0, 3) !== '+OK') { + $this->setError(array( + 'error' => "Server reported an error: $string", + 'errno' => 0, + 'errstr' => '' + )); + return false; + } else { + return true; + } + } + + /** + * Add an error to the internal error store. + * Also display debug output if it's enabled. + * @param $error + * @access protected + */ + protected function setError($error) + { + $this->errors[] = $error; + if ($this->do_debug >= 1) { + echo '
';
+            foreach ($this->errors as $error) {
+                print_r($error);
+            }
+            echo '
'; + } + } + + /** + * Get an array of error messages, if any. + * @return array + */ + public function getErrors() + { + return $this->errors; + } + + /** + * POP3 connection error handler. + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + * @access protected + */ + protected function catchWarning($errno, $errstr, $errfile, $errline) + { + $this->setError(array( + 'error' => "Connecting to the POP3 server raised a PHP warning: ", + 'errno' => $errno, + 'errstr' => $errstr, + 'errfile' => $errfile, + 'errline' => $errline + )); + } +} diff --git a/plugin/PHPMailer/class.smtp.php b/plugin/PHPMailer/class.smtp.php new file mode 100644 index 000000000..2e32e2fce --- /dev/null +++ b/plugin/PHPMailer/class.smtp.php @@ -0,0 +1,1181 @@ + + * @author Jim Jagielski (jimjag) + * @author Andy Prevost (codeworxtech) + * @author Brent R. Matzelle (original founder) + * @copyright 2014 Marcus Bointon + * @copyright 2010 - 2012 Jim Jagielski + * @copyright 2004 - 2009 Andy Prevost + * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License + * @note This program is distributed in the hope that it will be useful - WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ + +/** + * PHPMailer RFC821 SMTP email transport class. + * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server. + * @package PHPMailer + * @author Chris Ryan + * @author Marcus Bointon + */ +class SMTP +{ + /** + * The PHPMailer SMTP version number. + * @var string + */ + const VERSION = '5.2.14'; + + /** + * SMTP line break constant. + * @var string + */ + const CRLF = "\r\n"; + + /** + * The SMTP port to use if one is not specified. + * @var integer + */ + const DEFAULT_SMTP_PORT = 25; + + /** + * The maximum line length allowed by RFC 2822 section 2.1.1 + * @var integer + */ + const MAX_LINE_LENGTH = 998; + + /** + * Debug level for no output + */ + const DEBUG_OFF = 0; + + /** + * Debug level to show client -> server messages + */ + const DEBUG_CLIENT = 1; + + /** + * Debug level to show client -> server and server -> client messages + */ + const DEBUG_SERVER = 2; + + /** + * Debug level to show connection status, client -> server and server -> client messages + */ + const DEBUG_CONNECTION = 3; + + /** + * Debug level to show all messages + */ + const DEBUG_LOWLEVEL = 4; + + /** + * The PHPMailer SMTP Version number. + * @var string + * @deprecated Use the `VERSION` constant instead + * @see SMTP::VERSION + */ + public $Version = '5.2.14'; + + /** + * SMTP server port number. + * @var integer + * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead + * @see SMTP::DEFAULT_SMTP_PORT + */ + public $SMTP_PORT = 25; + + /** + * SMTP reply line ending. + * @var string + * @deprecated Use the `CRLF` constant instead + * @see SMTP::CRLF + */ + public $CRLF = "\r\n"; + + /** + * Debug output level. + * Options: + * * self::DEBUG_OFF (`0`) No debug output, default + * * self::DEBUG_CLIENT (`1`) Client commands + * * self::DEBUG_SERVER (`2`) Client commands and server responses + * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status + * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages + * @var integer + */ + public $do_debug = self::DEBUG_OFF; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `
`, appropriate for browser output + * * `error_log` Output to error log as configured in php.ini + * + * Alternatively, you can provide a callable expecting two params: a message string and the debug level: + * + * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";}; + * + * @var string|callable + */ + public $Debugoutput = 'echo'; + + /** + * Whether to use VERP. + * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path + * @link http://www.postfix.org/VERP_README.html Info on VERP + * @var boolean + */ + public $do_verp = false; + + /** + * The timeout value for connection, in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure. + * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2 + * @var integer + */ + public $Timeout = 300; + + /** + * How long to wait for commands to complete, in seconds. + * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 + * @var integer + */ + public $Timelimit = 300; + + /** + * The socket for the server connection. + * @var resource + */ + protected $smtp_conn; + + /** + * Error information, if any, for the last SMTP command. + * @var array + */ + protected $error = array( + 'error' => '', + 'detail' => '', + 'smtp_code' => '', + 'smtp_code_ex' => '' + ); + + /** + * The reply the server sent to us for HELO. + * If null, no HELO string has yet been received. + * @var string|null + */ + protected $helo_rply = null; + + /** + * The set of SMTP extensions sent in reply to EHLO command. + * Indexes of the array are extension names. + * Value at index 'HELO' or 'EHLO' (according to command that was sent) + * represents the server name. In case of HELO it is the only element of the array. + * Other values can be boolean TRUE or an array containing extension options. + * If null, no HELO/EHLO string has yet been received. + * @var array|null + */ + protected $server_caps = null; + + /** + * The most recent reply received from the server. + * @var string + */ + protected $last_reply = ''; + + /** + * Output debugging info via a user-selected method. + * @see SMTP::$Debugoutput + * @see SMTP::$do_debug + * @param string $str Debug string to output + * @param integer $level The debug level of this message; see DEBUG_* constants + * @return void + */ + protected function edebug($str, $level = 0) + { + if ($level > $this->do_debug) { + return; + } + //Avoid clash with built-in function names + if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) { + call_user_func($this->Debugoutput, $str, $this->do_debug); + return; + } + switch ($this->Debugoutput) { + case 'error_log': + //Don't output, just log + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), + ENT_QUOTES, + 'UTF-8' + ) + . "
\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); + echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( + "\n", + "\n \t ", + trim($str) + )."\n"; + } + } + + /** + * Connect to an SMTP server. + * @param string $host SMTP server IP or host name + * @param integer $port The port number to connect to + * @param integer $timeout How long to wait for the connection to open + * @param array $options An array of options for stream_context_create() + * @access public + * @return boolean + */ + public function connect($host, $port = null, $timeout = 30, $options = array()) + { + static $streamok; + //This is enabled by default since 5.0.0 but some providers disable it + //Check this once and cache the result + if (is_null($streamok)) { + $streamok = function_exists('stream_socket_client'); + } + // Clear errors to avoid confusion + $this->setError(''); + // Make sure we are __not__ connected + if ($this->connected()) { + // Already connected, generate error + $this->setError('Already connected to a server'); + return false; + } + if (empty($port)) { + $port = self::DEFAULT_SMTP_PORT; + } + // Connect to the SMTP server + $this->edebug( + "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true), + self::DEBUG_CONNECTION + ); + $errno = 0; + $errstr = ''; + if ($streamok) { + $socket_context = stream_context_create($options); + //Suppress errors; connection failures are handled at a higher level + $this->smtp_conn = @stream_socket_client( + $host . ":" . $port, + $errno, + $errstr, + $timeout, + STREAM_CLIENT_CONNECT, + $socket_context + ); + } else { + //Fall back to fsockopen which should work in more places, but is missing some features + $this->edebug( + "Connection: stream_socket_client not available, falling back to fsockopen", + self::DEBUG_CONNECTION + ); + $this->smtp_conn = fsockopen( + $host, + $port, + $errno, + $errstr, + $timeout + ); + } + // Verify we connected properly + if (!is_resource($this->smtp_conn)) { + $this->setError( + 'Failed to connect to server', + $errno, + $errstr + ); + $this->edebug( + 'SMTP ERROR: ' . $this->error['error'] + . ": $errstr ($errno)", + self::DEBUG_CLIENT + ); + return false; + } + $this->edebug('Connection: opened', self::DEBUG_CONNECTION); + // SMTP server can take longer to respond, give longer timeout for first read + // Windows does not have support for this timeout function + if (substr(PHP_OS, 0, 3) != 'WIN') { + $max = ini_get('max_execution_time'); + // Don't bother if unlimited + if ($max != 0 && $timeout > $max) { + @set_time_limit($timeout); + } + stream_set_timeout($this->smtp_conn, $timeout, 0); + } + // Get any announcement + $announce = $this->get_lines(); + $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER); + return true; + } + + /** + * Initiate a TLS (encrypted) session. + * @access public + * @return boolean + */ + public function startTLS() + { + if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) { + return false; + } + // Begin encrypted connection + if (!stream_socket_enable_crypto( + $this->smtp_conn, + true, + STREAM_CRYPTO_METHOD_TLS_CLIENT + )) { + return false; + } + return true; + } + + /** + * Perform SMTP authentication. + * Must be run after hello(). + * @see hello() + * @param string $username The user name + * @param string $password The password + * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2) + * @param string $realm The auth realm for NTLM + * @param string $workstation The auth workstation for NTLM + * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth) + * @return bool True if successfully authenticated.* @access public + */ + public function authenticate( + $username, + $password, + $authtype = null, + $realm = '', + $workstation = '', + $OAuth = null + ) { + if (!$this->server_caps) { + $this->setError('Authentication is not allowed before HELO/EHLO'); + return false; + } + + if (array_key_exists('EHLO', $this->server_caps)) { + // SMTP extensions are available. Let's try to find a proper authentication method + + if (!array_key_exists('AUTH', $this->server_caps)) { + $this->setError('Authentication is not allowed at this stage'); + // 'at this stage' means that auth may be allowed after the stage changes + // e.g. after STARTTLS + return false; + } + + self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL); + self::edebug( + 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']), + self::DEBUG_LOWLEVEL + ); + + if (empty($authtype)) { + foreach (array('LOGIN', 'CRAM-MD5', 'NTLM', 'PLAIN', 'XOAUTH2') as $method) { + if (in_array($method, $this->server_caps['AUTH'])) { + $authtype = $method; + break; + } + } + if (empty($authtype)) { + $this->setError('No supported authentication methods found'); + return false; + } + self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL); + } + + if (!in_array($authtype, $this->server_caps['AUTH'])) { + $this->setError("The requested authentication method \"$authtype\" is not supported by the server"); + return false; + } + } elseif (empty($authtype)) { + $authtype = 'LOGIN'; + } + switch ($authtype) { + case 'PLAIN': + // Start authentication + if (!$this->sendCommand('AUTH', 'AUTH PLAIN', 334)) { + return false; + } + // Send encoded username and password + if (!$this->sendCommand( + 'User & Password', + base64_encode("\0" . $username . "\0" . $password), + 235 + ) + ) { + return false; + } + break; + case 'LOGIN': + // Start authentication + if (!$this->sendCommand('AUTH', 'AUTH LOGIN', 334)) { + return false; + } + if (!$this->sendCommand("Username", base64_encode($username), 334)) { + return false; + } + if (!$this->sendCommand("Password", base64_encode($password), 235)) { + return false; + } + break; + case 'XOAUTH2': + //If the OAuth Instance is not set. Can be a case when PHPMailer is used + //instead of PHPMailerOAuth + if (is_null($OAuth)) { + return false; + } + $oauth = $OAuth->getOauth64(); + + // Start authentication + if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) { + return false; + } + break; + case 'NTLM': + /* + * ntlm_sasl_client.php + * Bundled with Permission + * + * How to telnet in windows: + * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx + * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication + */ + require_once 'extras/ntlm_sasl_client.php'; + $temp = new stdClass; + $ntlm_client = new ntlm_sasl_client_class; + //Check that functions are available + if (!$ntlm_client->Initialize($temp)) { + $this->setError($temp->error); + $this->edebug( + 'You need to enable some modules in your php.ini file: ' + . $this->error['error'], + self::DEBUG_CLIENT + ); + return false; + } + //msg1 + $msg1 = $ntlm_client->TypeMsg1($realm, $workstation); //msg1 + + if (!$this->sendCommand( + 'AUTH NTLM', + 'AUTH NTLM ' . base64_encode($msg1), + 334 + ) + ) { + return false; + } + //Though 0 based, there is a white space after the 3 digit number + //msg2 + $challenge = substr($this->last_reply, 3); + $challenge = base64_decode($challenge); + $ntlm_res = $ntlm_client->NTLMResponse( + substr($challenge, 24, 8), + $password + ); + //msg3 + $msg3 = $ntlm_client->TypeMsg3( + $ntlm_res, + $username, + $realm, + $workstation + ); + // send encoded username + return $this->sendCommand('Username', base64_encode($msg3), 235); + case 'CRAM-MD5': + // Start authentication + if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) { + return false; + } + // Get the challenge + $challenge = base64_decode(substr($this->last_reply, 4)); + + // Build the response + $response = $username . ' ' . $this->hmac($challenge, $password); + + // send encoded credentials + return $this->sendCommand('Username', base64_encode($response), 235); + default: + $this->setError("Authentication method \"$authtype\" is not supported"); + return false; + } + return true; + } + + /** + * Calculate an MD5 HMAC hash. + * Works like hash_hmac('md5', $data, $key) + * in case that function is not available + * @param string $data The data to hash + * @param string $key The key to hash with + * @access protected + * @return string + */ + protected function hmac($data, $key) + { + if (function_exists('hash_hmac')) { + return hash_hmac('md5', $data, $key); + } + + // The following borrowed from + // http://php.net/manual/en/function.mhash.php#27225 + + // RFC 2104 HMAC implementation for php. + // Creates an md5 HMAC. + // Eliminates the need to install mhash to compute a HMAC + // by Lance Rushing + + $bytelen = 64; // byte length for md5 + if (strlen($key) > $bytelen) { + $key = pack('H*', md5($key)); + } + $key = str_pad($key, $bytelen, chr(0x00)); + $ipad = str_pad('', $bytelen, chr(0x36)); + $opad = str_pad('', $bytelen, chr(0x5c)); + $k_ipad = $key ^ $ipad; + $k_opad = $key ^ $opad; + + return md5($k_opad . pack('H*', md5($k_ipad . $data))); + } + + /** + * Check connection state. + * @access public + * @return boolean True if connected. + */ + public function connected() + { + if (is_resource($this->smtp_conn)) { + $sock_status = stream_get_meta_data($this->smtp_conn); + if ($sock_status['eof']) { + // The socket is valid but we are not connected + $this->edebug( + 'SMTP NOTICE: EOF caught while checking if connected', + self::DEBUG_CLIENT + ); + $this->close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Close the socket and clean up the state of the class. + * Don't use this function without first trying to use QUIT. + * @see quit() + * @access public + * @return void + */ + public function close() + { + $this->setError(''); + $this->server_caps = null; + $this->helo_rply = null; + if (is_resource($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = null; //Makes for cleaner serialization + $this->edebug('Connection: closed', self::DEBUG_CONNECTION); + } + } + + /** + * Send an SMTP DATA command. + * Issues a data command and sends the msg_data to the server, + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being separated by and additional . + * Implements rfc 821: DATA + * @param string $msg_data Message data to send + * @access public + * @return boolean + */ + public function data($msg_data) + { + //This will use the standard timelimit + if (!$this->sendCommand('DATA', 'DATA', 354)) { + return false; + } + + /* The server is ready to accept data! + * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF) + * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into + * smaller lines to fit within the limit. + * We will also look for lines that start with a '.' and prepend an additional '.'. + * NOTE: this does not count towards line-length limit. + */ + + // Normalize line breaks before exploding + $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data)); + + /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field + * of the first line (':' separated) does not contain a space then it _should_ be a header and we will + * process all lines before a blank line as headers. + */ + + $field = substr($lines[0], 0, strpos($lines[0], ':')); + $in_headers = false; + if (!empty($field) && strpos($field, ' ') === false) { + $in_headers = true; + } + + foreach ($lines as $line) { + $lines_out = array(); + if ($in_headers and $line == '') { + $in_headers = false; + } + //Break this line up into several smaller lines if it's too long + //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len), + while (isset($line[self::MAX_LINE_LENGTH])) { + //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on + //so as to avoid breaking in the middle of a word + $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' '); + //Deliberately matches both false and 0 + if (!$pos) { + //No nice break found, add a hard break + $pos = self::MAX_LINE_LENGTH - 1; + $lines_out[] = substr($line, 0, $pos); + $line = substr($line, $pos); + } else { + //Break at the found point + $lines_out[] = substr($line, 0, $pos); + //Move along by the amount we dealt with + $line = substr($line, $pos + 1); + } + //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1 + if ($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + //Send the lines to the server + foreach ($lines_out as $line_out) { + //RFC2821 section 4.5.2 + if (!empty($line_out) and $line_out[0] == '.') { + $line_out = '.' . $line_out; + } + $this->client_send($line_out . self::CRLF); + } + } + + //Message data has been sent, complete the command + //Increase timelimit for end of DATA command + $savetimelimit = $this->Timelimit; + $this->Timelimit = $this->Timelimit * 2; + $result = $this->sendCommand('DATA END', '.', 250); + //Restore timelimit + $this->Timelimit = $savetimelimit; + return $result; + } + + /** + * Send an SMTP HELO or EHLO command. + * Used to identify the sending server to the receiving server. + * This makes sure that client and server are in a known state. + * Implements RFC 821: HELO + * and RFC 2821 EHLO. + * @param string $host The host name or IP to connect to + * @access public + * @return boolean + */ + public function hello($host = '') + { + //Try extended hello first (RFC 2821) + return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host)); + } + + /** + * Send an SMTP HELO or EHLO command. + * Low-level implementation used by hello() + * @see hello() + * @param string $hello The HELO string + * @param string $host The hostname to say we are + * @access protected + * @return boolean + */ + protected function sendHello($hello, $host) + { + $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250); + $this->helo_rply = $this->last_reply; + if ($noerror) { + $this->parseHelloFields($hello); + } else { + $this->server_caps = null; + } + return $noerror; + } + + /** + * Parse a reply to HELO/EHLO command to discover server extensions. + * In case of HELO, the only parameter that can be discovered is a server name. + * @access protected + * @param string $type - 'HELO' or 'EHLO' + */ + protected function parseHelloFields($type) + { + $this->server_caps = array(); + $lines = explode("\n", $this->last_reply); + + foreach ($lines as $n => $s) { + //First 4 chars contain response code followed by - or space + $s = trim(substr($s, 4)); + if (empty($s)) { + continue; + } + $fields = explode(' ', $s); + if (!empty($fields)) { + if (!$n) { + $name = $type; + $fields = $fields[0]; + } else { + $name = array_shift($fields); + switch ($name) { + case 'SIZE': + $fields = ($fields ? $fields[0] : 0); + break; + case 'AUTH': + if (!is_array($fields)) { + $fields = array(); + } + break; + default: + $fields = true; + } + } + $this->server_caps[$name] = $fields; + } + } + } + + /** + * Send an SMTP MAIL command. + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more recipient + * commands may be called followed by a data command. + * Implements rfc 821: MAIL FROM: + * @param string $from Source address of this message + * @access public + * @return boolean + */ + public function mail($from) + { + $useVerp = ($this->do_verp ? ' XVERP' : ''); + return $this->sendCommand( + 'MAIL FROM', + 'MAIL FROM:<' . $from . '>' . $useVerp, + 250 + ); + } + + /** + * Send an SMTP QUIT command. + * Closes the socket if there is no error or the $close_on_error argument is true. + * Implements from rfc 821: QUIT + * @param boolean $close_on_error Should the connection close if an error occurs? + * @access public + * @return boolean + */ + public function quit($close_on_error = true) + { + $noerror = $this->sendCommand('QUIT', 'QUIT', 221); + $err = $this->error; //Save any error + if ($noerror or $close_on_error) { + $this->close(); + $this->error = $err; //Restore any error from the quit command + } + return $noerror; + } + + /** + * Send an SMTP RCPT command. + * Sets the TO argument to $toaddr. + * Returns true if the recipient was accepted false if it was rejected. + * Implements from rfc 821: RCPT TO: + * @param string $address The address the message is being sent to + * @access public + * @return boolean + */ + public function recipient($address) + { + return $this->sendCommand( + 'RCPT TO', + 'RCPT TO:<' . $address . '>', + array(250, 251) + ); + } + + /** + * Send an SMTP RSET command. + * Abort any transaction that is currently in progress. + * Implements rfc 821: RSET + * @access public + * @return boolean True on success. + */ + public function reset() + { + return $this->sendCommand('RSET', 'RSET', 250); + } + + /** + * Send a command to an SMTP server and check its return code. + * @param string $command The command name - not sent to the server + * @param string $commandstring The actual command to send + * @param integer|array $expect One or more expected integer success codes + * @access protected + * @return boolean True on success. + */ + protected function sendCommand($command, $commandstring, $expect) + { + if (!$this->connected()) { + $this->setError("Called $command without being connected"); + return false; + } + //Reject line breaks in all commands + if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) { + $this->setError("Command '$command' contained line breaks"); + return false; + } + $this->client_send($commandstring . self::CRLF); + + $this->last_reply = $this->get_lines(); + // Fetch SMTP code and possible error code explanation + $matches = array(); + if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) { + $code = $matches[1]; + $code_ex = (count($matches) > 2 ? $matches[2] : null); + // Cut off error code from each response line + $detail = preg_replace( + "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m", + '', + $this->last_reply + ); + } else { + // Fall back to simple parsing if regex fails + $code = substr($this->last_reply, 0, 3); + $code_ex = null; + $detail = substr($this->last_reply, 4); + } + + $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER); + + if (!in_array($code, (array)$expect)) { + $this->setError( + "$command command failed", + $detail, + $code, + $code_ex + ); + $this->edebug( + 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply, + self::DEBUG_CLIENT + ); + return false; + } + + $this->setError(''); + return true; + } + + /** + * Send an SMTP SAML command. + * Starts a mail transaction from the email address specified in $from. + * Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more recipient + * commands may be called followed by a data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * Implements rfc 821: SAML FROM: + * @param string $from The address the message is from + * @access public + * @return boolean + */ + public function sendAndMail($from) + { + return $this->sendCommand('SAML', "SAML FROM:$from", 250); + } + + /** + * Send an SMTP VRFY command. + * @param string $name The name to verify + * @access public + * @return boolean + */ + public function verify($name) + { + return $this->sendCommand('VRFY', "VRFY $name", array(250, 251)); + } + + /** + * Send an SMTP NOOP command. + * Used to keep keep-alives alive, doesn't actually do anything + * @access public + * @return boolean + */ + public function noop() + { + return $this->sendCommand('NOOP', 'NOOP', 250); + } + + /** + * Send an SMTP TURN command. + * This is an optional command for SMTP that this class does not support. + * This method is here to make the RFC821 Definition complete for this class + * and _may_ be implemented in future + * Implements from rfc 821: TURN + * @access public + * @return boolean + */ + public function turn() + { + $this->setError('The SMTP TURN command is not implemented'); + $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT); + return false; + } + + /** + * Send raw data to the server. + * @param string $data The data to send + * @access public + * @return integer|boolean The number of bytes sent to the server or false on error + */ + public function client_send($data) + { + $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); + return fwrite($this->smtp_conn, $data); + } + + /** + * Get the latest error. + * @access public + * @return array + */ + public function getError() + { + return $this->error; + } + + /** + * Get SMTP extensions available on the server + * @access public + * @return array|null + */ + public function getServerExtList() + { + return $this->server_caps; + } + + /** + * A multipurpose method + * The method works in three ways, dependent on argument value and current state + * 1. HELO/EHLO was not sent - returns null and set up $this->error + * 2. HELO was sent + * $name = 'HELO': returns server name + * $name = 'EHLO': returns boolean false + * $name = any string: returns null and set up $this->error + * 3. EHLO was sent + * $name = 'HELO'|'EHLO': returns server name + * $name = any string: if extension $name exists, returns boolean True + * or its options. Otherwise returns boolean False + * In other words, one can use this method to detect 3 conditions: + * - null returned: handshake was not or we don't know about ext (refer to $this->error) + * - false returned: the requested feature exactly not exists + * - positive value returned: the requested feature exists + * @param string $name Name of SMTP extension or 'HELO'|'EHLO' + * @return mixed + */ + public function getServerExt($name) + { + if (!$this->server_caps) { + $this->setError('No HELO/EHLO was sent'); + return null; + } + + // the tight logic knot ;) + if (!array_key_exists($name, $this->server_caps)) { + if ($name == 'HELO') { + return $this->server_caps['EHLO']; + } + if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) { + return false; + } + $this->setError('HELO handshake was used. Client knows nothing about server extensions'); + return null; + } + + return $this->server_caps[$name]; + } + + /** + * Get the last reply from the server. + * @access public + * @return string + */ + public function getLastReply() + { + return $this->last_reply; + } + + /** + * Read the SMTP server's response. + * Either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access protected + * @return string + */ + protected function get_lines() + { + // If the connection is bad, give up straight away + if (!is_resource($this->smtp_conn)) { + return ''; + } + $data = ''; + $endtime = 0; + stream_set_timeout($this->smtp_conn, $this->Timeout); + if ($this->Timelimit > 0) { + $endtime = time() + $this->Timelimit; + } + while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) { + $str = @fgets($this->smtp_conn, 515); + $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); + $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); + $data .= $str; + // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen + if ((isset($str[3]) and $str[3] == ' ')) { + break; + } + // Timed-out? Log and break + $info = stream_get_meta_data($this->smtp_conn); + if ($info['timed_out']) { + $this->edebug( + 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)', + self::DEBUG_LOWLEVEL + ); + break; + } + // Now check if reads took too long + if ($endtime and time() > $endtime) { + $this->edebug( + 'SMTP -> get_lines(): timelimit reached ('. + $this->Timelimit . ' sec)', + self::DEBUG_LOWLEVEL + ); + break; + } + } + return $data; + } + + /** + * Enable or disable VERP address generation. + * @param boolean $enabled + */ + public function setVerp($enabled = false) + { + $this->do_verp = $enabled; + } + + /** + * Get VERP address generation mode. + * @return boolean + */ + public function getVerp() + { + return $this->do_verp; + } + + /** + * Set error messages and codes. + * @param string $message The error message + * @param string $detail Further detail on the error + * @param string $smtp_code An associated SMTP error code + * @param string $smtp_code_ex Extended SMTP code + */ + protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '') + { + $this->error = array( + 'error' => $message, + 'detail' => $detail, + 'smtp_code' => $smtp_code, + 'smtp_code_ex' => $smtp_code_ex + ); + } + + /** + * Set debug output method. + * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it. + */ + public function setDebugOutput($method = 'echo') + { + $this->Debugoutput = $method; + } + + /** + * Get debug output method. + * @return string + */ + public function getDebugOutput() + { + return $this->Debugoutput; + } + + /** + * Set debug output level. + * @param integer $level + */ + public function setDebugLevel($level = 0) + { + $this->do_debug = $level; + } + + /** + * Get debug output level. + * @return integer + */ + public function getDebugLevel() + { + return $this->do_debug; + } + + /** + * Set SMTP timeout. + * @param integer $timeout + */ + public function setTimeout($timeout = 0) + { + $this->Timeout = $timeout; + } + + /** + * Get SMTP timeout. + * @return integer + */ + public function getTimeout() + { + return $this->Timeout; + } +} diff --git a/plugin/PHPMailer/docs/Callback_function_notes.txt b/plugin/PHPMailer/docs/Callback_function_notes.txt new file mode 100644 index 000000000..461ea508e --- /dev/null +++ b/plugin/PHPMailer/docs/Callback_function_notes.txt @@ -0,0 +1,17 @@ +NEW CALLBACK FUNCTION: +====================== + +We have had requests for a method to process the results of sending emails +through PHPMailer. In this new release, we have implemented a callback +function that passes the results of each email sent (to, cc, and/or bcc). +We have provided an example that echos the results back to the screen. The +callback function can be used for any purpose. With minor modifications, the +callback function can be used to create CSV logs, post results to databases, +etc. + +Please review the test.php script for the example. + +It's pretty straight forward. + +Enjoy! +Andy diff --git a/plugin/PHPMailer/docs/DomainKeys_notes.txt b/plugin/PHPMailer/docs/DomainKeys_notes.txt new file mode 100644 index 000000000..2ad10f159 --- /dev/null +++ b/plugin/PHPMailer/docs/DomainKeys_notes.txt @@ -0,0 +1,55 @@ +CREATE DKIM KEYS and DNS Resource Record: +========================================= + +To create DomainKeys Identified Mail keys, visit: +http://dkim.worxware.com/ +... read the information, fill in the form, and download the ZIP file +containing the public key, private key, DNS Resource Record and instructions +to add to your DNS Zone Record, and the PHPMailer code to enable DKIM +digital signing. + +/*** PROTECT YOUR PRIVATE & PUBLIC KEYS ***/ + +You need to protect your DKIM private and public keys from being viewed or +accessed. Add protection to your .htaccess file as in this example: + +# secure htkeyprivate file + + order allow,deny + deny from all + + +# secure htkeypublic file + + order allow,deny + deny from all + + +(the actual .htaccess additions are in the ZIP file sent back to you from +http://dkim.worxware.com/ + +A few notes on using DomainKey Identified Mail (DKIM): + +You do not need to use PHPMailer to DKIM sign emails IF: +- you enable DomainKey support and add the DNS resource record +- you use your outbound mail server + +If you are a third-party emailer that works on behalf of domain owners to +send their emails from your own server: +- you absolutely have to DKIM sign outbound emails +- the domain owner has to add the DNS resource record to match the + private key, public key, selector, identity, and domain that you create +- use caution with the "selector" ... at least one "selector" will already + exist in the DNS Zone Record of the domain at the domain owner's server + you need to ensure that the "selector" you use is unique +Note: since the IP address will not match the domain owner's DNS Zone record +you can be certain that email providers that validate based on DomainKey will +check the domain owner's DNS Zone record for your DNS resource record. Before +sending out emails on behalf of domain owners, ensure they have entered the +DNS resource record you provided them. + +Enjoy! +Andy + +PS. if you need additional information about DKIM, please see: +http://www.dkim.org/info/dkim-faq.html diff --git a/plugin/PHPMailer/docs/Note_for_SMTP_debugging.txt b/plugin/PHPMailer/docs/Note_for_SMTP_debugging.txt new file mode 100644 index 000000000..128b2d9d8 --- /dev/null +++ b/plugin/PHPMailer/docs/Note_for_SMTP_debugging.txt @@ -0,0 +1,17 @@ +If you are having problems connecting or sending emails through your SMTP server, the SMTP class can provide more information about the processing/errors taking place. +Use the debug functionality of the class to see what's going on in your connections. To do that, set the debug level in your script. For example: + +$mail->SMTPDebug = 1; +$mail->isSMTP(); // telling the class to use SMTP +$mail->SMTPAuth = true; // enable SMTP authentication +$mail->Port = 26; // set the SMTP port +$mail->Host = "mail.yourhost.com"; // SMTP server +$mail->Username = "name@yourhost.com"; // SMTP account username +$mail->Password = "your password"; // SMTP account password + +Notes on this: +$mail->SMTPDebug = 0; ... will disable debugging (you can also leave this out completely, 0 is the default) +$mail->SMTPDebug = 1; ... will echo errors and server responses +$mail->SMTPDebug = 2; ... will echo errors, server responses and client messages + +And finally, don't forget to disable debugging before going into production. diff --git a/plugin/PHPMailer/docs/extending.html b/plugin/PHPMailer/docs/extending.html new file mode 100644 index 000000000..4466a1de9 --- /dev/null +++ b/plugin/PHPMailer/docs/extending.html @@ -0,0 +1,128 @@ + + +Examples using phpmailer + + + + +

Examples using PHPMailer

+ +

1. Advanced Example

+

+ +This demonstrates sending multiple email messages with binary attachments +from a MySQL database using multipart/alternative messages.

+ +

+require 'PHPMailerAutoload.php';
+
+$mail = new PHPMailer();
+
+$mail->setFrom('list@example.com', 'List manager');
+$mail->Host   = 'smtp1.example.com;smtp2.example.com';
+$mail->Mailer = 'smtp';
+
+@mysqli_connect('localhost','root','password');
+@mysqli_select_db("my_company");
+$query = "SELECT full_name, email, photo FROM employee";
+$result = @mysqli_query($query);
+
+while ($row = mysqli_fetch_assoc($result))
+{
+    // HTML body
+    $body  = "Hello <font size=\"4\">" . $row['full_name'] . "</font>, <p>";
+    $body .= "<i>Your</i> personal photograph to this message.<p>";
+    $body .= "Sincerely, <br>";
+    $body .= "phpmailer List manager";
+
+    // Plain text body (for mail clients that cannot read HTML)
+    $text_body  = 'Hello ' . $row['full_name'] . ", \n\n";
+    $text_body .= "Your personal photograph to this message.\n\n";
+    $text_body .= "Sincerely, \n";
+    $text_body .= 'phpmailer List manager';
+
+    $mail->Body    = $body;
+    $mail->AltBody = $text_body;
+    $mail->addAddress($row['email'], $row['full_name']);
+    $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
+
+    if(!$mail->send())
+        echo "There has been a mail error sending to " . $row['email'] . "<br>";
+
+    // Clear all addresses and attachments for next loop
+    $mail->clearAddresses();
+    $mail->clearAttachments();
+}
+
+

+ +

2. Extending PHPMailer

+

+ +Extending classes with inheritance is one of the most +powerful features of object-oriented programming. It allows you to make changes to the +original class for your own personal use without hacking the original +classes, and it's very easy to do: + +

+Here's a class that extends the phpmailer class and sets the defaults +for the particular site:
+PHP include file: my_phpmailer.php +

+ +

+require 'PHPMailerAutoload.php';
+
+class my_phpmailer extends PHPMailer {
+    // Set default variables for all new objects
+    public $From     = 'from@example.com';
+    public $FromName = 'Mailer';
+    public $Host     = 'smtp1.example.com;smtp2.example.com';
+    public $Mailer   = 'smtp';                         // Alternative to isSMTP()
+    public $WordWrap = 75;
+
+    // Replace the default debug output function
+    protected function edebug($msg) {
+        print('My Site Error');
+        print('Description:');
+        printf('%s', $msg);
+        exit;
+    }
+
+    //Extend the send function
+    public function send() {
+        $this->Subject = '[Yay for me!] '.$this->Subject;
+        return parent::send()
+    }
+
+    // Create an additional function
+    public function do_something($something) {
+        // Place your new code here
+    }
+}
+
+
+Now here's a normal PHP page in the site, which will have all the defaults set above:
+ +
+require 'my_phpmailer.php';
+
+// Instantiate your new class
+$mail = new my_phpmailer;
+
+// Now you only need to add the necessary stuff
+$mail->addAddress('josh@example.com', 'Josh Adams');
+$mail->Subject = 'Here is the subject';
+$mail->Body    = 'This is the message body';
+$mail->addAttachment('c:/temp/11-10-00.zip', 'new_name.zip');  // optional name
+
+if(!$mail->send())
+{
+   echo 'There was an error sending the message';
+   exit;
+}
+
+echo 'Message was sent successfully';
+
+ + diff --git a/plugin/PHPMailer/docs/faq.html b/plugin/PHPMailer/docs/faq.html new file mode 100644 index 000000000..7033a142e --- /dev/null +++ b/plugin/PHPMailer/docs/faq.html @@ -0,0 +1,28 @@ + + +PHPMailer FAQ + + +

PHPMailer FAQ

+
    +
  • Q: I am concerned that using include files will take up too much + processing time on my computer. How can I make it run faster?
    + A: PHP by itself is fairly fast, but it recompiles scripts every time they are run, which takes up valuable + computer resources. You can bypass this by using an opcode cache which compiles + PHP code and store it in memory to reduce overhead immensely. APC + (Alternative PHP Cache) is a free opcode cache extension in the PECL library.
  • +
  • Q: Which mailer gives me the best performance?
    + A: On a single machine the sendmail (or Qmail) is fastest overall. + Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. + If you do not have a local mail server (as is typical on Windows), SMTP is your only option.
  • +
  • Q: When I try to attach a file with on my server I get a + "Could not find {file} on filesystem error". Why is this?
    + A: If you are using a Unix machine this is probably because the user + running your web server does not have read access to the directory in question. If you are using Windows, + then the problem is probably that you have used single backslashes to denote directories (\). + A single backslash has a special meaning to PHP so these are not + valid. Instead use double backslashes ("\\") or a single forward + slash ("/").
  • +
+ + diff --git a/plugin/PHPMailer_v2.0.4/docs/pop3_article.txt b/plugin/PHPMailer/docs/pop3_article.txt similarity index 74% rename from plugin/PHPMailer_v2.0.4/docs/pop3_article.txt rename to plugin/PHPMailer/docs/pop3_article.txt index 379c44e89..fb90b9c76 100644 --- a/plugin/PHPMailer_v2.0.4/docs/pop3_article.txt +++ b/plugin/PHPMailer/docs/pop3_article.txt @@ -1,39 +1,50 @@ -This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. - -With that noted, here is how to implement it: -Install the class file - -I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer-1.72 directory: -[geshi lang=php] require 'phpmailer-1.72/class.phpmailer.php'; require 'phpmailer-1.72/class.pop3.php'; [/geshi] -When you need it, create your POP3 object - -Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: -[geshi lang=php] Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); $mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->IsSMTP(); $mail->IsHTML(false); $mail->Host = 'relay.example.com'; $mail->From = 'mailer@example.com'; $mail->FromName = 'Example Mailer'; $mail->Subject = 'My subject'; $mail->Body = 'Hello world'; $mail->AddAddress('rich@corephp.co.uk', 'Richard Davey'); if (!$mail->Send()) { echo $mail->ErrorInfo; } ?> [/geshi] - -The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are Connect, Logon and Disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. -The Parameters - -The Authorise parameters are as follows: -[geshi lang=php]$pop->Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);[/geshi] - - 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) - 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) - 3. 30 - A connection time-out value (in seconds) - 4. mailer - The POP3 Username required to logon - 5. password - The POP3 Password required to logon - 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) - -Final Comments + the Download - -1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. - -2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. - -3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. - -4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. -Download - -Here is the full class file plus my test script: POP_before_SMTP_PHPMailer.zip (4 KB) - Please note that it does not include PHPMailer itself. - -My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) +This is built for PHP Mailer 1.72 and was not tested with any previous version. It was developed under PHP 4.3.11 (E_ALL). It works under PHP 5 and 5.1 with E_ALL, but not in Strict mode due to var deprecation (but then neither does PHP Mailer either!). It follows the RFC 1939 standard explicitly and is fully commented. + +With that noted, here is how to implement it: + +I didn't want to modify the PHP Mailer classes at all, so you will have to include/require this class along with the base one. It can sit quite happily in the phpmailer directory. + +When you need it, create your POP3 object + +Right before I invoke PHP Mailer I activate the POP3 authorisation. POP3 before SMTP is a process whereby you login to your web hosts POP3 mail server BEFORE sending out any emails via SMTP. The POP3 logon 'verifies' your ability to send email by SMTP, which typically otherwise blocks you. On my web host (Pair Networks) a single POP3 logon is enough to 'verify' you for 90 minutes. Here is some sample PHP code that activates the POP3 logon and then sends an email via PHP Mailer: + +authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); +$mail = new PHPMailer(); $mail->SMTPDebug = 2; $mail->isSMTP(); +$mail->isHTML(false); $mail->Host = 'relay.example.com'; +$mail->From = 'mailer@example.com'; +$mail->FromName = 'Example Mailer'; +$mail->Subject = 'My subject'; +$mail->Body = 'Hello world'; +$mail->addAddress('rich@corephp.co.uk', 'Richard Davey'); +if (!$mail->send()) { + echo $mail->ErrorInfo; +} +?> + +The PHP Mailer parts of this code should be obvious to anyone who has used PHP Mailer before. One thing to note - you almost certainly will not need to use SMTP Authentication *and* POP3 before SMTP together. The Authorisation method is a proxy method to all of the others within that class. There are connect, Logon and disconnect methods available, but I wrapped them in the single Authorisation one to make things easier. +The Parameters + +The authorise parameters are as follows: + +$pop->authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1); + + 1. pop3.example.com - The POP3 Mail Server Name (hostname or IP address) + 2. 110 - The POP3 Port on which to connect (default is usually 110, but check with your host) + 3. 30 - A connection time-out value (in seconds) + 4. mailer - The POP3 Username required to logon + 5. password - The POP3 Password required to logon + 6. 1 - The class debug level (0 = off, 1+ = debug output is echoed to the browser) + +Final Comments + the Download + +1) This class does not support APOP connections. This is only because I did not have an APOP server to test with, but if you'd like to see that added just contact me. + +2) Opening and closing lots of POP3 connections can be quite a resource/network drain. If you need to send a whole batch of emails then just perform the authentication once at the start, and then loop through your mail sending script. Providing this process doesn't take longer than the verification period lasts on your POP3 server, you should be fine. With my host that period is 90 minutes, i.e. plenty of time. + +3) If you have heavy requirements for this script (i.e. send a LOT of email on a frequent basis) then I would advise seeking out an alternative sending method (direct SMTP ideally). If this isn't possible then you could modify this class so the 'last authorised' date is recorded somewhere (MySQL, Flat file, etc) meaning you only open a new connection if the old one has expired, saving you precious overhead. + +4) There are lots of other POP3 classes for PHP available. However most of them implement the full POP3 command set, where-as this one is purely for authentication, and much lighter as a result. However using any of the other POP3 classes to just logon to your server would have the same net result. At the end of the day, use whatever method you feel most comfortable with. +Download + +My thanks to Chris Ryan for the inspiration (even if indirectly, via his SMTP class) diff --git a/plugin/PHPMailer/examples/code_generator.phps b/plugin/PHPMailer/examples/code_generator.phps new file mode 100644 index 000000000..23458561b --- /dev/null +++ b/plugin/PHPMailer/examples/code_generator.phps @@ -0,0 +1,597 @@ +CharSet = 'utf-8'; +ini_set('default_charset', 'UTF-8'); +$mail->Debugoutput = $CFG['smtp_debugoutput']; +$example_code .= "\n\n\$mail = new PHPMailer(true);"; +$example_code .= "\n\$mail->CharSet = 'utf-8';"; +$example_code .= "\nini_set('default_charset', 'UTF-8');"; + +class phpmailerAppException extends phpmailerException +{ +} + +$example_code .= "\n\nclass phpmailerAppException extends phpmailerException {}"; +$example_code .= "\n\ntry {"; + +try { + if (isset($_POST["submit"]) && $_POST['submit'] == "Submit") { + $to = $_POST['To_Email']; + if (!PHPMailer::validateAddress($to)) { + throw new phpmailerAppException("Email address " . $to . " is invalid -- aborting!"); + } + + $example_code .= "\n\$to = '{$_POST['To_Email']}';"; + $example_code .= "\nif(!PHPMailer::validateAddress(\$to)) {"; + $example_code .= "\n throw new phpmailerAppException(\"Email address \" . " . + "\$to . \" is invalid -- aborting!\");"; + $example_code .= "\n}"; + + switch ($_POST['test_type']) { + case 'smtp': + $mail->isSMTP(); // telling the class to use SMTP + $mail->SMTPDebug = (integer)$_POST['smtp_debug']; + $mail->Host = $_POST['smtp_server']; // SMTP server + $mail->Port = (integer)$_POST['smtp_port']; // set the SMTP port + if ($_POST['smtp_secure']) { + $mail->SMTPSecure = strtolower($_POST['smtp_secure']); + } + $mail->SMTPAuth = array_key_exists('smtp_authenticate', $_POST); // enable SMTP authentication? + if (array_key_exists('smtp_authenticate', $_POST)) { + $mail->Username = $_POST['authenticate_username']; // SMTP account username + $mail->Password = $_POST['authenticate_password']; // SMTP account password + } + + $example_code .= "\n\$mail->isSMTP();"; + $example_code .= "\n\$mail->SMTPDebug = " . $_POST['smtp_debug'] . ";"; + $example_code .= "\n\$mail->Host = \"" . $_POST['smtp_server'] . "\";"; + $example_code .= "\n\$mail->Port = \"" . $_POST['smtp_port'] . "\";"; + $example_code .= "\n\$mail->SMTPSecure = \"" . strtolower($_POST['smtp_secure']) . "\";"; + $example_code .= "\n\$mail->SMTPAuth = " . (array_key_exists( + 'smtp_authenticate', + $_POST + ) ? 'true' : 'false') . ";"; + if (array_key_exists('smtp_authenticate', $_POST)) { + $example_code .= "\n\$mail->Username = \"" . $_POST['authenticate_username'] . "\";"; + $example_code .= "\n\$mail->Password = \"" . $_POST['authenticate_password'] . "\";"; + } + break; + case 'mail': + $mail->isMail(); // telling the class to use PHP's mail() + $example_code .= "\n\$mail->isMail();"; + break; + case 'sendmail': + $mail->isSendmail(); // telling the class to use Sendmail + $example_code .= "\n\$mail->isSendmail();"; + break; + case 'qmail': + $mail->isQmail(); // telling the class to use Qmail + $example_code .= "\n\$mail->isQmail();"; + break; + default: + throw new phpmailerAppException('Invalid test_type provided'); + } + + try { + if ($_POST['From_Name'] != '') { + $mail->addReplyTo($_POST['From_Email'], $_POST['From_Name']); + $mail->setFrom($_POST['From_Email'], $_POST['From_Name']); + + $example_code .= "\n\$mail->addReplyTo(\"" . + $_POST['From_Email'] . "\", \"" . $_POST['From_Name'] . "\");"; + $example_code .= "\n\$mail->setFrom(\"" . + $_POST['From_Email'] . "\", \"" . $_POST['From_Name'] . "\");"; + } else { + $mail->addReplyTo($_POST['From_Email']); + $mail->setFrom($_POST['From_Email'], $_POST['From_Email']); + + $example_code .= "\n\$mail->addReplyTo(\"" . $_POST['From_Email'] . "\");"; + $example_code .= "\n\$mail->setFrom(\"" . + $_POST['From_Email'] . "\", \"" . $_POST['From_Email'] . "\");"; + } + + if ($_POST['To_Name'] != '') { + $mail->addAddress($to, $_POST['To_Name']); + $example_code .= "\n\$mail->addAddress(\"$to\", \"" . $_POST['To_Name'] . "\");"; + } else { + $mail->addAddress($to); + $example_code .= "\n\$mail->addAddress(\"$to\");"; + } + + if ($_POST['bcc_Email'] != '') { + $indiBCC = explode(" ", $_POST['bcc_Email']); + foreach ($indiBCC as $key => $value) { + $mail->addBCC($value); + $example_code .= "\n\$mail->addBCC(\"$value\");"; + } + } + + if ($_POST['cc_Email'] != '') { + $indiCC = explode(" ", $_POST['cc_Email']); + foreach ($indiCC as $key => $value) { + $mail->addCC($value); + $example_code .= "\n\$mail->addCC(\"$value\");"; + } + } + } catch (phpmailerException $e) { //Catch all kinds of bad addressing + throw new phpmailerAppException($e->getMessage()); + } + $mail->Subject = $_POST['Subject'] . ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')'; + $example_code .= "\n\$mail->Subject = \"" . $_POST['Subject'] . + ' (PHPMailer test using ' . strtoupper($_POST['test_type']) . ')";'; + + if ($_POST['Message'] == '') { + $body = file_get_contents('contents.html'); + } else { + $body = $_POST['Message']; + } + + $example_code .= "\n\$body = <<<'EOT'\n" . htmlentities($body) . "\nEOT;"; + + $mail->WordWrap = 78; // set word wrap to the RFC2822 limit + $mail->msgHTML($body, dirname(__FILE__), true); //Create message bodies and embed images + + $example_code .= "\n\$mail->WordWrap = 78;"; + $example_code .= "\n\$mail->msgHTML(\$body, dirname(__FILE__), true); //Create message bodies and embed images"; + + $mail->addAttachment('images/phpmailer_mini.png', 'phpmailer_mini.png'); // optional name + $mail->addAttachment('images/phpmailer.png', 'phpmailer.png'); // optional name + $example_code .= "\n\$mail->addAttachment('images/phpmailer_mini.png'," . + "'phpmailer_mini.png'); // optional name"; + $example_code .= "\n\$mail->addAttachment('images/phpmailer.png', 'phpmailer.png'); // optional name"; + + $example_code .= "\n\ntry {"; + $example_code .= "\n \$mail->send();"; + $example_code .= "\n \$results_messages[] = \"Message has been sent using " . + strtoupper($_POST['test_type']) . "\";"; + $example_code .= "\n}"; + $example_code .= "\ncatch (phpmailerException \$e) {"; + $example_code .= "\n throw new phpmailerAppException('Unable to send to: ' . \$to. ': '.\$e->getMessage());"; + $example_code .= "\n}"; + + try { + $mail->send(); + $results_messages[] = "Message has been sent using " . strtoupper($_POST["test_type"]); + } catch (phpmailerException $e) { + throw new phpmailerAppException("Unable to send to: " . $to . ': ' . $e->getMessage()); + } + } +} catch (phpmailerAppException $e) { + $results_messages[] = $e->errorMessage(); +} +$example_code .= "\n}"; +$example_code .= "\ncatch (phpmailerAppException \$e) {"; +$example_code .= "\n \$results_messages[] = \$e->errorMessage();"; +$example_code .= "\n}"; +$example_code .= "\n\nif (count(\$results_messages) > 0) {"; +$example_code .= "\n echo \"

Run results

\\n\";"; +$example_code .= "\n echo \"
    \\n\";"; +$example_code .= "\nforeach (\$results_messages as \$result) {"; +$example_code .= "\n echo \"
  • \$result
  • \\n\";"; +$example_code .= "\n}"; +$example_code .= "\necho \"
\\n\";"; +$example_code .= "\n}"; +?> + + + + PHPMailer Test Page + + + + + + + + +"; + echo exit("ERROR: Wrong PHP version. Must be PHP 5 or above."); +} + +if (count($results_messages) > 0) { + echo '

Run results

'; + echo '
    '; + foreach ($results_messages as $result) { + echo "
  • $result
  • "; + } + echo '
'; +} + +if (isset($_POST["submit"]) && $_POST["submit"] == "Submit") { + echo "
\n"; + echo "
Script:\n"; + echo "
\n";
+    echo $example_code;
+    echo "\n
\n"; + echo "\n
\n"; +} +?> +
+
+
+
+ Mail Details + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+
Test will include two attachments.
+
+
+
+
+ Mail Test Specs + + + + + +
Test Type +
+ + + required> +
+
+ + + required> +
+
+ + + required> +
+
+ + + required> +
+
+
"> + SMTP Specific Options: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ + value=""> +
+ +
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+
+ + diff --git a/plugin/PHPMailer/examples/contents.html b/plugin/PHPMailer/examples/contents.html new file mode 100644 index 000000000..dc3fc6676 --- /dev/null +++ b/plugin/PHPMailer/examples/contents.html @@ -0,0 +1,17 @@ + + + + + PHPMailer Test + + +
+

This is a test of PHPMailer.

+
+ PHPMailer rocks +
+

This example uses HTML.

+

ISO-8859-1 text:

+
+ + diff --git a/plugin/PHPMailer/examples/contentsutf8.html b/plugin/PHPMailer/examples/contentsutf8.html new file mode 100644 index 000000000..81a202405 --- /dev/null +++ b/plugin/PHPMailer/examples/contentsutf8.html @@ -0,0 +1,20 @@ + + + + + PHPMailer Test + + +
+

This is a test of PHPMailer.

+
+ PHPMailer rocks +
+

This example uses HTML.

+

Chinese text: 郵件內容為空

+

Russian text: Пустое тело сообщения

+

Armenian text: Հաղորդագրությունը դատարկ է

+

Czech text: Prázdné tělo zprávy

+
+ + diff --git a/plugin/PHPMailer/examples/exceptions.phps b/plugin/PHPMailer/examples/exceptions.phps new file mode 100644 index 000000000..0e941e733 --- /dev/null +++ b/plugin/PHPMailer/examples/exceptions.phps @@ -0,0 +1,35 @@ +setFrom('from@example.com', 'First Last'); + //Set an alternative reply-to address + $mail->addReplyTo('replyto@example.com', 'First Last'); + //Set who the message is to be sent to + $mail->addAddress('whoto@example.com', 'John Doe'); + //Set the subject line + $mail->Subject = 'PHPMailer Exceptions test'; + //Read an HTML message body from an external file, convert referenced images to embedded, + //and convert the HTML into a basic plain-text alternative body + $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); + //Replace the plain text body with one created manually + $mail->AltBody = 'This is a plain-text message body'; + //Attach an image file + $mail->addAttachment('images/phpmailer_mini.png'); + //send the message + //Note that we don't need check the response from this because it will throw an exception if it has trouble + $mail->send(); + echo "Message sent!"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} diff --git a/plugin/PHPMailer/examples/gmail.phps b/plugin/PHPMailer/examples/gmail.phps new file mode 100644 index 000000000..b3cc02d53 --- /dev/null +++ b/plugin/PHPMailer/examples/gmail.phps @@ -0,0 +1,75 @@ +isSMTP(); + +//Enable SMTP debugging +// 0 = off (for production use) +// 1 = client messages +// 2 = client and server messages +$mail->SMTPDebug = 2; + +//Ask for HTML-friendly debug output +$mail->Debugoutput = 'html'; + +//Set the hostname of the mail server +$mail->Host = 'smtp.gmail.com'; +// use +// $mail->Host = gethostbyname('smtp.gmail.com'); +// if your network does not support SMTP over IPv6 + +//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission +$mail->Port = 587; + +//Set the encryption system to use - ssl (deprecated) or tls +$mail->SMTPSecure = 'tls'; + +//Whether to use SMTP authentication +$mail->SMTPAuth = true; + +//Username to use for SMTP authentication - use full email address for gmail +$mail->Username = "username@gmail.com"; + +//Password to use for SMTP authentication +$mail->Password = "yourpassword"; + +//Set who the message is to be sent from +$mail->setFrom('from@example.com', 'First Last'); + +//Set an alternative reply-to address +$mail->addReplyTo('replyto@example.com', 'First Last'); + +//Set who the message is to be sent to +$mail->addAddress('whoto@example.com', 'John Doe'); + +//Set the subject line +$mail->Subject = 'PHPMailer GMail SMTP test'; + +//Read an HTML message body from an external file, convert referenced images to embedded, +//convert HTML into a basic plain-text alternative body +$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); + +//Replace the plain text body with one created manually +$mail->AltBody = 'This is a plain-text message body'; + +//Attach an image file +$mail->addAttachment('images/phpmailer_mini.png'); + +//send the message, check for errors +if (!$mail->send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} diff --git a/plugin/PHPMailer/examples/gmail_xoauth.phps b/plugin/PHPMailer/examples/gmail_xoauth.phps new file mode 100644 index 000000000..d64483a4d --- /dev/null +++ b/plugin/PHPMailer/examples/gmail_xoauth.phps @@ -0,0 +1,85 @@ +isSMTP(); + +//Enable SMTP debugging +// 0 = off (for production use) +// 1 = client messages +// 2 = client and server messages +$mail->SMTPDebug = 0; + +//Ask for HTML-friendly debug output +$mail->Debugoutput = 'html'; + +//Set the hostname of the mail server +$mail->Host = 'smtp.gmail.com'; + +//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission +$mail->Port = 587; + +//Set the encryption system to use - ssl (deprecated) or tls +$mail->SMTPSecure = 'tls'; + +//Whether to use SMTP authentication +$mail->SMTPAuth = true; + +//Set AuthType +$mail->AuthType = 'XOAUTH2'; + +//User Email to use for SMTP authentication - Use the same Email used in Google Developer Console +$mail->oauthUserEmail = "someone@gmail.com"; + +//Obtained From Google Developer Console +$mail->oauthClientId = "RANDOMCHARS-----duv1n2.apps.googleusercontent.com"; + +//Obtained From Google Developer Console +$mail->oauthClientSecret = "RANDOMCHARS-----lGyjPcRtvP"; + +//Obtained By running get_oauth_token.php after setting up APP in Google Developer Console. +//Set Redirect URI in Developer Console as [https/http]:////get_oauth_token.php +// eg: http://localhost/phpmail/get_oauth_token.php +$mail->oauthRefreshToken = "RANDOMCHARS-----DWxgOvPT003r-yFUV49TQYag7_Aod7y0"; + +//Set who the message is to be sent from +//For gmail, this generally needs to be the same as the user you logged in as +$mail->setFrom('from@example.com', 'First Last'); + +//Set who the message is to be sent to +$mail->addAddress('whoto@example.com', 'John Doe'); + +//Set the subject line +$mail->Subject = 'PHPMailer GMail SMTP test'; + +//Read an HTML message body from an external file, convert referenced images to embedded, +//convert HTML into a basic plain-text alternative body +$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); + +//Replace the plain text body with one created manually +$mail->AltBody = 'This is a plain-text message body'; + +//Attach an image file +$mail->addAttachment('images/phpmailer_mini.png'); + +//send the message, check for errors +if (!$mail->send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} diff --git a/plugin/PHPMailer/examples/images/phpmailer.png b/plugin/PHPMailer/examples/images/phpmailer.png new file mode 100644 index 000000000..9bdd83c8d Binary files /dev/null and b/plugin/PHPMailer/examples/images/phpmailer.png differ diff --git a/plugin/PHPMailer/examples/images/phpmailer_mini.png b/plugin/PHPMailer/examples/images/phpmailer_mini.png new file mode 100644 index 000000000..e6915f431 Binary files /dev/null and b/plugin/PHPMailer/examples/images/phpmailer_mini.png differ diff --git a/plugin/PHPMailer/examples/index.html b/plugin/PHPMailer/examples/index.html new file mode 100644 index 000000000..bbb830d19 --- /dev/null +++ b/plugin/PHPMailer/examples/index.html @@ -0,0 +1,48 @@ + + + + + PHPMailer Examples + + +

PHPMailer code examplesPHPMailer logo

+

This folder contains a collection of examples of using PHPMailer.

+

About testing email sending

+

When working on email sending code you'll find yourself worrying about what might happen if all these test emails got sent to your mailing list. The solution is to use a fake mail server, one that acts just like the real thing, but just doesn't actually send anything out. Some offer web interfaces, feedback, logging, the ability to return specific error codes, all things that are useful for testing error handling, authentication etc. Here's a selection of mail testing tools you might like to try:

+
    +
  • FakeSMTP, a Java desktop app with the ability to show an SMTP log and save messages to a folder.
  • +
  • FakeEmail, a Python-based fake mail server with a web interface.
  • +
  • smtp-sink, part of the Postfix mail server, so you probably already have this installed. This is used in the Travis-CI configuration to run PHPMailer's unit tests.
  • +
  • smtp4dev, a dummy SMTP server for Windows.
  • +
  • fakesendmail.sh, part of PHPMailer's test setup, this is a shell script that emulates sendmail for testing 'mail' or 'sendmail' methods in PHPMailer.
  • +
  • msglint, not a mail server, the IETF's MIME structure analyser checks the formatting of your messages.
  • +
+
+

Security note

+

Before running these examples you'll need to rename them with '.php' extensions. They are supplied as '.phps' files which will usually be displayed with syntax highlighting by PHP instead of running them. This prevents potential security issues with running potential spam-gateway code if you happen to deploy these code examples on a live site - please don't do that! Similarly, don't leave your passwords in these files as they will be visible to the world!

+
+

code_generator.phps

+

This script is a simple code generator - fill in the form and hit submit, and it will use when you entered to email you a message, and will also generate PHP code using your settings that you can copy and paste to use in your own apps. If you need to get going quickly, this is probably the best place to start.

+

mail.phps

+

This script is a basic example which creates an email message from an external HTML file, creates a plain text body, sets various addresses, adds an attachment and sends the message. It uses PHP's built-in mail() function which is the simplest to use, but relies on the presence of a local mail server, something which is not usually available on Windows. If you find yourself in that situation, either install a local mail server, or use a remote one and send using SMTP instead.

+

exceptions.phps

+

The same as the mail example, but shows how to use PHPMailer's optional exceptions for error handling.

+

smtp.phps

+

A simple example sending using SMTP with authentication.

+

smtp_no_auth.phps

+

A simple example sending using SMTP without authentication.

+

sendmail.phps

+

A simple example using sendmail. Sendmail is a program (usually found on Linux/BSD, OS X and other UNIX-alikes) that can be used to submit messages to a local mail server without a lengthy SMTP conversation. It's probably the fastest sending mechanism, but lacks some error reporting features. There are sendmail emulators for most popular mail servers including postfix, qmail, exim etc.

+

gmail.phps

+

Submitting email via Google's Gmail service is a popular use of PHPMailer. It's much the same as normal SMTP sending, just with some specific settings, namely using TLS encryption, authentication is enabled, and it connects to the SMTP submission port 587 on the smtp.gmail.com host. This example does all that.

+

pop_before_smtp.phps

+

Before effective SMTP authentication mechanisms were available, it was common for ISPs to use POP-before-SMTP authentication. As it implies, you authenticate using the POP3 protocol (an older protocol now mostly replaced by the far superior IMAP), and then the SMTP server will allow send access from your IP address for a short while, usually 5-15 minutes. PHPMailer includes a POP3 protocol client, so it can carry out this sequence - it's just like a normal SMTP conversation (without authentication), but connects via POP first.

+

mailing_list.phps

+

This is a somewhat naïve example of sending similar emails to a list of different addresses. It sets up a PHPMailer instance using SMTP, then connects to a MySQL database to retrieve a list of recipients. The code loops over this list, sending email to each person using their info and marks them as sent in the database. It makes use of SMTP keepalive which saves reconnecting and re-authenticating between each message.

+
+

smtp_check.phps

+

This is an example showing how to use the SMTP class by itself (without PHPMailer) to check an SMTP connection.

+
+

Most of these examples use the 'example.com' domain. This domain is reserved by IANA for illustrative purposes, as documented in RFC 2606. Don't use made-up domains like 'mydomain.com' or 'somedomain.com' in examples as someone, somewhere, probably owns them!

+ + diff --git a/plugin/PHPMailer/examples/mail.phps b/plugin/PHPMailer/examples/mail.phps new file mode 100644 index 000000000..8e129f47d --- /dev/null +++ b/plugin/PHPMailer/examples/mail.phps @@ -0,0 +1,31 @@ +setFrom('from@example.com', 'First Last'); +//Set an alternative reply-to address +$mail->addReplyTo('replyto@example.com', 'First Last'); +//Set who the message is to be sent to +$mail->addAddress('whoto@example.com', 'John Doe'); +//Set the subject line +$mail->Subject = 'PHPMailer mail() test'; +//Read an HTML message body from an external file, convert referenced images to embedded, +//convert HTML into a basic plain-text alternative body +$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); +//Replace the plain text body with one created manually +$mail->AltBody = 'This is a plain-text message body'; +//Attach an image file +$mail->addAttachment('images/phpmailer_mini.png'); + +//send the message, check for errors +if (!$mail->send()) { + echo "Mailer Error: " . $mail->ErrorInfo; +} else { + echo "Message sent!"; +} diff --git a/plugin/PHPMailer/examples/mailing_list.phps b/plugin/PHPMailer/examples/mailing_list.phps new file mode 100644 index 000000000..8644bb596 --- /dev/null +++ b/plugin/PHPMailer/examples/mailing_list.phps @@ -0,0 +1,59 @@ +isSMTP(); +$mail->Host = 'smtp.example.com'; +$mail->SMTPAuth = true; +$mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent, reduces SMTP overhead +$mail->Port = 25; +$mail->Username = 'yourname@example.com'; +$mail->Password = 'yourpassword'; +$mail->setFrom('list@example.com', 'List manager'); +$mail->addReplyTo('list@example.com', 'List manager'); + +$mail->Subject = "PHPMailer Simple database mailing list test"; + +//Same body for all messages, so set this before the sending loop +//If you generate a different body for each recipient (e.g. you're using a templating system), +//set it inside the loop +$mail->msgHTML($body); +//msgHTML also sets AltBody, but if you want a custom one, set it afterwards +$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; + +//Connect to the database and select the recipients from your mailing list that have not yet been sent to +//You'll need to alter this to match your database +$mysql = mysqli_connect('localhost', 'username', 'password'); +mysqli_select_db($mysql, 'mydb'); +$result = mysqli_query($mysql, 'SELECT full_name, email, photo FROM mailinglist WHERE sent = false'); + +foreach ($result as $row) { //This iterator syntax only works in PHP 5.4+ + $mail->addAddress($row['email'], $row['full_name']); + if (!empty($row['photo'])) { + $mail->addStringAttachment($row['photo'], 'YourPhoto.jpg'); //Assumes the image data is stored in the DB + } + + if (!$mail->send()) { + echo "Mailer Error (" . str_replace("@", "@", $row["email"]) . ') ' . $mail->ErrorInfo . '
'; + break; //Abandon sending + } else { + echo "Message sent to :" . $row['full_name'] . ' (' . str_replace("@", "@", $row['email']) . ')
'; + //Mark it as sent in the DB + mysqli_query( + $mysql, + "UPDATE mailinglist SET sent = true WHERE email = '" . + mysqli_real_escape_string($mysql, $row['email']) . "'" + ); + } + // Clear all addresses and attachments for next loop + $mail->clearAddresses(); + $mail->clearAttachments(); +} diff --git a/plugin/PHPMailer/examples/pop_before_smtp.phps b/plugin/PHPMailer/examples/pop_before_smtp.phps new file mode 100644 index 000000000..164dfe8dd --- /dev/null +++ b/plugin/PHPMailer/examples/pop_before_smtp.phps @@ -0,0 +1,54 @@ +isSMTP(); + //Enable SMTP debugging + // 0 = off (for production use) + // 1 = client messages + // 2 = client and server messages + $mail->SMTPDebug = 2; + //Ask for HTML-friendly debug output + $mail->Debugoutput = 'html'; + //Set the hostname of the mail server + $mail->Host = "mail.example.com"; + //Set the SMTP port number - likely to be 25, 465 or 587 + $mail->Port = 25; + //Whether to use SMTP authentication + $mail->SMTPAuth = false; + //Set who the message is to be sent from + $mail->setFrom('from@example.com', 'First Last'); + //Set an alternative reply-to address + $mail->addReplyTo('replyto@example.com', 'First Last'); + //Set who the message is to be sent to + $mail->addAddress('whoto@example.com', 'John Doe'); + //Set the subject line + $mail->Subject = 'PHPMailer POP-before-SMTP test'; + //Read an HTML message body from an external file, convert referenced images to embedded, + //and convert the HTML into a basic plain-text alternative body + $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); + //Replace the plain text body with one created manually + $mail->AltBody = 'This is a plain-text message body'; + //Attach an image file + $mail->addAttachment('images/phpmailer_mini.png'); + //send the message + //Note that we don't need check the response from this because it will throw an exception if it has trouble + $mail->send(); + echo "Message sent!"; +} catch (phpmailerException $e) { + echo $e->errorMessage(); //Pretty error messages from PHPMailer +} catch (Exception $e) { + echo $e->getMessage(); //Boring error messages from anything else! +} diff --git a/plugin/PHPMailer/examples/scripts/XRegExp.js b/plugin/PHPMailer/examples/scripts/XRegExp.js new file mode 100644 index 000000000..ebdb9c948 --- /dev/null +++ b/plugin/PHPMailer/examples/scripts/XRegExp.js @@ -0,0 +1,664 @@ +// XRegExp 1.5.1 +// (c) 2007-2012 Steven Levithan +// MIT License +// +// Provides an augmented, extensible, cross-browser implementation of regular expressions, +// including support for additional syntax, flags, and methods + +var XRegExp; + +if (XRegExp) { + // Avoid running twice, since that would break references to native globals + throw Error("can't load XRegExp twice in the same frame"); +} + +// Run within an anonymous function to protect variables and avoid new globals +(function (undefined) { + + //--------------------------------- + // Constructor + //--------------------------------- + + // Accepts a pattern and flags; returns a new, extended `RegExp` object. Differs from a native + // regular expression in that additional syntax and flags are supported and cross-browser + // syntax inconsistencies are ameliorated. `XRegExp(/regex/)` clones an existing regex and + // converts to type XRegExp + XRegExp = function (pattern, flags) { + var output = [], + currScope = XRegExp.OUTSIDE_CLASS, + pos = 0, + context, tokenResult, match, chr, regex; + + if (XRegExp.isRegExp(pattern)) { + if (flags !== undefined) + throw TypeError("can't supply flags when constructing one RegExp from another"); + return clone(pattern); + } + // Tokens become part of the regex construction process, so protect against infinite + // recursion when an XRegExp is constructed within a token handler or trigger + if (isInsideConstructor) + throw Error("can't call the XRegExp constructor within token definition functions"); + + flags = flags || ""; + context = { // `this` object for custom tokens + hasNamedCapture: false, + captureNames: [], + hasFlag: function (flag) {return flags.indexOf(flag) > -1;}, + setFlag: function (flag) {flags += flag;} + }; + + while (pos < pattern.length) { + // Check for custom tokens at the current position + tokenResult = runTokens(pattern, pos, currScope, context); + + if (tokenResult) { + output.push(tokenResult.output); + pos += (tokenResult.match[0].length || 1); + } else { + // Check for native multicharacter metasequences (excluding character classes) at + // the current position + if (match = nativ.exec.call(nativeTokens[currScope], pattern.slice(pos))) { + output.push(match[0]); + pos += match[0].length; + } else { + chr = pattern.charAt(pos); + if (chr === "[") + currScope = XRegExp.INSIDE_CLASS; + else if (chr === "]") + currScope = XRegExp.OUTSIDE_CLASS; + // Advance position one character + output.push(chr); + pos++; + } + } + } + + regex = RegExp(output.join(""), nativ.replace.call(flags, flagClip, "")); + regex._xregexp = { + source: pattern, + captureNames: context.hasNamedCapture ? context.captureNames : null + }; + return regex; + }; + + + //--------------------------------- + // Public properties + //--------------------------------- + + XRegExp.version = "1.5.1"; + + // Token scope bitflags + XRegExp.INSIDE_CLASS = 1; + XRegExp.OUTSIDE_CLASS = 2; + + + //--------------------------------- + // Private variables + //--------------------------------- + + var replacementToken = /\$(?:(\d\d?|[$&`'])|{([$\w]+)})/g, + flagClip = /[^gimy]+|([\s\S])(?=[\s\S]*\1)/g, // Nonnative and duplicate flags + quantifier = /^(?:[?*+]|{\d+(?:,\d*)?})\??/, + isInsideConstructor = false, + tokens = [], + // Copy native globals for reference ("native" is an ES3 reserved keyword) + nativ = { + exec: RegExp.prototype.exec, + test: RegExp.prototype.test, + match: String.prototype.match, + replace: String.prototype.replace, + split: String.prototype.split + }, + compliantExecNpcg = nativ.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups + compliantLastIndexIncrement = function () { + var x = /^/g; + nativ.test.call(x, ""); + return !x.lastIndex; + }(), + hasNativeY = RegExp.prototype.sticky !== undefined, + nativeTokens = {}; + + // `nativeTokens` match native multicharacter metasequences only (including deprecated octals, + // excluding character classes) + nativeTokens[XRegExp.INSIDE_CLASS] = /^(?:\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S]))/; + nativeTokens[XRegExp.OUTSIDE_CLASS] = /^(?:\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u[\dA-Fa-f]{4}|c[A-Za-z]|[\s\S])|\(\?[:=!]|[?*+]\?|{\d+(?:,\d*)?}\??)/; + + + //--------------------------------- + // Public methods + //--------------------------------- + + // Lets you extend or change XRegExp syntax and create custom flags. This is used internally by + // the XRegExp library and can be used to create XRegExp plugins. This function is intended for + // users with advanced knowledge of JavaScript's regular expression syntax and behavior. It can + // be disabled by `XRegExp.freezeTokens` + XRegExp.addToken = function (regex, handler, scope, trigger) { + tokens.push({ + pattern: clone(regex, "g" + (hasNativeY ? "y" : "")), + handler: handler, + scope: scope || XRegExp.OUTSIDE_CLASS, + trigger: trigger || null + }); + }; + + // Accepts a pattern and flags; returns an extended `RegExp` object. If the pattern and flag + // combination has previously been cached, the cached copy is returned; otherwise the newly + // created regex is cached + XRegExp.cache = function (pattern, flags) { + var key = pattern + "/" + (flags || ""); + return XRegExp.cache[key] || (XRegExp.cache[key] = XRegExp(pattern, flags)); + }; + + // Accepts a `RegExp` instance; returns a copy with the `/g` flag set. The copy has a fresh + // `lastIndex` (set to zero). If you want to copy a regex without forcing the `global` + // property, use `XRegExp(regex)`. Do not use `RegExp(regex)` because it will not preserve + // special properties required for named capture + XRegExp.copyAsGlobal = function (regex) { + return clone(regex, "g"); + }; + + // Accepts a string; returns the string with regex metacharacters escaped. The returned string + // can safely be used at any point within a regex to match the provided literal string. Escaped + // characters are [ ] { } ( ) * + ? - . , \ ^ $ | # and whitespace + XRegExp.escape = function (str) { + return str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + }; + + // Accepts a string to search, regex to search with, position to start the search within the + // string (default: 0), and an optional Boolean indicating whether matches must start at-or- + // after the position or at the specified position only. This function ignores the `lastIndex` + // of the provided regex in its own handling, but updates the property for compatibility + XRegExp.execAt = function (str, regex, pos, anchored) { + var r2 = clone(regex, "g" + ((anchored && hasNativeY) ? "y" : "")), + match; + r2.lastIndex = pos = pos || 0; + match = r2.exec(str); // Run the altered `exec` (required for `lastIndex` fix, etc.) + if (anchored && match && match.index !== pos) + match = null; + if (regex.global) + regex.lastIndex = match ? r2.lastIndex : 0; + return match; + }; + + // Breaks the unrestorable link to XRegExp's private list of tokens, thereby preventing + // syntax and flag changes. Should be run after XRegExp and any plugins are loaded + XRegExp.freezeTokens = function () { + XRegExp.addToken = function () { + throw Error("can't run addToken after freezeTokens"); + }; + }; + + // Accepts any value; returns a Boolean indicating whether the argument is a `RegExp` object. + // Note that this is also `true` for regex literals and regexes created by the `XRegExp` + // constructor. This works correctly for variables created in another frame, when `instanceof` + // and `constructor` checks would fail to work as intended + XRegExp.isRegExp = function (o) { + return Object.prototype.toString.call(o) === "[object RegExp]"; + }; + + // Executes `callback` once per match within `str`. Provides a simpler and cleaner way to + // iterate over regex matches compared to the traditional approaches of subverting + // `String.prototype.replace` or repeatedly calling `exec` within a `while` loop + XRegExp.iterate = function (str, regex, callback, context) { + var r2 = clone(regex, "g"), + i = -1, match; + while (match = r2.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.) + if (regex.global) + regex.lastIndex = r2.lastIndex; // Doing this to follow expectations if `lastIndex` is checked within `callback` + callback.call(context, match, ++i, str, regex); + if (r2.lastIndex === match.index) + r2.lastIndex++; + } + if (regex.global) + regex.lastIndex = 0; + }; + + // Accepts a string and an array of regexes; returns the result of using each successive regex + // to search within the matches of the previous regex. The array of regexes can also contain + // objects with `regex` and `backref` properties, in which case the named or numbered back- + // references specified are passed forward to the next regex or returned. E.g.: + // var xregexpImgFileNames = XRegExp.matchChain(html, [ + // {regex: /]+)>/i, backref: 1}, // tag attributes + // {regex: XRegExp('(?ix) \\s src=" (? [^"]+ )'), backref: "src"}, // src attribute values + // {regex: XRegExp("^http://xregexp\\.com(/[^#?]+)", "i"), backref: 1}, // xregexp.com paths + // /[^\/]+$/ // filenames (strip directory paths) + // ]); + XRegExp.matchChain = function (str, chain) { + return function recurseChain (values, level) { + var item = chain[level].regex ? chain[level] : {regex: chain[level]}, + regex = clone(item.regex, "g"), + matches = [], i; + for (i = 0; i < values.length; i++) { + XRegExp.iterate(values[i], regex, function (match) { + matches.push(item.backref ? (match[item.backref] || "") : match[0]); + }); + } + return ((level === chain.length - 1) || !matches.length) ? + matches : recurseChain(matches, level + 1); + }([str], 0); + }; + + + //--------------------------------- + // New RegExp prototype methods + //--------------------------------- + + // Accepts a context object and arguments array; returns the result of calling `exec` with the + // first value in the arguments array. the context is ignored but is accepted for congruity + // with `Function.prototype.apply` + RegExp.prototype.apply = function (context, args) { + return this.exec(args[0]); + }; + + // Accepts a context object and string; returns the result of calling `exec` with the provided + // string. the context is ignored but is accepted for congruity with `Function.prototype.call` + RegExp.prototype.call = function (context, str) { + return this.exec(str); + }; + + + //--------------------------------- + // Overriden native methods + //--------------------------------- + + // Adds named capture support (with backreferences returned as `result.name`), and fixes two + // cross-browser issues per ES3: + // - Captured values for nonparticipating capturing groups should be returned as `undefined`, + // rather than the empty string. + // - `lastIndex` should not be incremented after zero-length matches. + RegExp.prototype.exec = function (str) { + var match, name, r2, origLastIndex; + if (!this.global) + origLastIndex = this.lastIndex; + match = nativ.exec.apply(this, arguments); + if (match) { + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) { + r2 = RegExp(this.source, nativ.replace.call(getNativeFlags(this), "g", "")); + // Using `str.slice(match.index)` rather than `match[0]` in case lookahead allowed + // matching due to characters outside the match + nativ.replace.call((str + "").slice(match.index), r2, function () { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) + match[i] = undefined; + } + }); + } + // Attach named capture properties + if (this._xregexp && this._xregexp.captureNames) { + for (var i = 1; i < match.length; i++) { + name = this._xregexp.captureNames[i - 1]; + if (name) + match[name] = match[i]; + } + } + // Fix browsers that increment `lastIndex` after zero-length matches + if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + } + if (!this.global) + this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows) + return match; + }; + + // Fix browser bugs in native method + RegExp.prototype.test = function (str) { + // Use the native `exec` to skip some processing overhead, even though the altered + // `exec` would take care of the `lastIndex` fixes + var match, origLastIndex; + if (!this.global) + origLastIndex = this.lastIndex; + match = nativ.exec.call(this, str); + // Fix browsers that increment `lastIndex` after zero-length matches + if (match && !compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index)) + this.lastIndex--; + if (!this.global) + this.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows) + return !!match; + }; + + // Adds named capture support and fixes browser bugs in native method + String.prototype.match = function (regex) { + if (!XRegExp.isRegExp(regex)) + regex = RegExp(regex); // Native `RegExp` + if (regex.global) { + var result = nativ.match.apply(this, arguments); + regex.lastIndex = 0; // Fix IE bug + return result; + } + return regex.exec(this); // Run the altered `exec` + }; + + // Adds support for `${n}` tokens for named and numbered backreferences in replacement text, + // and provides named backreferences to replacement functions as `arguments[0].name`. Also + // fixes cross-browser differences in replacement text syntax when performing a replacement + // using a nonregex search value, and the value of replacement regexes' `lastIndex` property + // during replacement iterations. Note that this doesn't support SpiderMonkey's proprietary + // third (`flags`) parameter + String.prototype.replace = function (search, replacement) { + var isRegex = XRegExp.isRegExp(search), + captureNames, result, str, origLastIndex; + + // There are too many combinations of search/replacement types/values and browser bugs that + // preclude passing to native `replace`, so don't try + //if (...) + // return nativ.replace.apply(this, arguments); + + if (isRegex) { + if (search._xregexp) + captureNames = search._xregexp.captureNames; // Array or `null` + if (!search.global) + origLastIndex = search.lastIndex; + } else { + search = search + ""; // Type conversion + } + + if (Object.prototype.toString.call(replacement) === "[object Function]") { + result = nativ.replace.call(this + "", search, function () { + if (captureNames) { + // Change the `arguments[0]` string primitive to a String object which can store properties + arguments[0] = new String(arguments[0]); + // Store named backreferences on `arguments[0]` + for (var i = 0; i < captureNames.length; i++) { + if (captureNames[i]) + arguments[0][captureNames[i]] = arguments[i + 1]; + } + } + // Update `lastIndex` before calling `replacement` (fix browsers) + if (isRegex && search.global) + search.lastIndex = arguments[arguments.length - 2] + arguments[0].length; + return replacement.apply(null, arguments); + }); + } else { + str = this + ""; // Type conversion, so `args[args.length - 1]` will be a string (given nonstring `this`) + result = nativ.replace.call(str, search, function () { + var args = arguments; // Keep this function's `arguments` available through closure + return nativ.replace.call(replacement + "", replacementToken, function ($0, $1, $2) { + // Numbered backreference (without delimiters) or special variable + if ($1) { + switch ($1) { + case "$": return "$"; + case "&": return args[0]; + case "`": return args[args.length - 1].slice(0, args[args.length - 2]); + case "'": return args[args.length - 1].slice(args[args.length - 2] + args[0].length); + // Numbered backreference + default: + // What does "$10" mean? + // - Backreference 10, if 10 or more capturing groups exist + // - Backreference 1 followed by "0", if 1-9 capturing groups exist + // - Otherwise, it's the string "$10" + // Also note: + // - Backreferences cannot be more than two digits (enforced by `replacementToken`) + // - "$01" is equivalent to "$1" if a capturing group exists, otherwise it's the string "$01" + // - There is no "$0" token ("$&" is the entire match) + var literalNumbers = ""; + $1 = +$1; // Type conversion; drop leading zero + if (!$1) // `$1` was "0" or "00" + return $0; + while ($1 > args.length - 3) { + literalNumbers = String.prototype.slice.call($1, -1) + literalNumbers; + $1 = Math.floor($1 / 10); // Drop the last digit + } + return ($1 ? args[$1] || "" : "$") + literalNumbers; + } + // Named backreference or delimited numbered backreference + } else { + // What does "${n}" mean? + // - Backreference to numbered capture n. Two differences from "$n": + // - n can be more than two digits + // - Backreference 0 is allowed, and is the entire match + // - Backreference to named capture n, if it exists and is not a number overridden by numbered capture + // - Otherwise, it's the string "${n}" + var n = +$2; // Type conversion; drop leading zeros + if (n <= args.length - 3) + return args[n]; + n = captureNames ? indexOf(captureNames, $2) : -1; + return n > -1 ? args[n + 1] : $0; + } + }); + }); + } + + if (isRegex) { + if (search.global) + search.lastIndex = 0; // Fix IE, Safari bug (last tested IE 9.0.5, Safari 5.1.2 on Windows) + else + search.lastIndex = origLastIndex; // Fix IE, Opera bug (last tested IE 9.0.5, Opera 11.61 on Windows) + } + + return result; + }; + + // A consistent cross-browser, ES3 compliant `split` + String.prototype.split = function (s /* separator */, limit) { + // If separator `s` is not a regex, use the native `split` + if (!XRegExp.isRegExp(s)) + return nativ.split.apply(this, arguments); + + var str = this + "", // Type conversion + output = [], + lastLastIndex = 0, + match, lastLength; + + // Behavior for `limit`: if it's... + // - `undefined`: No limit + // - `NaN` or zero: Return an empty array + // - A positive number: Use `Math.floor(limit)` + // - A negative number: No limit + // - Other: Type-convert, then use the above rules + if (limit === undefined || +limit < 0) { + limit = Infinity; + } else { + limit = Math.floor(+limit); + if (!limit) + return []; + } + + // This is required if not `s.global`, and it avoids needing to set `s.lastIndex` to zero + // and restore it to its original value when we're done using the regex + s = XRegExp.copyAsGlobal(s); + + while (match = s.exec(str)) { // Run the altered `exec` (required for `lastIndex` fix, etc.) + if (s.lastIndex > lastLastIndex) { + output.push(str.slice(lastLastIndex, match.index)); + + if (match.length > 1 && match.index < str.length) + Array.prototype.push.apply(output, match.slice(1)); + + lastLength = match[0].length; + lastLastIndex = s.lastIndex; + + if (output.length >= limit) + break; + } + + if (s.lastIndex === match.index) + s.lastIndex++; + } + + if (lastLastIndex === str.length) { + if (!nativ.test.call(s, "") || lastLength) + output.push(""); + } else { + output.push(str.slice(lastLastIndex)); + } + + return output.length > limit ? output.slice(0, limit) : output; + }; + + + //--------------------------------- + // Private helper functions + //--------------------------------- + + // Supporting function for `XRegExp`, `XRegExp.copyAsGlobal`, etc. Returns a copy of a `RegExp` + // instance with a fresh `lastIndex` (set to zero), preserving properties required for named + // capture. Also allows adding new flags in the process of copying the regex + function clone (regex, additionalFlags) { + if (!XRegExp.isRegExp(regex)) + throw TypeError("type RegExp expected"); + var x = regex._xregexp; + regex = XRegExp(regex.source, getNativeFlags(regex) + (additionalFlags || "")); + if (x) { + regex._xregexp = { + source: x.source, + captureNames: x.captureNames ? x.captureNames.slice(0) : null + }; + } + return regex; + } + + function getNativeFlags (regex) { + return (regex.global ? "g" : "") + + (regex.ignoreCase ? "i" : "") + + (regex.multiline ? "m" : "") + + (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3 + (regex.sticky ? "y" : ""); + } + + function runTokens (pattern, index, scope, context) { + var i = tokens.length, + result, match, t; + // Protect against constructing XRegExps within token handler and trigger functions + isInsideConstructor = true; + // Must reset `isInsideConstructor`, even if a `trigger` or `handler` throws + try { + while (i--) { // Run in reverse order + t = tokens[i]; + if ((scope & t.scope) && (!t.trigger || t.trigger.call(context))) { + t.pattern.lastIndex = index; + match = t.pattern.exec(pattern); // Running the altered `exec` here allows use of named backreferences, etc. + if (match && match.index === index) { + result = { + output: t.handler.call(context, match, scope), + match: match + }; + break; + } + } + } + } catch (err) { + throw err; + } finally { + isInsideConstructor = false; + } + return result; + } + + function indexOf (array, item, from) { + if (Array.prototype.indexOf) // Use the native array method if available + return array.indexOf(item, from); + for (var i = from || 0; i < array.length; i++) { + if (array[i] === item) + return i; + } + return -1; + } + + + //--------------------------------- + // Built-in tokens + //--------------------------------- + + // Augment XRegExp's regular expression syntax and flags. Note that when adding tokens, the + // third (`scope`) argument defaults to `XRegExp.OUTSIDE_CLASS` + + // Comment pattern: (?# ) + XRegExp.addToken( + /\(\?#[^)]*\)/, + function (match) { + // Keep tokens separated unless the following token is a quantifier + return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)"; + } + ); + + // Capturing group (match the opening parenthesis only). + // Required for support of named capturing groups + XRegExp.addToken( + /\((?!\?)/, + function () { + this.captureNames.push(null); + return "("; + } + ); + + // Named capturing group (match the opening delimiter only): (? + XRegExp.addToken( + /\(\?<([$\w]+)>/, + function (match) { + this.captureNames.push(match[1]); + this.hasNamedCapture = true; + return "("; + } + ); + + // Named backreference: \k + XRegExp.addToken( + /\\k<([\w$]+)>/, + function (match) { + var index = indexOf(this.captureNames, match[1]); + // Keep backreferences separate from subsequent literal numbers. Preserve back- + // references to named groups that are undefined at this point as literal strings + return index > -1 ? + "\\" + (index + 1) + (isNaN(match.input.charAt(match.index + match[0].length)) ? "" : "(?:)") : + match[0]; + } + ); + + // Empty character class: [] or [^] + XRegExp.addToken( + /\[\^?]/, + function (match) { + // For cross-browser compatibility with ES3, convert [] to \b\B and [^] to [\s\S]. + // (?!) should work like \b\B, but is unreliable in Firefox + return match[0] === "[]" ? "\\b\\B" : "[\\s\\S]"; + } + ); + + // Mode modifier at the start of the pattern only, with any combination of flags imsx: (?imsx) + // Does not support x(?i), (?-i), (?i-m), (?i: ), (?i)(?m), etc. + XRegExp.addToken( + /^\(\?([imsx]+)\)/, + function (match) { + this.setFlag(match[1]); + return ""; + } + ); + + // Whitespace and comments, in free-spacing (aka extended) mode only + XRegExp.addToken( + /(?:\s+|#.*)+/, + function (match) { + // Keep tokens separated unless the following token is a quantifier + return nativ.test.call(quantifier, match.input.slice(match.index + match[0].length)) ? "" : "(?:)"; + }, + XRegExp.OUTSIDE_CLASS, + function () {return this.hasFlag("x");} + ); + + // Dot, in dotall (aka singleline) mode only + XRegExp.addToken( + /\./, + function () {return "[\\s\\S]";}, + XRegExp.OUTSIDE_CLASS, + function () {return this.hasFlag("s");} + ); + + + //--------------------------------- + // Backward compatibility + //--------------------------------- + + // Uncomment the following block for compatibility with XRegExp 1.0-1.2: + /* + XRegExp.matchWithinChain = XRegExp.matchChain; + RegExp.prototype.addFlags = function (s) {return clone(this, s);}; + RegExp.prototype.execAll = function (s) {var r = []; XRegExp.iterate(s, this, function (m) {r.push(m);}); return r;}; + RegExp.prototype.forEachExec = function (s, f, c) {return XRegExp.iterate(s, this, f, c);}; + RegExp.prototype.validate = function (s) {var r = RegExp("^(?:" + this.source + ")$(?!\\s)", getNativeFlags(this)); if (this.global) this.lastIndex = 0; return s.search(r) === 0;}; + */ + +})(); + diff --git a/plugin/PHPMailer/examples/scripts/shAutoloader.js b/plugin/PHPMailer/examples/scripts/shAutoloader.js new file mode 100644 index 000000000..9f5942ee2 --- /dev/null +++ b/plugin/PHPMailer/examples/scripts/shAutoloader.js @@ -0,0 +1,122 @@ +(function() { + +var sh = SyntaxHighlighter; + +/** + * Provides functionality to dynamically load only the brushes that a needed to render the current page. + * + * There are two syntaxes that autoload understands. For example: + * + * SyntaxHighlighter.autoloader( + * [ 'applescript', 'Scripts/shBrushAppleScript.js' ], + * [ 'actionscript3', 'as3', 'Scripts/shBrushAS3.js' ] + * ); + * + * or a more easily comprehendable one: + * + * SyntaxHighlighter.autoloader( + * 'applescript Scripts/shBrushAppleScript.js', + * 'actionscript3 as3 Scripts/shBrushAS3.js' + * ); + */ +sh.autoloader = function() +{ + var list = arguments, + elements = sh.findElements(), + brushes = {}, + scripts = {}, + all = SyntaxHighlighter.all, + allCalled = false, + allParams = null, + i + ; + + SyntaxHighlighter.all = function(params) + { + allParams = params; + allCalled = true; + }; + + function addBrush(aliases, url) + { + for (var i = 0; i < aliases.length; i++) + brushes[aliases[i]] = url; + }; + + function getAliases(item) + { + return item.pop + ? item + : item.split(/\s+/) + ; + } + + // create table of aliases and script urls + for (i = 0; i < list.length; i++) + { + var aliases = getAliases(list[i]), + url = aliases.pop() + ; + + addBrush(aliases, url); + } + + // dynamically add - - -
-
-
-The http://phpmailer.codeworxtech.com/ website now carries a few -advertisements through the Google Adsense network to help offset -some of our costs.
-Thanks ....
-
-

My name is Andy Prevost, AKA "codeworxtech".
-www.codeworxtech.com for more information.
-

-

WHY USE OUR TOOLS & WHAT'S IN IT FOR YOU?

-

A valid question. We're developers too. We've been writing software, primarily for the internet, for more than 15 years. Along the way, there are two major things that had tremendous impact of our company: PHP and Open Source. PHP is without doubt the most popular platform for the internet. There has been more progress in this area of technology because of Open Source software than in any other IT segment. We have used many open source tools, some as learning tools, some as components in projects we were working on. To us, it's not about popularity ... we're committed to robust, stable, and efficient tools you can use to get your projects in your user's hands quickly. So the shorter answer: what's in it for you? rapid development and rapid deployment without fuss and with straight forward open source licensing.

-

Now, the introductions:

-

Our company, Worx International Inc., is the publisher of several Open Source applications and developer tools as well as several commercial PHP applications. The Open Source applications are ttCMS and DCP Portal. The Open Source developer tools include QuickComponents (QuickSkin and QuickCache) and now PHPMailer. -We have staff and offices in the United States, Caribbean, the Middle -East, and our primary development center in Canada. Our company is represented by -agents and resellers globally.

-

Worx International Inc. is at the forefront of developing PHP applications. Our staff are all Zend Certified university educated and experts at object oriented programming. While Worx International Inc. can handle any project from trouble shooting programs written by others all the way to finished mission-critical applications, we specialize in taking projects from inception all the way through to implementation - on budget, and on time. If you need help with your projects, we're the team to get it done right at a reasonable price.

-

Over the years, there have been a number of tools that have been constant favorites in all of our projects. We have become the project administrators for most of these tools.

-

Our developer tools are all Open Source. Here's a brief description:

-
    -
  • PHPMailer. Originally authored by Brent Matzelle, PHPMailer is the leading "email transfer class" for PHP. PHPMailer is downloaded more than 18000 times each and every month by developers looking for a stable, simple email solution. We used it ourselves for years as our favorite tool. It's always been small (the entire footprint is around 100 Kb), stable, and as complete a solution as you can find. Other tools are nowhere near as simple. And more importantly, most of our applications (including PHPMailer) is implemented in a smaller footprint than one competing email class. Our thanks to Brent Matzelle for this superb tool - our commitment is to keep it lean, keep it focused, and compliant with standards. Visit the PHPMailer website at - http://phpmailer.codeworxtech.com/.
    - Please note: all of our focus is now on the PHPMailer for PHP5.
    - PS. While you are at it, please visit our sponsor's sites, click on their ads. - It helps offset some of our costs.
    - Want to help? We're looking for progressive developers to join our team of volunteer professionals working on PHPMailer. Our entire focus is on PHPMailer for PHP5, and our next major task is to enhance our - exception/error handling with PHP 5's object oriented try/throw/catch mechanisms. If you are interested, let us know.
    -
    -
  • -
  • QuickCache. Originally authored by Jean Pierre Deckers as jpCache, QuickCache is an HTTP OpCode caching strategy that works on your entire site with only one line of code at the top of your script. The cached pages can be stored as files or as database objects. The benefits are absolutely astounding: bandwidth savings of up to 80% and screen display times increased by 8 - 10x. Visit the QuickCache website at - http://quickcache.codeworxtech.com/.
    -
    -
  • -
  • QuickSkin. Originally authored by Philipp v. Criegern and named "SmartTemplate". The project was taken over by Manuel 'EndelWar' Dalla Lana and now by "codeworxtech". QuickSkin is one of the truly outstanding templating engines available, but has always been confused with Smarty Templating Engine. QuickSkin is even more relevant today than when it was launched. It's a small footprint with big impact on your projects. It features a built in caching technology, token based substitution, and works on the concept of one single HTML file as the template. The HTML template file can contain variable information making it one small powerful tool for your developer tool kit. Visit the QuickSkin website at - http://quickskin.codeworxtech.com/.
    -
    -
  • -
-

We're committed to PHP and to the Open Source community.

-

Opportunities with Worx International Inc.:

-
    -
  • Resellers/Agents: We're always interested in talking with companies that -want to represent -Worx International Inc. in their markets. We also have private label programs for our commercial products (in certain circumstances).
  • -
  • Programmers/Developers: We are usually fully staffed, however, if you would like to be considered for a career with -Worx International Inc., we would be pleased to hear from you.
    -A few things to note:
    -
      -
    • experience level does not matter: from fresh out of college to multi-year experience - it's your - creative mind and a positive attitude we want
    • -
    • if you contact us looking for employment, include a cover letter, indicate what type of work/career you are looking for and expected compensation
    • -
    • if you are representing someone else looking for work, do not contact us. We have an exclusive relationship with a recruiting partner already and not interested in altering the arrangement. We will not hire your candidate under any circumstances unless they wish to approach us individually.
    • -
    • any contact that ignores any of these points will be discarded
    • -
  • -
  • Affiliates/Partnerships: We are interested in partnering with other firms who are leaders in their field. We clearly understand that successful companies are built on successful relationships in all industries world-wide. We currently have innovative relationships throughout the world that are mutually beneficial. Drop us a line and let's talk.
  • -
-Regards,
-Andy Prevost (aka, codeworxtech)
-codeworxtech@users.sourceforge.net
-
-We now also offer website design. hosting, and remote forms processing. Visit WorxStudio.com for more information.
-
-
- - diff --git a/plugin/PHPMailer_v2.0.4/docs/extending.html b/plugin/PHPMailer_v2.0.4/docs/extending.html deleted file mode 100644 index f7c3200af..000000000 --- a/plugin/PHPMailer_v2.0.4/docs/extending.html +++ /dev/null @@ -1,148 +0,0 @@ - - -Examples using phpmailer - - - - -

Examples using phpmailer

- -

1. Advanced Example

-

- -This demonstrates sending out multiple email messages with binary attachments -from a MySQL database with multipart/alternative support.

- - - - -
-
-require("class.phpmailer.php");
-
-$mail = new phpmailer();
-
-$mail->From     = "list@example.com";
-$mail->FromName = "List manager";
-$mail->Host     = "smtp1.example.com;smtp2.example.com";
-$mail->Mailer   = "smtp";
-
-@MYSQL_CONNECT("localhost","root","password");
-@mysql_select_db("my_company");
-$query ="SELECT full_name, email,photoFROM employeeWHEREid=$id";
-$result=@MYSQL_QUERY($query);
-
-while ($row = mysql_fetch_array ($result))
-{
-    // HTML body
-    $body  = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
-    $body .= "<i>Your</i> personal photograph to this message.<p>";
-    $body .= "Sincerely, <br>";
-    $body .= "phpmailer List manager";
-
-    // Plain text body (for mail clients that cannot read HTML)
-    $text_body  = "Hello " . $row["full_name"] . ", \n\n";
-    $text_body .= "Your personal photograph to this message.\n\n";
-    $text_body .= "Sincerely, \n";
-    $text_body .= "phpmailer List manager";
-
-    $mail->Body    = $body;
-    $mail->AltBody = $text_body;
-    $mail->AddAddress($row["email"], $row["full_name"]);
-    $mail->AddStringAttachment($row["photo"], "YourPhoto.jpg");
-
-    if(!$mail->Send())
-        echo "There has been a mail error sending to " . $row["email"] . "<br>";
-
-    // Clear all addresses and attachments for next loop
-    $mail->ClearAddresses();
-    $mail->ClearAttachments();
-}
-
-
-

- -

2. Extending phpmailer

-

- -Extending classes with inheritance is one of the most -powerful features of object-oriented -programming. It allows you to make changes to the -original class for your -own personal use without hacking the original -classes. Plus, it is very -easy to do. I've provided an example: - -

-Here's a class that extends the phpmailer class and sets the defaults -for the particular site:
-PHP include file: mail.inc.php -

- - - - - -
-
-require("class.phpmailer.php");
-
-class my_phpmailer extends phpmailer {
-    // Set default variables for all new objects
-    var $From     = "from@example.com";
-    var $FromName = "Mailer";
-    var $Host     = "smtp1.example.com;smtp2.example.com";
-    var $Mailer   = "smtp";                         // Alternative to IsSMTP()
-    var $WordWrap = 75;
-
-    // Replace the default error_handler
-    function error_handler($msg) {
-        print("My Site Error");
-        print("Description:");
-        printf("%s", $msg);
-        exit;
-    }
-
-    // Create an additional function
-    function do_something($something) {
-        // Place your new code here
-    }
-}
-
-
- -Now here's a normal PHP page in the site, which will have all the defaults set -above:
-Normal PHP file: mail_test.php -

- - - - - -
-
-require("mail.inc.php");
-
-// Instantiate your new class
-$mail = new my_phpmailer;
-
-// Now you only need to add the necessary stuff
-$mail->AddAddress("josh@example.com", "Josh Adams");
-$mail->Subject = "Here is the subject";
-$mail->Body    = "This is the message body";
-$mail->AddAttachment("c:/temp/11-10-00.zip", "new_name.zip");  // optional name
-
-if(!$mail->Send())
-{
-   echo "There was an error sending the message";
-   exit;
-}
-
-echo "Message was sent successfully";
-
-
-

- - - diff --git a/plugin/PHPMailer_v2.0.4/docs/faq.html b/plugin/PHPMailer_v2.0.4/docs/faq.html deleted file mode 100644 index 54ac18370..000000000 --- a/plugin/PHPMailer_v2.0.4/docs/faq.html +++ /dev/null @@ -1,67 +0,0 @@ - - -PHPMailer FAQ - - - -
-
-

PHPMailer FAQ

-
    - -
  • Q: I'm using the SMTP mailer and I keep on getting a timeout message - well before the X seconds I set it for. What gives?
    - A: PHP versions 4.0.4pl1 and earlier have a bug in which sockets timeout - early. You can fix this by re-compiling PHP 4.0.4pl1 with this fix: - timeoutfix.diff. Otherwise you can wait for the new PHP release.

  • - -
  • Q: I am concerned that using include files will take up too much - processing time on my computer. How can I make it run faster?
    - A: PHP by itself is very fast. Much faster than ASP or JSP running on - the same type of server. This is because it has very little overhead compared - to its competitors and it pre-compiles all of - its code before it runs each script (in PHP4). However, all of - this compiling and re-compiling can take up a lot of valuable - computer resources. However, there are programs out there that compile - PHP code and store it in memory (or on mmaped files) to reduce the - processing immensely. Two of these: APC - (Alternative PHP Cache) and Afterburner - (Win32 download) - are excellent free tools that do just this. If you have the money - you might also try Zend Cache, it is - even faster than the open source varieties. All of these tools make your - scripts run faster while also reducing the load on your server. I have tried - them myself and they are quite stable too.

  • - -
  • Q: What mailer gives me the best performance?
    - A: On a single machine the sendmail (or Qmail) is fastest overall. - Next fastest is mail() to give you the best performance. Both do not have the overhead of SMTP. - If you have you have your mail server on a another machine then - SMTP is your only option, but you do get the benefit of redundant mail servers.
    - If you are running a mailing list with thousands of names, the fastest mailers in order are: SMTP, sendmail (or Qmail), mail().

  • - -
  • Q: When I try to attach a file with on my server I get a - "Could not find {file} on filesystem error". Why is this?
    - A: If you are using a Unix machine this is probably because the user - running your web server does not have read access to the directory in question. If you are using Windows, - then the problem probably is that you have used single backslashes to denote directories (\). - A single backslash has a special meaning to PHP so these are not - valid. Instead use double backslashes ("\\") or a single forward - slash ("/").

  • - -
- -
-
- - - diff --git a/plugin/PHPMailer_v2.0.4/docs/phpmailer_sm.gif b/plugin/PHPMailer_v2.0.4/docs/phpmailer_sm.gif deleted file mode 100644 index 0244d2990..000000000 Binary files a/plugin/PHPMailer_v2.0.4/docs/phpmailer_sm.gif and /dev/null differ diff --git a/plugin/PHPMailer_v2.0.4/docs/use_gmail.txt b/plugin/PHPMailer_v2.0.4/docs/use_gmail.txt deleted file mode 100644 index 3669f5d23..000000000 --- a/plugin/PHPMailer_v2.0.4/docs/use_gmail.txt +++ /dev/null @@ -1,45 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPSecure = "ssl"; // sets the prefix to the servier -$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server -$mail->Port = 465; // set the SMTP port - -$mail->Username = "yourname@gmail.com"; // GMAIL username -$mail->Password = "password"; // GMAIL password - -$mail->From = "replyto@yourdomain.com"; -$mail->FromName = "Webmaster"; -$mail->Subject = "This is the subject"; -$mail->AltBody = "This is the body when user views in plain text format"; //Text Body -$mail->WordWrap = 50; // set word wrap - -$mail->MsgHTML($body); - -$mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); - -$mail->AddAttachment("/path/to/file.zip"); // attachment -$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment - -$mail->AddAddress("username@domain.com","First Last"); - -$mail->IsHTML(true); // send as HTML - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message has been sent"; -} - -?> diff --git a/plugin/PHPMailer_v2.0.4/examples/contents.html b/plugin/PHPMailer_v2.0.4/examples/contents.html deleted file mode 100644 index 70c7e3070..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/contents.html +++ /dev/null @@ -1,12 +0,0 @@ - -
-

-
- This is a test of PHPMailer v2.0.0 rc1.
-
-This particular example uses HTML, with a <div> tag and inline
-styles.
-
-Also note the use of the PHPMailer at the top with no specific code to handle -including it in the body of the email.
- diff --git a/plugin/PHPMailer_v2.0.4/examples/images/bkgrnd.gif b/plugin/PHPMailer_v2.0.4/examples/images/bkgrnd.gif deleted file mode 100644 index bc89624c0..000000000 Binary files a/plugin/PHPMailer_v2.0.4/examples/images/bkgrnd.gif and /dev/null differ diff --git a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.gif b/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.gif deleted file mode 100644 index 5e269714e..000000000 Binary files a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.gif and /dev/null differ diff --git a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.png b/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.png deleted file mode 100644 index abe0101f3..000000000 Binary files a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer.png and /dev/null differ diff --git a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer_mini.gif b/plugin/PHPMailer_v2.0.4/examples/images/phpmailer_mini.gif deleted file mode 100644 index dc7d7827c..000000000 Binary files a/plugin/PHPMailer_v2.0.4/examples/images/phpmailer_mini.gif and /dev/null differ diff --git a/plugin/PHPMailer_v2.0.4/examples/index.html b/plugin/PHPMailer_v2.0.4/examples/index.html deleted file mode 100644 index d0a8b9d95..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/index.html +++ /dev/null @@ -1,73 +0,0 @@ -

The example file "test_mail.php" contents include:

-
- -<?php
-
-include_once('../class.phpmailer.php');
-
-$mail = new PHPMailer();
-
-$body = $mail->getFile('contents.html');
-
-$body = eregi_replace("[\]",'',$body);
-$subject = eregi_replace("[\]",'',$subject);
-
-$mail->From = "name@yourdomain.com";
-$mail->FromName = "First Last";
-
-$mail->Subject = "PHPMailer Test Subject";
-
-$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
-
-$mail->MsgHTML($body);
-
-$mail->AddAddress("whoto@otherdomain.com", "John Doe");
-
-if(!$mail->Send()) {
- echo 'Failed to send mail';
-} else {
- echo 'Mail sent';
-}
-
-?> -
-
-
-Although you could use full compabitility with PHPMailer 1.7.3, this example -shows how to use the new features. If you view 'contents.html', you will note -that there is a background image used in the <body tag as well as an image used -with a regular <img tag. Here's what the HTML file looks like:
-
-
- -<body background="images/bkgrnd.gif" style="margin: 0px;">
-<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
-<div align="center"><img src="images/phpmailer.gif" style="height: 90px; width: 340px"></div><br>
-<br>
- This is a test of PHPMailer v2.0.0 rc1.<br>
-<br>
-This particular example uses <strong>HTML</strong>, with a <div> tag and inline<br>
-styles.<br>
-<br>
-Also note the use of the PHPMailer at the top with no specific code to handle
-including it in the body of the email.</div>
-</body>
-
-
-
-A few things to notice in the PHP script that generates the email: -
    -
  • the use of $mail->AltBody is completely optional. If not used, PHPMailer - will use the HTML text with htmlentities().
  • -
  • the background= and <img src= images were processed without any directives - or methods from the PHP script
  • -
  • there is no specific code to define the image type ... that is handled - automatically by PHPMailer when it parses the images
  • -
  • we are using a new class method '$mail->MsgHTML($body)' ... that is what will handle the parsing of the images and creating the AltBody text
  • -
-

Of course, you can still use PHPMailer the same way you have in the past. -That provides full compatibility with all existing scripts, while new scripts -can take advantage of the new features.

-

Modify test_mail.php now with your own email address and try it out.

-To see what the email SHOULD look like in your HTML compatible email viewer: click here
- diff --git a/plugin/PHPMailer_v2.0.4/examples/pop3_before_smtp_test.php b/plugin/PHPMailer_v2.0.4/examples/pop3_before_smtp_test.php deleted file mode 100644 index 794b2a267..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/pop3_before_smtp_test.php +++ /dev/null @@ -1,39 +0,0 @@ - - -POP before SMTP Test - - - - -
-Authorise('pop3.example.com', 110, 30, 'mailer', 'password', 1);
-
-  $mail = new PHPMailer();
-
-  $mail->IsSMTP();
-  $mail->SMTPDebug = 2;
-  $mail->IsHTML(false);
-
-  $mail->Host     = 'relay.example.com';
-
-  $mail->From     = 'mailer@example.com';
-  $mail->FromName = 'Example Mailer';
-
-  $mail->Subject  =  'My subject';
-  $mail->Body     =  'Hello world';
-  $mail->AddAddress('name@anydomain.com', 'First Last');
-
-  if (!$mail->Send())
-  {
-    echo $mail->ErrorInfo;
-  }
-?>
-
- - - diff --git a/plugin/PHPMailer_v2.0.4/examples/test_gmail.php b/plugin/PHPMailer_v2.0.4/examples/test_gmail.php deleted file mode 100644 index 9b951f869..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/test_gmail.php +++ /dev/null @@ -1,45 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); -$mail->SMTPAuth = true; // enable SMTP authentication -$mail->SMTPSecure = "ssl"; // sets the prefix to the servier -$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server -$mail->Port = 465; // set the SMTP port for the GMAIL server - -$mail->Username = "yourusername@gmail.com"; // GMAIL username -$mail->Password = "yourpassword"; // GMAIL password - -$mail->AddReplyTo("yourusername@gmail.com","First Last"); - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via gmail"; - -//$mail->Body = "Hi,
This is the HTML BODY
"; //HTML Body -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test -$mail->WordWrap = 50; // set word wrap - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -$mail->IsHTML(true); // send as HTML - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/plugin/PHPMailer_v2.0.4/examples/test_mail.php b/plugin/PHPMailer_v2.0.4/examples/test_mail.php deleted file mode 100644 index e87056e91..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/test_mail.php +++ /dev/null @@ -1,29 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via mail()"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/plugin/PHPMailer_v2.0.4/examples/test_sendmail.php b/plugin/PHPMailer_v2.0.4/examples/test_sendmail.php deleted file mode 100644 index f0311665e..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/test_sendmail.php +++ /dev/null @@ -1,30 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSendmail(); // telling the class to use SendMail transport - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via smtp"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/plugin/PHPMailer_v2.0.4/examples/test_smtp.php b/plugin/PHPMailer_v2.0.4/examples/test_smtp.php deleted file mode 100644 index 189f8daa1..000000000 --- a/plugin/PHPMailer_v2.0.4/examples/test_smtp.php +++ /dev/null @@ -1,33 +0,0 @@ -getFile('contents.html'); -$body = eregi_replace("[\]",'',$body); - -$mail->IsSMTP(); // telling the class to use SMTP -$mail->Host = "mail.yourdomain.com"; // SMTP server - -$mail->From = "name@yourdomain.com"; -$mail->FromName = "First Last"; - -$mail->Subject = "PHPMailer Test Subject via smtp"; - -$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test - -$mail->MsgHTML($body); - -$mail->AddAddress("whoto@otherdomain.com", "John Doe"); - -$mail->AddAttachment("images/phpmailer.gif"); // attachment - -if(!$mail->Send()) { - echo "Mailer Error: " . $mail->ErrorInfo; -} else { - echo "Message sent!"; -} - -?> diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ar.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ar.php deleted file mode 100644 index c7f343ae2..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ar.php +++ /dev/null @@ -1,26 +0,0 @@ - - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG['provide_address'] = 'You must provide at least one ' . - 'recipient email address.'; -$PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.'; -$PHPMAILER_LANG['execute'] = 'لم أستطع تنفيذ : '; -$PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.'; -$PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.'; -$PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : '; -$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' . - 'فشل في الارسال لكل من : '; -$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: لم يتم قبول المعلومات .'; -$PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.'; -$PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للملف: '; -$PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: '; -$PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: '; -$PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: '; -$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; -?> \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-br.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-br.php deleted file mode 100644 index dece2256a..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-br.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ca.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ca.php deleted file mode 100644 index dfc8370ef..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ca.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ch.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ch.php deleted file mode 100644 index 5251402b0..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ch.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-cz.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-cz.php deleted file mode 100644 index 80b4eea1d..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-cz.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-en.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-en.php deleted file mode 100644 index 41906b1e7..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-en.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-es.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-es.php deleted file mode 100644 index b0d7d22e4..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-es.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-fr.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-fr.php deleted file mode 100644 index b40ec215d..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-fr.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-hu.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-hu.php deleted file mode 100644 index 5fac38a09..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-hu.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-it.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-it.php deleted file mode 100644 index 76a9f3a59..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-it.php +++ /dev/null @@ -1,26 +0,0 @@ -*/ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente'; -$PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato'; -$PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: '; -$PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail'; -$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.'; -$PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: '; -$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi'. - 'destinatari hanno generato errore: '; -$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Data non accettati dal'. - 'server.'; -$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.'; -$PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: '; -$PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: '; -$PHPMAILER_LANG['encoding'] = 'Encoding set dei caratteri sconosciuto: '; -$PHPMAILER_LANG['signing'] = 'Signing Error: '; -$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; -?> \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ja.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ja.php deleted file mode 100644 index 6848ca380..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-ja.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-nl.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-nl.php deleted file mode 100644 index 269b1522a..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-nl.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-no.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-no.php deleted file mode 100644 index 184d8857f..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-no.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-pl.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-pl.php deleted file mode 100644 index bbc9cc9a8..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-pl.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-tr.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-tr.php deleted file mode 100644 index 99c5ac421..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-tr.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh.php deleted file mode 100644 index 31c10faae..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -$PHPMAILER_LANG = array(); -$PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。'; -$PHPMAILER_LANG['mailer_not_supported'] = '發信客戶端不被支持。'; -$PHPMAILER_LANG['execute'] = '無法執行:'; -$PHPMAILER_LANG['instantiate'] = '未知函數調用。'; -$PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登錄失敗。'; -$PHPMAILER_LANG['from_failed'] = '發送地址錯誤:'; -$PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:'; -$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。'; -$PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。'; -$PHPMAILER_LANG['file_access'] = '無法訪問文件:'; -$PHPMAILER_LANG['file_open'] = '文件錯誤:無法打開文件:'; -$PHPMAILER_LANG['encoding'] = '未知編碼: '; -$PHPMAILER_LANG['signing'] = 'Signing Error: '; -$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; -?> \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh_cn.php b/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh_cn.php deleted file mode 100644 index b01d806f0..000000000 --- a/plugin/PHPMailer_v2.0.4/language/phpmailer.lang-zh_cn.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - -$PHPMAILER_LANG = array(); - -$PHPMAILER_LANG["provide_address"] = '必须提供至少一个收件人地址。'; -$PHPMAILER_LANG["mailer_not_supported"] = '发信客户端不被支持。'; -$PHPMAILER_LANG["execute"] = '无法执行:'; -$PHPMAILER_LANG["instantiate"] = '未知函数调用。'; -$PHPMAILER_LANG["authenticate"] = 'SMTP 错误:登录失败。'; -$PHPMAILER_LANG["from_failed"] = '发送地址错误:'; -$PHPMAILER_LANG["recipients_failed"] = 'SMTP 错误:收件人地址错误:'; -$PHPMAILER_LANG["data_not_accepted"] = 'SMTP 错误:数据不被接受。'; -$PHPMAILER_LANG["connect_host"] = 'SMTP 错误:无法连接到 SMTP 主机。'; -$PHPMAILER_LANG["file_access"] = '无法访问文件:'; -$PHPMAILER_LANG["file_open"] = '文件错误:无法打开文件:'; -$PHPMAILER_LANG["encoding"] = '未知编码: '; -$PHPMAILER_LANG["signing"] = 'Signing Error: '; -$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; -?> \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/PHPMailer.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/PHPMailer.html deleted file mode 100644 index f892db222..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/PHPMailer.html +++ /dev/null @@ -1,2042 +0,0 @@ - - - - - - Docs For Class PHPMailer - - - - -
-

Class PHPMailer

- - -
-
Description
- -
- -

- Located in /class.phpmailer.php (line 34) -

- - -

-	
-			
-
- - - - -
-
Variable Summary
- -
-
-
- string - $AltBody -
-
- mixed - $attachment -
-
- mixed - $bcc -
-
- string - $Body -
-
- mixed - $boundary -
-
- mixed - $cc -
-
- string - $CharSet -
-
- string - $ConfirmReadingTo -
-
- string - $ContentType -
-
- mixed - $CustomHeader -
-
- string - $Encoding -
-
- string - $ErrorInfo -
-
- mixed - $error_count -
-
- string - $From -
-
- string - $FromName -
-
- string - $Helo -
-
- string - $Host -
-
- string - $Hostname -
-
- mixed - $language -
-
- mixed - $LE -
-
- string - $Mailer -
-
- string - $MessageID -
-
- mixed - $message_type -
-
- string - $Password -
-
- string - $PluginDir -
-
- int - $Port -
-
- int - $Priority -
-
- mixed - $ReplyTo -
-
- string - $Sender -
-
- string - $Sendmail -
-
- mixed - $sign_cert_file -
-
- mixed - $sign_key_file -
-
- mixed - $sign_key_pass -
-
- bool - $SingleTo -
-
- mixed - $smtp -
-
- bool - $SMTPAuth -
-
- bool - $SMTPDebug -
-
- bool - $SMTPKeepAlive -
-
- string - $SMTPSecure -
-
- string - $Subject -
-
- int - $Timeout -
-
- mixed - $to -
-
- string - $Username -
-
- string - $Version -
-
- int - $WordWrap -
-
-
-
- - -
-
Method Summary
- -
-
- -
- void - AddAddress - (string $address, [string $name = '']) -
- -
- bool - AddAttachment - (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
- void - AddBCC - (string $address, [string $name = '']) -
- -
- void - AddCC - (string $address, [string $name = '']) -
- -
- void - AddCustomHeader - (mixed $custom_header) -
- -
- bool - AddEmbeddedImage - (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
- void - AddReplyTo - (string $address, [string $name = '']) -
- -
- void - AddStringAttachment - (string $string, string $filename, [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
- void - ClearAddresses - () -
- -
- void - ClearAllRecipients - () -
- -
- void - ClearAttachments - () -
- -
- void - ClearBCCs - () -
- -
- void - ClearCCs - () -
- -
- void - ClearCustomHeaders - () -
- -
- void - ClearReplyTos - () -
- -
- void - getFile - (string $filename) -
- -
- void - HeaderLine - (mixed $name, mixed $value) -
- -
- bool - IsError - () -
- -
- void - IsHTML - (bool $bool) -
- -
- void - IsMail - () -
- -
- void - IsQmail - () -
- -
- void - IsSendmail - () -
- -
- void - IsSMTP - () -
- -
- $message - MsgHTML - (mixed $message, [mixed $basedir = '']) -
- -
- bool - Send - () -
- -
- void - set - (string $name, [mixed $value = '']) -
- -
- bool - SetLanguage - (string $lang_type, [string $lang_path = 'language/']) -
- -
- void - Sign - (mixed $cert_filename, string $key_filename, string $key_pass) -
- -
- void - SmtpClose - () -
-
-
-
- - -
-
Variables
- -
- -
- -
- - string - $AltBody - = '' (line 110) - -
- - -

Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.

- - - - - -
- -
- -
- - mixed - $attachment - = array() (line 253) - -
- - - - - - - -
- -
- -
- - mixed - $bcc - = array() (line 251) - -
- - - - - - - -
- -
- -
- - string - $Body - = '' (line 101) - -
- - -

Sets the Body of the message. This can be either an HTML or text body.

-

If HTML then run IsHTML(true).

- - - - - -
- -
- -
- - mixed - $boundary - = array() (line 256) - -
- - - - - - - -
- -
- -
- - mixed - $cc - = array() (line 250) - -
- - - - - - - -
- -
- -
- - string - $CharSet - = 'iso-8859-1' (line 50) - -
- - -

Sets the CharSet of the message.

- - - - - -
- -
- -
- - string - $ConfirmReadingTo - = '' (line 148) - -
- - -

Sets the email address that a reading confirmation will be sent.

- - - - - -
- -
- -
- - string - $ContentType - = 'text/plain' (line 56) - -
- - -

Sets the Content-type of the message.

- - - - - -
- -
- -
- - mixed - $CustomHeader - = array() (line 254) - -
- - - - - - - -
- -
- -
- - string - $Encoding - = '8bit' (line 63) - -
- - -

Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".

- - - - - -
- -
- -
- - string - $ErrorInfo - = '' (line 69) - -
- - -

Holds the most recent mailer error message.

- - - - - -
- -
- -
- - mixed - $error_count - = 0 (line 258) - -
- - - - - - - -
- -
- -
- - string - $From - = 'root@localhost' (line 75) - -
- - -

Sets the From email address for the message.

- - - - - -
- -
- -
- - string - $FromName - = 'Root User' (line 81) - -
- - -

Sets the From name of the message.

- - - - - -
- -
- -
- - string - $Helo - = '' (line 189) - -
- - -

Sets the SMTP HELO of the message (Default is $Hostname).

- - - - - -
- -
- -
- - string - $Host - = 'localhost' (line 177) - -
- - -

Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").

-

Hosts will be tried in order.

- - - - - -
- -
- -
- - string - $Hostname - = '' (line 156) - -
- - -

Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.

- - - - - -
- -
- -
- - mixed - $language - = array() (line 257) - -
- - - - - - - -
- -
- -
- - mixed - $LE - = "\n" (line 259) - -
- - - - - - - -
- -
- -
- - string - $Mailer - = 'mail' (line 123) - -
- - -

Method to send mail: ("mail", "sendmail", or "smtp").

- - - - - -
- -
- -
- - string - $MessageID - = '' (line 163) - -
- - -

Sets the message ID to be used in the Message-Id header.

-

If empty, a unique id will be generated.

- - - - - -
- -
- -
- - mixed - $message_type - = '' (line 255) - -
- - - - - - - -
- -
- -
- - string - $Password - = '' (line 214) - -
- - -

Sets SMTP password.

- - - - - -
- -
- -
- - string - $PluginDir - = '' (line 136) - -
- - -

Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.

- - - - - -
- -
- -
- - int - $Port - = 25 (line 183) - -
- - -

Sets the default SMTP server port.

- - - - - -
- -
- -
- - int - $Priority - = 3 (line 44) - -
- - -

Email priority (1 = High, 3 = Normal, 5 = low).

- - - - - -
- -
- -
- - mixed - $ReplyTo - = array() (line 252) - -
- - - - - - - -
- -
- -
- - string - $Sender - = '' (line 88) - -
- - -

Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.

- - - - - -
- -
- -
- - string - $Sendmail - = '/usr/sbin/sendmail' (line 129) - -
- - -

Sets the path of the sendmail program.

- - - - - -
- -
- -
- - mixed - $sign_cert_file - = "" (line 260) - -
- - - - - - - -
- -
- -
- - mixed - $sign_key_file - = "" (line 261) - -
- - - - - - - -
- -
- -
- - mixed - $sign_key_pass - = "" (line 262) - -
- - - - - - - -
- -
- -
- - bool - $SingleTo - = false (line 242) - -
- - -

Provides the ability to have the TO field process individual

-

emails, instead of sending to entire TO addresses

- - - - - -
- -
- -
- - mixed - $smtp - = NULL (line 248) - -
- - - - - - - -
- -
- -
- - bool - $SMTPAuth - = false (line 202) - -
- - -

Sets SMTP authentication. Utilizes the Username and Password variables.

- - - - - -
- -
- -
- - bool - $SMTPDebug - = false (line 227) - -
- - -

Sets SMTP class debugging on or off.

- - - - - -
- -
- -
- - bool - $SMTPKeepAlive - = false (line 235) - -
- - -

Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().

- - - - - -
- -
- -
- - string - $SMTPSecure - = "" (line 196) - -
- - -

Sets connection prefix.

-

Options are "", "ssl" or "tls"

- - - - - -
- -
- -
- - string - $Subject - = '' (line 94) - -
- - -

Sets the Subject of the message.

- - - - - -
- -
- -
- - int - $Timeout - = 10 (line 221) - -
- - -

Sets the SMTP server timeout in seconds. This function will not work with the win32 version.

- - - - - -
- -
- -
- - mixed - $to - = array() (line 249) - -
- - - - - - - -
- -
- -
- - string - $Username - = '' (line 208) - -
- - -

Sets SMTP username.

- - - - - -
- -
- -
- - string - $Version - = "2.0.4" (line 142) - -
- - -

Holds PHPMailer version.

- - - - - -
- -
- -
- - int - $WordWrap - = 0 (line 117) - -
- - -

Sets word wrapping on the body of the message to a given number of characters.

- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- AddAddress (line 324) -
- - -

Adds a "To" address.

- -
- void - - AddAddress - - (string $address, [string $name = '']) -
- -
    -
  • - string - $address
  • -
  • - string - $name
  • -
- - -
- -
- -
- AddAttachment (line 1124) -
- - -

Adds an attachment from a path on the filesystem.

-

Returns false if the file could not be found or accessed.

- -
- bool - - AddAttachment - - (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
    -
  • - string - $path: Path to the attachment.
  • -
  • - string - $name: Overrides the attachment name.
  • -
  • - string - $encoding: File encoding (see $Encoding).
  • -
  • - string - $type: File extension (MIME) type.
  • -
- - -
- -
- -
- AddBCC (line 352) -
- - -

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

- -
- void - - AddBCC - - (string $address, [string $name = '']) -
- -
    -
  • - string - $address
  • -
  • - string - $name
  • -
- - -
- -
- -
- AddCC (line 338) -
- - -

Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

- -
- void - - AddCC - - (string $address, [string $name = '']) -
- -
    -
  • - string - $address
  • -
  • - string - $name
  • -
- - -
- -
- -
- AddCustomHeader (line 1704) -
- - -

Adds a custom header.

- -
- void - - AddCustomHeader - - (mixed $custom_header) -
- - - -
- -
- -
- AddEmbeddedImage (line 1484) -
- - -

Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".

- -
- bool - - AddEmbeddedImage - - (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
    -
  • - string - $path: Path to the attachment.
  • -
  • - string - $cid: Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
  • -
  • - string - $name: Overrides the attachment name.
  • -
  • - string - $encoding: File encoding (see $Encoding).
  • -
  • - string - $type: File extension (MIME) type.
  • -
- - -
- -
- -
- AddReplyTo (line 364) -
- - -

Adds a "Reply-To" address.

- -
- void - - AddReplyTo - - (string $address, [string $name = '']) -
- -
    -
  • - string - $address
  • -
  • - string - $name
  • -
- - -
- -
- -
- AddStringAttachment (line 1458) -
- - -

Adds a string or binary attachment (non-filesystem) to the list.

-

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

- -
- void - - AddStringAttachment - - (string $string, string $filename, [string $encoding = 'base64'], [string $type = 'application/octet-stream']) -
- -
    -
  • - string - $string: String attachment data.
  • -
  • - string - $filename: Name of the attachment.
  • -
  • - string - $encoding: File encoding (see $Encoding).
  • -
  • - string - $type: File extension (MIME) type.
  • -
- - -
- -
- -
- ClearAddresses (line 1535) -
- - -

Clears all recipients assigned in the TO array. Returns void.

- -
- void - - ClearAddresses - - () -
- - - -
- -
- -
- ClearAllRecipients (line 1568) -
- - -

Clears all recipients assigned in the TO, CC and BCC array. Returns void.

- -
- void - - ClearAllRecipients - - () -
- - - -
- -
- -
- ClearAttachments (line 1579) -
- - -

Clears all previously set filesystem, string, and binary attachments. Returns void.

- -
- void - - ClearAttachments - - () -
- - - -
- -
- -
- ClearBCCs (line 1551) -
- - -

Clears all recipients assigned in the BCC array. Returns void.

- -
- void - - ClearBCCs - - () -
- - - -
- -
- -
- ClearCCs (line 1543) -
- - -

Clears all recipients assigned in the CC array. Returns void.

- -
- void - - ClearCCs - - () -
- - - -
- -
- -
- ClearCustomHeaders (line 1587) -
- - -

Clears all custom headers. Returns void.

- -
- void - - ClearCustomHeaders - - () -
- - - -
- -
- -
- ClearReplyTos (line 1559) -
- - -

Clears all recipients assigned in the ReplyTo array. Returns void.

- -
- void - - ClearReplyTos - - () -
- - - -
- -
- -
- getFile (line 1868) -
- - -

Read a file from a supplied filename and return it.

-
    -
  • access: public
  • -
- -
- void - - getFile - - (string $filename) -
- -
    -
  • - string - $filename: Parameter File Name
  • -
- - -
- -
- -
- HeaderLine (line 1097) -
- - - -
- void - - HeaderLine - - (mixed $name, mixed $value) -
- - - -
- -
- -
- IsError (line 1684) -
- - -

Returns true if an error occurred.

- -
- bool - - IsError - - () -
- - - -
- -
- -
- IsHTML (line 273) -
- - -

Sets message type to HTML.

- -
- void - - IsHTML - - (bool $bool) -
- -
    -
  • - bool - $bool
  • -
- - -
- -
- -
- IsMail (line 293) -
- - -

Sets Mailer to send message using PHP mail() function.

- -
- void - - IsMail - - () -
- - - -
- -
- -
- IsQmail (line 309) -
- - -

Sets Mailer to send message using the qmail MTA.

- -
- void - - IsQmail - - () -
- - - -
- -
- -
- IsSendmail (line 301) -
- - -

Sets Mailer to send message using the $Sendmail program.

- -
- void - - IsSendmail - - () -
- - - -
- -
- -
- IsSMTP (line 285) -
- - -

Sets Mailer to send message using SMTP.

- -
- void - - IsSMTP - - () -
- - - -
- -
- -
- MsgHTML (line 1713) -
- - -

Evaluates the message and returns modifications for inline images and backgrounds

-
    -
  • access: public
  • -
- -
- $message - - MsgHTML - - (mixed $message, [mixed $basedir = '']) -
- - - -
- -
- -
- Send (line 380) -
- - -

Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.

- -
- bool - - Send - - () -
- - - -
- -
- -
- set (line 1853) -
- - -

Set (or reset) Class Objects (variables)

-

Usage Example: $page->set('X-Priority', '3');

-
    -
  • access: public
  • -
- -
- void - - set - - (string $name, [mixed $value = '']) -
- -
    -
  • - string - $name: Parameter Name
  • -
  • - mixed - $value: Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset
  • -
- - -
- -
- -
- SetLanguage (line 647) -
- - -

Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.

-
    -
  • access: public
  • -
- -
- bool - - SetLanguage - - (string $lang_type, [string $lang_path = 'language/']) -
- -
    -
  • - string - $lang_type: Type of language (e.g. Portuguese: "br")
  • -
  • - string - $lang_path: Path to the language file directory
  • -
- - -
- -
- -
- Sign (line 1901) -
- - -

Set the private key file and password to sign the message.

-
    -
  • access: public
  • -
- -
- void - - Sign - - (mixed $cert_filename, string $key_filename, string $key_pass) -
- -
    -
  • - string - $key_filename: Parameter File Name
  • -
  • - string - $key_pass: Password for private key
  • -
- - -
- -
- -
- SmtpClose (line 629) -
- - -

Closes the active SMTP session if one exists.

- -
- void - - SmtpClose - - () -
- - - -
- -
-
- - -

- Documentation generated on Thu, 02 Apr 2009 21:19:48 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/POP3.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/POP3.html deleted file mode 100644 index 66d3d8afd..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/POP3.html +++ /dev/null @@ -1,649 +0,0 @@ - - - - - - Docs For Class POP3 - - - - -
-

Class POP3

- - -
-
Description
- -
- -

- Located in /class.pop3.php (line 46) -

- - -

-	
-			
-
- - - - -
-
Variable Summary
- -
-
-
- string - $CRLF -
-
- int - $do_debug -
-
- string - $host -
-
- string - $password -
-
- int - $POP3_PORT -
-
- int - $POP3_TIMEOUT -
-
- int - $port -
-
- int - $tval -
-
- string - $username -
-
-
-
- - -
-
Method Summary
- -
-
- -
- POP3 - POP3 - () -
- -
- void - Authorise - (string $host, [integer $port = false], [integer $tval = false], string $username, string $password, mixed $debug_level) -
- -
- void - catchWarning - (integer $errno, string $errstr, string $errfile, integer $errline) -
- -
- boolean - checkResponse - (string $string) -
- -
- boolean - Connect - (string $host, [integer $port = false], [integer $tval = 30]) -
- -
- void - Disconnect - () -
- -
- void - displayErrors - () -
- -
- string - getResponse - ([integer $size = 128]) -
- -
- boolean - Login - ([string $username = ''], [string $password = '']) -
- -
- integer - sendString - (string $string) -
-
-
-
- - -
-
Variables
- -
- -
- -
- - string - $CRLF - = "\r\n" (line 64) - -
- - -

POP3 Carriage Return + Line Feed

- - - - - -
- -
- -
- - int - $do_debug - = 2 (line 70) - -
- - -

Displaying Debug warnings? (0 = now, 1+ = yes)

- - - - - -
- -
- -
- - string - $host - (line 76) - -
- - -

POP3 Mail Server

- - - - - -
- -
- -
- - string - $password - (line 100) - -
- - -

POP3 Password

- - - - - -
- -
- -
- - int - $POP3_PORT - = 110 (line 52) - -
- - -

Default POP3 port

- - - - - -
- -
- -
- - int - $POP3_TIMEOUT - = 30 (line 58) - -
- - -

Default Timeout

- - - - - -
- -
- -
- - int - $port - (line 82) - -
- - -

POP3 Port

- - - - - -
- -
- -
- - int - $tval - (line 88) - -
- - -

POP3 Timeout Value

- - - - - -
- -
- -
- - string - $username - (line 94) - -
- - -

POP3 Username

- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- Constructor POP3 (line 115) -
- - -

Constructor, sets the initial values

- -
- POP3 - - POP3 - - () -
- - - -
- -
- -
- Authorise (line 131) -
- - -

Combination of public events - connect, login, disconnect

- -
- void - - Authorise - - (string $host, [integer $port = false], [integer $tval = false], string $username, string $password, mixed $debug_level) -
- -
    -
  • - string - $host
  • -
  • - integer - $port
  • -
  • - integer - $tval
  • -
  • - string - $username
  • -
  • - string - $password
  • -
- - -
- -
- -
- catchWarning (line 425) -
- - -

Takes over from PHP for the socket warning handler

- -
- void - - catchWarning - - (integer $errno, string $errstr, string $errfile, integer $errline) -
- -
    -
  • - integer - $errno
  • -
  • - string - $errstr
  • -
  • - string - $errfile
  • -
  • - integer - $errline
  • -
- - -
- -
- -
- checkResponse (line 377) -
- - -

Checks the POP3 server response for +OK or -ERR

- -
- boolean - - checkResponse - - (string $string) -
- -
    -
  • - string - $string
  • -
- - -
- -
- -
- Connect (line 192) -
- - -

Connect to the POP3 server

- -
- boolean - - Connect - - (string $host, [integer $port = false], [integer $tval = 30]) -
- -
    -
  • - string - $host
  • -
  • - integer - $port
  • -
  • - integer - $tval
  • -
- - -
- -
- -
- Disconnect (line 330) -
- - -

Disconnect from the POP3 server

- -
- void - - Disconnect - - () -
- - - -
- -
- -
- displayErrors (line 405) -
- - -

If debug is enabled, display the error message array

- -
- void - - displayErrors - - () -
- - - -
- -
- -
- getResponse (line 350) -
- - -

Get the socket response back.

-

$size is the maximum number of bytes to retrieve

- -
- string - - getResponse - - ([integer $size = 128]) -
- -
    -
  • - integer - $size
  • -
- - -
- -
- -
- Login (line 277) -
- - -

Login to the POP3 server (does not support APOP yet)

- -
- boolean - - Login - - ([string $username = ''], [string $password = '']) -
- -
    -
  • - string - $username
  • -
  • - string - $password
  • -
- - -
- -
- -
- sendString (line 363) -
- - -

Send a string down the open socket connection to the POP3 server

- -
- integer - - sendString - - (string $string) -
- -
    -
  • - string - $string
  • -
- - -
- -
-
- - -

- Documentation generated on Thu, 02 Apr 2009 21:19:49 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/SMTP.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/SMTP.html deleted file mode 100644 index 7c6c6697b..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/SMTP.html +++ /dev/null @@ -1,755 +0,0 @@ - - - - - - Docs For Class SMTP - - - - -
-

Class SMTP

- - -
-
Description
- -
- -

- Located in /class.smtp.php (line 36) -

- - -

-	
-			
-
- - - - -
-
Variable Summary
- -
-
-
- string - $CRLF -
-
- bool - $do_debug -
-
- bool - $do_verp -
-
- int - $SMTP_PORT -
-
-
-
- - -
-
Method Summary
- -
-
- -
- void - SMTP - () -
- -
- bool - Authenticate - (mixed $username, mixed $password) -
- -
- void - Close - () -
- -
- bool - Connect - (mixed $host, mixed $port, [mixed $tval = 30]) -
- -
- bool - Data - (mixed $msg_data) -
- -
- string - Expand - (mixed $name) -
- -
- bool - Hello - ([mixed $host = ""]) -
- -
- string - Help - ([mixed $keyword = ""]) -
- -
- bool - Mail - (mixed $from) -
- -
- bool - Noop - () -
- -
- bool - Quit - ([mixed $close_on_error = true]) -
- -
- bool - Recipient - (mixed $to) -
- -
- bool - Reset - () -
- -
- bool - Send - (mixed $from) -
- -
- bool - SendAndMail - (mixed $from) -
- -
- bool - SendOrMail - (mixed $from) -
- -
- bool - Turn - () -
- -
- int - Verify - (mixed $name) -
-
-
-
- - -
-
Variables
- -
- -
- -
- - string - $CRLF - = "\r\n" (line 48) - -
- - -

SMTP reply line ending

- - - - - -
- -
- -
- - bool - $do_debug - (line 54) - -
- - -

Sets whether debugging is turned on

- - - - - -
- -
- -
- - bool - $do_verp - = false (line 60) - -
- - -

Sets VERP use on/off (default is off)

- - - - - -
- -
- -
- - int - $SMTP_PORT - = 25 (line 42) - -
- - -

SMTP server port

- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- Constructor SMTP (line 75) -
- - -

Initialize the class so that the data is in a known state.

-
    -
  • access: public
  • -
- -
- void - - SMTP - - () -
- - - -
- -
- -
- Authenticate (line 161) -
- - -

Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.

-
    -
  • access: public
  • -
- -
- bool - - Authenticate - - (mixed $username, mixed $password) -
- - - -
- -
- -
- Close (line 249) -
- - -

Closes the socket and cleans up the state of the class.

-

It is not considered good to use this function without first trying to use QUIT.

-
    -
  • access: public
  • -
- -
- void - - Close - - () -
- - - -
- -
- -
- Connect (line 100) -
- - -

Connect to the server specified on the port specified.

-

If the port is not specified use the default SMTP_PORT. If tval is specified then a connection will try and be established with the server for that number of seconds. If tval is not specified the default is 30 seconds to try on the connection.

SMTP CODE SUCCESS: 220 SMTP CODE FAILURE: 421

-
    -
  • access: public
  • -
- -
- bool - - Connect - - (mixed $host, mixed $port, [mixed $tval = 30]) -
- - - -
- -
- -
- Data (line 282) -
- - -

Issues a data command and sends the msg_data to the server

-

finializing the mail transaction. $msg_data is the message that is to be send with the headers. Each header needs to be on a single line followed by a <CRLF> with the message headers and the message body being seperated by and additional <CRLF>.

Implements rfc 821: DATA <CRLF>

SMTP CODE INTERMEDIATE: 354 [data] <CRLF>.<CRLF> SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 552,554,451,452 SMTP CODE FAILURE: 451,554 SMTP CODE ERROR : 500,501,503,421

-
    -
  • access: public
  • -
- -
- bool - - Data - - (mixed $msg_data) -
- - - -
- -
- -
- Expand (line 421) -
- - -

Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.

-

Each value in the array returned has the format of: [ <full-name> <sp> ] <path> The definition of <path> is defined in rfc 821

Implements rfc 821: EXPN <SP> <string> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 550 SMTP CODE ERROR : 500,501,502,504,421

-
    -
  • return: array
  • -
  • access: public
  • -
- -
- string - - Expand - - (mixed $name) -
- - - -
- -
- -
- Hello (line 472) -
- - -

Sends the HELO command to the smtp server.

-

This makes sure that we and the server are in the same known state.

Implements from rfc 821: HELO <SP> <domain> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500, 501, 504, 421

-
    -
  • access: public
  • -
- -
- bool - - Hello - - ([mixed $host = ""]) -
- - - -
- -
- -
- Help (line 546) -
- - -

Gets help information on the keyword specified. If the keyword

-

is not specified then returns generic help, ussually contianing A list of keywords that help is available on. This function returns the results back to the user. It is up to the user to handle the returned data. If an error occurs then false is returned with $this->error set appropiately.

Implements rfc 821: HELP [ <SP> <string> ] <CRLF>

SMTP CODE SUCCESS: 211,214 SMTP CODE ERROR : 500,501,502,504,421

-
    -
  • access: public
  • -
- -
- string - - Help - - ([mixed $keyword = ""]) -
- - - -
- -
- -
- Mail (line 598) -
- - -

Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.

-

Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,421

-
    -
  • access: public
  • -
- -
- bool - - Mail - - (mixed $from) -
- - - -
- -
- -
- Noop (line 641) -
- - -

Sends the command NOOP to the SMTP server.

-

Implements from rfc 821: NOOP <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500, 421

-
    -
  • access: public
  • -
- -
- bool - - Noop - - () -
- - - -
- -
- -
- Quit (line 684) -
- - -

Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.

-

Implements from rfc 821: QUIT <CRLF>

SMTP CODE SUCCESS: 221 SMTP CODE ERROR : 500

-
    -
  • access: public
  • -
- -
- bool - - Quit - - ([mixed $close_on_error = true]) -
- - - -
- -
- -
- Recipient (line 738) -
- - -

Sends the command RCPT to the SMTP server with the TO: argument of $to.

-

Returns true if the recipient was accepted false if it was rejected.

Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>

SMTP CODE SUCCESS: 250,251 SMTP CODE FAILURE: 550,551,552,553,450,451,452 SMTP CODE ERROR : 500,501,503,421

-
    -
  • access: public
  • -
- -
- bool - - Recipient - - (mixed $to) -
- - - -
- -
- -
- Reset (line 782) -
- - -

Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.

-

Implements rfc 821: RSET <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE ERROR : 500,501,504,421

-
    -
  • access: public
  • -
- -
- bool - - Reset - - () -
- - - -
- -
- -
- Send (line 831) -
- - -

Starts a mail transaction from the email address specified in

-

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in.

Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

-
    -
  • access: public
  • -
- -
- bool - - Send - - (mixed $from) -
- - - -
- -
- -
- SendAndMail (line 879) -
- - -

Starts a mail transaction from the email address specified in

-

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in and send them an email.

Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

-
    -
  • access: public
  • -
- -
- bool - - SendAndMail - - (mixed $from) -
- - - -
- -
- -
- SendOrMail (line 927) -
- - -

Starts a mail transaction from the email address specified in

-

$from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command. This command will send the message to the users terminal if they are logged in or mail it to them if they are not.

Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE SUCCESS: 552,451,452 SMTP CODE SUCCESS: 500,501,502,421

-
    -
  • access: public
  • -
- -
- bool - - SendOrMail - - (mixed $from) -
- - - -
- -
- -
- Turn (line 972) -
- - -

This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future

-

Implements from rfc 821: TURN <CRLF>

SMTP CODE SUCCESS: 250 SMTP CODE FAILURE: 502 SMTP CODE ERROR : 500, 503

-
    -
  • access: public
  • -
- -
- bool - - Turn - - () -
- - - -
- -
- -
- Verify (line 994) -
- - -

Verifies that the name is recognized by the server.

-

Returns false if the name could not be verified otherwise the response from the server is returned.

Implements rfc 821: VRFY <SP> <string> <CRLF>

SMTP CODE SUCCESS: 250,251 SMTP CODE FAILURE: 550,551,553 SMTP CODE ERROR : 500,501,502,421

-
    -
  • access: public
  • -
- -
- int - - Verify - - (mixed $name) -
- - - -
- -
-
- - -

- Documentation generated on Thu, 02 Apr 2009 21:19:51 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_phpmailer_php.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_phpmailer_php.html deleted file mode 100644 index bfcd69009..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_phpmailer_php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page class.phpmailer.php - - - - -
-

/class.phpmailer.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- PHPMailer - - -
-
-
- - - - - -

- Documentation generated on Thu, 02 Apr 2009 21:19:46 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_pop3_php.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_pop3_php.html deleted file mode 100644 index b30da7980..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_pop3_php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page class.pop3.php - - - - -
-

/class.pop3.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- POP3 - - -
-
-
- - - - - -

- Documentation generated on Thu, 02 Apr 2009 21:19:49 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_smtp_php.html b/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_smtp_php.html deleted file mode 100644 index d43e6f8ea..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/PHPMailer/_v2.0.4_PHPMailer_v2.0.4_class_smtp_php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page class.smtp.php - - - - -
-

/class.smtp.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- SMTP - - -
-
-
- - - - - -

- Documentation generated on Thu, 02 Apr 2009 21:19:49 -0400 by phpDocumentor 1.3.0RC3 -

-
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.phpmailer.php.html b/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.phpmailer.php.html deleted file mode 100644 index bb7cddb15..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.phpmailer.php.html +++ /dev/null @@ -1,1951 +0,0 @@ - - - - - - File Source for class.phpmailer.php - - - - -

Source for file class.phpmailer.php

-

Documentation is available at class.phpmailer.php

-
-
  1. <?php
  2. -
  3. /*~ class.phpmailer.php
  4. -
  5. .---------------------------------------------------------------------------.
  6. -
  7. | Software: PHPMailer - PHP email class |
  8. -
  9. | Version: 2.0.4 |
  10. -
  11. | Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
  12. -
  13. | Info: http://phpmailer.sourceforge.net |
  14. -
  15. | Support: http://sourceforge.net/projects/phpmailer/ |
  16. -
  17. | ------------------------------------------------------------------------- |
  18. -
  19. | Author: Andy Prevost (project admininistrator) |
  20. -
  21. | Author: Brent R. Matzelle (original founder) |
  22. -
  23. | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
  24. -
  25. | Copyright (c) 2001-2003, Brent R. Matzelle |
  26. -
  27. | ------------------------------------------------------------------------- |
  28. -
  29. | License: Distributed under the Lesser General Public License (LGPL) |
  30. -
  31. | http://www.gnu.org/copyleft/lesser.html |
  32. -
  33. | This program is distributed in the hope that it will be useful - WITHOUT |
  34. -
  35. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
  36. -
  37. | FITNESS FOR A PARTICULAR PURPOSE. |
  38. -
  39. | ------------------------------------------------------------------------- |
  40. -
  41. | We offer a number of paid services (www.codeworxtech.com): |
  42. -
  43. | - Web Hosting on highly optimized fast and secure servers |
  44. -
  45. | - Technology Consulting |
  46. -
  47. | - Oursourcing (highly qualified programmers and graphic designers) |
  48. -
  49. '---------------------------------------------------------------------------'
  50. -
  51.  
  52. -
  53.  
  54. -
  55.  
  56. -
  57. /**
  58. -
  59. * PHPMailer - PHP email transport class
  60. -
  61. * @package PHPMailer
  62. -
  63. * @author Andy Prevost
  64. -
  65. * @copyright 2004 - 2009 Andy Prevost
  66. -
  67. */
  68. -
  69.  
  70. -
  71. class PHPMailer {
  72. -
  73.  
  74. -
  75. /////////////////////////////////////////////////
  76. -
  77. // PROPERTIES, PUBLIC
  78. -
  79. /////////////////////////////////////////////////
  80. -
  81.  
  82. -
  83. -
  84.  
  85. -
  86. /**
  87. -
  88. * Email priority (1 = High, 3 = Normal, 5 = low).
  89. -
  90. * @var int
  91. -
  92. */
  93. -
  94. var $Priority = 3;
  95. -
  96.  
  97. -
  98. /**
  99. -
  100. * Sets the CharSet of the message.
  101. -
  102. * @var string
  103. -
  104. */
  105. -
  106. var $CharSet = 'iso-8859-1';
  107. -
  108.  
  109. -
  110. /**
  111. -
  112. * Sets the Content-type of the message.
  113. -
  114. * @var string
  115. -
  116. */
  117. -
  118. var $ContentType = 'text/plain';
  119. -
  120.  
  121. -
  122. /**
  123. -
  124. * Sets the Encoding of the message. Options for this are "8bit",
  125. -
  126. * "7bit", "binary", "base64", and "quoted-printable".
  127. -
  128. * @var string
  129. -
  130. */
  131. -
  132. var $Encoding = '8bit';
  133. -
  134.  
  135. -
  136. /**
  137. -
  138. * Holds the most recent mailer error message.
  139. -
  140. * @var string
  141. -
  142. */
  143. -
  144. var $ErrorInfo = '';
  145. -
  146.  
  147. -
  148. /**
  149. -
  150. * Sets the From email address for the message.
  151. -
  152. * @var string
  153. -
  154. */
  155. -
  156. var $From = 'root@localhost';
  157. -
  158.  
  159. -
  160. /**
  161. -
  162. * Sets the From name of the message.
  163. -
  164. * @var string
  165. -
  166. */
  167. -
  168. var $FromName = 'Root User';
  169. -
  170.  
  171. -
  172. /**
  173. -
  174. * Sets the Sender email (Return-Path) of the message. If not empty,
  175. -
  176. * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
  177. -
  178. * @var string
  179. -
  180. */
  181. -
  182. var $Sender = '';
  183. -
  184.  
  185. -
  186. /**
  187. -
  188. * Sets the Subject of the message.
  189. -
  190. * @var string
  191. -
  192. */
  193. -
  194. var $Subject = '';
  195. -
  196.  
  197. -
  198. /**
  199. -
  200. * Sets the Body of the message. This can be either an HTML or text body.
  201. -
  202. * If HTML then run IsHTML(true).
  203. -
  204. * @var string
  205. -
  206. */
  207. -
  208. var $Body = '';
  209. -
  210.  
  211. -
  212. /**
  213. -
  214. * Sets the text-only body of the message. This automatically sets the
  215. -
  216. * email to multipart/alternative. This body can be read by mail
  217. -
  218. * clients that do not have HTML email capability such as mutt. Clients
  219. -
  220. * that can read HTML will view the normal Body.
  221. -
  222. * @var string
  223. -
  224. */
  225. -
  226. var $AltBody = '';
  227. -
  228.  
  229. -
  230. /**
  231. -
  232. * Sets word wrapping on the body of the message to a given number of
  233. -
  234. * characters.
  235. -
  236. * @var int
  237. -
  238. */
  239. -
  240. var $WordWrap = 0;
  241. -
  242.  
  243. -
  244. /**
  245. -
  246. * Method to send mail: ("mail", "sendmail", or "smtp").
  247. -
  248. * @var string
  249. -
  250. */
  251. -
  252. var $Mailer = 'mail';
  253. -
  254.  
  255. -
  256. /**
  257. -
  258. * Sets the path of the sendmail program.
  259. -
  260. * @var string
  261. -
  262. */
  263. -
  264. var $Sendmail = '/usr/sbin/sendmail';
  265. -
  266.  
  267. -
  268. /**
  269. -
  270. * Path to PHPMailer plugins. This is now only useful if the SMTP class
  271. -
  272. * is in a different directory than the PHP include path.
  273. -
  274. * @var string
  275. -
  276. */
  277. -
  278. var $PluginDir = '';
  279. -
  280.  
  281. -
  282. /**
  283. -
  284. * Holds PHPMailer version.
  285. -
  286. * @var string
  287. -
  288. */
  289. -
  290. var $Version = "2.0.4";
  291. -
  292.  
  293. -
  294. /**
  295. -
  296. * Sets the email address that a reading confirmation will be sent.
  297. -
  298. * @var string
  299. -
  300. */
  301. -
  302. var $ConfirmReadingTo = '';
  303. -
  304.  
  305. -
  306. /**
  307. -
  308. * Sets the hostname to use in Message-Id and Received headers
  309. -
  310. * and as default HELO string. If empty, the value returned
  311. -
  312. * by SERVER_NAME is used or 'localhost.localdomain'.
  313. -
  314. * @var string
  315. -
  316. */
  317. -
  318. var $Hostname = '';
  319. -
  320.  
  321. -
  322. /**
  323. -
  324. * Sets the message ID to be used in the Message-Id header.
  325. -
  326. * If empty, a unique id will be generated.
  327. -
  328. * @var string
  329. -
  330. */
  331. -
  332. var $MessageID = '';
  333. -
  334.  
  335. -
  336. /////////////////////////////////////////////////
  337. -
  338. // PROPERTIES FOR SMTP
  339. -
  340. /////////////////////////////////////////////////
  341. -
  342.  
  343. -
  344. -
  345.  
  346. -
  347. /**
  348. -
  349. * Sets the SMTP hosts. All hosts must be separated by a
  350. -
  351. * semicolon. You can also specify a different port
  352. -
  353. * for each host by using this format: [hostname:port]
  354. -
  355. * (e.g. "smtp1.example.com:25;smtp2.example.com").
  356. -
  357. * Hosts will be tried in order.
  358. -
  359. * @var string
  360. -
  361. */
  362. -
  363. var $Host = 'localhost';
  364. -
  365.  
  366. -
  367. /**
  368. -
  369. * Sets the default SMTP server port.
  370. -
  371. * @var int
  372. -
  373. */
  374. -
  375. var $Port = 25;
  376. -
  377.  
  378. -
  379. /**
  380. -
  381. * Sets the SMTP HELO of the message (Default is $Hostname).
  382. -
  383. * @var string
  384. -
  385. */
  386. -
  387. var $Helo = '';
  388. -
  389.  
  390. -
  391. /**
  392. -
  393. * Sets connection prefix.
  394. -
  395. * Options are "", "ssl" or "tls"
  396. -
  397. * @var string
  398. -
  399. */
  400. -
  401. var $SMTPSecure = "";
  402. -
  403.  
  404. -
  405. /**
  406. -
  407. * Sets SMTP authentication. Utilizes the Username and Password variables.
  408. -
  409. * @var bool
  410. -
  411. */
  412. -
  413. var $SMTPAuth = false;
  414. -
  415.  
  416. -
  417. /**
  418. -
  419. * Sets SMTP username.
  420. -
  421. * @var string
  422. -
  423. */
  424. -
  425. var $Username = '';
  426. -
  427.  
  428. -
  429. /**
  430. -
  431. * Sets SMTP password.
  432. -
  433. * @var string
  434. -
  435. */
  436. -
  437. var $Password = '';
  438. -
  439.  
  440. -
  441. /**
  442. -
  443. * Sets the SMTP server timeout in seconds. This function will not
  444. -
  445. * work with the win32 version.
  446. -
  447. * @var int
  448. -
  449. */
  450. -
  451. var $Timeout = 10;
  452. -
  453.  
  454. -
  455. /**
  456. -
  457. * Sets SMTP class debugging on or off.
  458. -
  459. * @var bool
  460. -
  461. */
  462. -
  463. var $SMTPDebug = false;
  464. -
  465.  
  466. -
  467. /**
  468. -
  469. * Prevents the SMTP connection from being closed after each mail
  470. -
  471. * sending. If this is set to true then to close the connection
  472. -
  473. * requires an explicit call to SmtpClose().
  474. -
  475. * @var bool
  476. -
  477. */
  478. -
  479. var $SMTPKeepAlive = false;
  480. -
  481.  
  482. -
  483. /**
  484. -
  485. * Provides the ability to have the TO field process individual
  486. -
  487. * emails, instead of sending to entire TO addresses
  488. -
  489. * @var bool
  490. -
  491. */
  492. -
  493. var $SingleTo = false;
  494. -
  495.  
  496. -
  497. /////////////////////////////////////////////////
  498. -
  499. // PROPERTIES, PRIVATE
  500. -
  501. /////////////////////////////////////////////////
  502. -
  503.  
  504. -
  505. -
  506.  
  507. -
  508. var $smtp = NULL;
  509. -
  510. var $to = array();
  511. -
  512. var $cc = array();
  513. -
  514. var $bcc = array();
  515. -
  516. var $ReplyTo = array();
  517. -
  518. var $attachment = array();
  519. -
  520. var $CustomHeader = array();
  521. -
  522. var $message_type = '';
  523. -
  524. var $boundary = array();
  525. -
  526. var $language = array();
  527. -
  528. var $error_count = 0;
  529. -
  530. var $LE = "\n";
  531. -
  532. var $sign_cert_file = "";
  533. -
  534. var $sign_key_file = "";
  535. -
  536. var $sign_key_pass = "";
  537. -
  538.  
  539. -
  540. /////////////////////////////////////////////////
  541. -
  542. // METHODS, VARIABLES
  543. -
  544. /////////////////////////////////////////////////
  545. -
  546.  
  547. -
  548. -
  549.  
  550. -
  551. /**
  552. -
  553. * Sets message type to HTML.
  554. -
  555. * @param bool $bool
  556. -
  557. * @return void
  558. -
  559. */
  560. -
  561. function IsHTML($bool) {
  562. -
  563. if($bool == true) {
  564. -
  565. $this->ContentType = 'text/html';
  566. -
  567. } else {
  568. -
  569. $this->ContentType = 'text/plain';
  570. -
  571. }
  572. -
  573. }
  574. -
  575.  
  576. -
  577. /**
  578. -
  579. * Sets Mailer to send message using SMTP.
  580. -
  581. * @return void
  582. -
  583. */
  584. -
  585. function IsSMTP() {
  586. -
  587. $this->Mailer = 'smtp';
  588. -
  589. }
  590. -
  591.  
  592. -
  593. /**
  594. -
  595. * Sets Mailer to send message using PHP mail() function.
  596. -
  597. * @return void
  598. -
  599. */
  600. -
  601. function IsMail() {
  602. -
  603. $this->Mailer = 'mail';
  604. -
  605. }
  606. -
  607.  
  608. -
  609. /**
  610. -
  611. * Sets Mailer to send message using the $Sendmail program.
  612. -
  613. * @return void
  614. -
  615. */
  616. -
  617. function IsSendmail() {
  618. -
  619. $this->Mailer = 'sendmail';
  620. -
  621. }
  622. -
  623.  
  624. -
  625. /**
  626. -
  627. * Sets Mailer to send message using the qmail MTA.
  628. -
  629. * @return void
  630. -
  631. */
  632. -
  633. function IsQmail() {
  634. -
  635. $this->Sendmail = '/var/qmail/bin/sendmail';
  636. -
  637. $this->Mailer = 'sendmail';
  638. -
  639. }
  640. -
  641.  
  642. -
  643. /////////////////////////////////////////////////
  644. -
  645. // METHODS, RECIPIENTS
  646. -
  647. /////////////////////////////////////////////////
  648. -
  649.  
  650. -
  651. -
  652.  
  653. -
  654. /**
  655. -
  656. * Adds a "To" address.
  657. -
  658. * @param string $address
  659. -
  660. * @param string $name
  661. -
  662. * @return void
  663. -
  664. */
  665. -
  666. function AddAddress($address, $name = '') {
  667. -
  668. $cur = count($this->to);
  669. -
  670. $this->to[$cur][0] = trim($address);
  671. -
  672. $this->to[$cur][1] = $name;
  673. -
  674. }
  675. -
  676.  
  677. -
  678. /**
  679. -
  680. * Adds a "Cc" address. Note: this function works
  681. -
  682. * with the SMTP mailer on win32, not with the "mail"
  683. -
  684. * mailer.
  685. -
  686. * @param string $address
  687. -
  688. * @param string $name
  689. -
  690. * @return void
  691. -
  692. */
  693. -
  694. function AddCC($address, $name = '') {
  695. -
  696. $cur = count($this->cc);
  697. -
  698. $this->cc[$cur][0] = trim($address);
  699. -
  700. $this->cc[$cur][1] = $name;
  701. -
  702. }
  703. -
  704.  
  705. -
  706. /**
  707. -
  708. * Adds a "Bcc" address. Note: this function works
  709. -
  710. * with the SMTP mailer on win32, not with the "mail"
  711. -
  712. * mailer.
  713. -
  714. * @param string $address
  715. -
  716. * @param string $name
  717. -
  718. * @return void
  719. -
  720. */
  721. -
  722. function AddBCC($address, $name = '') {
  723. -
  724. $cur = count($this->bcc);
  725. -
  726. $this->bcc[$cur][0] = trim($address);
  727. -
  728. $this->bcc[$cur][1] = $name;
  729. -
  730. }
  731. -
  732.  
  733. -
  734. /**
  735. -
  736. * Adds a "Reply-To" address.
  737. -
  738. * @param string $address
  739. -
  740. * @param string $name
  741. -
  742. * @return void
  743. -
  744. */
  745. -
  746. function AddReplyTo($address, $name = '') {
  747. -
  748. $cur = count($this->ReplyTo);
  749. -
  750. $this->ReplyTo[$cur][0] = trim($address);
  751. -
  752. $this->ReplyTo[$cur][1] = $name;
  753. -
  754. }
  755. -
  756.  
  757. -
  758. /////////////////////////////////////////////////
  759. -
  760. // METHODS, MAIL SENDING
  761. -
  762. /////////////////////////////////////////////////
  763. -
  764.  
  765. -
  766. -
  767.  
  768. -
  769. /**
  770. -
  771. * Creates message and assigns Mailer. If the message is
  772. -
  773. * not sent successfully then it returns false. Use the ErrorInfo
  774. -
  775. * variable to view description of the error.
  776. -
  777. * @return bool
  778. -
  779. */
  780. -
  781. function Send() {
  782. -
  783. $header = '';
  784. -
  785. $body = '';
  786. -
  787. $result = true;
  788. -
  789.  
  790. -
  791. if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
  792. -
  793. $this->SetError($this->Lang('provide_address'));
  794. -
  795. return false;
  796. -
  797. }
  798. -
  799.  
  800. -
  801. /* Set whether the message is multipart/alternative */
  802. -
  803. if(!empty($this->AltBody)) {
  804. -
  805. $this->ContentType = 'multipart/alternative';
  806. -
  807. }
  808. -
  809.  
  810. -
  811. $this->error_count = 0; // reset errors
  812. -
  813. $this->SetMessageType();
  814. -
  815. $header .= $this->CreateHeader();
  816. -
  817. $body = $this->CreateBody();
  818. -
  819.  
  820. -
  821. if($body == '') {
  822. -
  823. return false;
  824. -
  825. }
  826. -
  827.  
  828. -
  829. /* Choose the mailer */
  830. -
  831. switch($this->Mailer) {
  832. -
  833. case 'sendmail':
  834. -
  835. $result = $this->SendmailSend($header, $body);
  836. -
  837. break;
  838. -
  839. case 'smtp':
  840. -
  841. $result = $this->SmtpSend($header, $body);
  842. -
  843. break;
  844. -
  845. case 'mail':
  846. -
  847. $result = $this->MailSend($header, $body);
  848. -
  849. break;
  850. -
  851. default:
  852. -
  853. $result = $this->MailSend($header, $body);
  854. -
  855. break;
  856. -
  857. //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported'));
  858. -
  859. //$result = false;
  860. -
  861. //break;
  862. -
  863. }
  864. -
  865.  
  866. -
  867. return $result;
  868. -
  869. }
  870. -
  871.  
  872. -
  873. /**
  874. -
  875. * Sends mail using the $Sendmail program.
  876. -
  877. * @access private
  878. -
  879. * @return bool
  880. -
  881. */
  882. -
  883. function SendmailSend($header, $body) {
  884. -
  885. if ($this->Sender != '') {
  886. -
  887. $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
  888. -
  889. } else {
  890. -
  891. $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
  892. -
  893. }
  894. -
  895.  
  896. -
  897. if(!@$mail = popen($sendmail, 'w')) {
  898. -
  899. $this->SetError($this->Lang('execute') . $this->Sendmail);
  900. -
  901. return false;
  902. -
  903. }
  904. -
  905.  
  906. -
  907. fputs($mail, $header);
  908. -
  909. fputs($mail, $body);
  910. -
  911.  
  912. -
  913. $result = pclose($mail);
  914. -
  915. if (version_compare(phpversion(), '4.2.3') == -1) {
  916. -
  917. $result = $result >> 8 & 0xFF;
  918. -
  919. }
  920. -
  921. if($result != 0) {
  922. -
  923. $this->SetError($this->Lang('execute') . $this->Sendmail);
  924. -
  925. return false;
  926. -
  927. }
  928. -
  929. return true;
  930. -
  931. }
  932. -
  933.  
  934. -
  935. /**
  936. -
  937. * Sends mail using the PHP mail() function.
  938. -
  939. * @access private
  940. -
  941. * @return bool
  942. -
  943. */
  944. -
  945. function MailSend($header, $body) {
  946. -
  947.  
  948. -
  949. $to = '';
  950. -
  951. for($i = 0; $i < count($this->to); $i++) {
  952. -
  953. if($i != 0) { $to .= ', '; }
  954. -
  955. $to .= $this->AddrFormat($this->to[$i]);
  956. -
  957. }
  958. -
  959.  
  960. -
  961. $toArr = split(',', $to);
  962. -
  963.  
  964. -
  965. $params = sprintf("-oi -f %s", $this->Sender);
  966. -
  967. if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) {
  968. -
  969. $old_from = ini_get('sendmail_from');
  970. -
  971. ini_set('sendmail_from', $this->Sender);
  972. -
  973. if ($this->SingleTo === true && count($toArr) > 1) {
  974. -
  975. foreach ($toArr as $key => $val) {
  976. -
  977. $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  978. -
  979. }
  980. -
  981. } else {
  982. -
  983. $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  984. -
  985. }
  986. -
  987. } else {
  988. -
  989. if ($this->SingleTo === true && count($toArr) > 1) {
  990. -
  991. foreach ($toArr as $key => $val) {
  992. -
  993. $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
  994. -
  995. }
  996. -
  997. } else {
  998. -
  999. $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
  1000. -
  1001. }
  1002. -
  1003. }
  1004. -
  1005.  
  1006. -
  1007. if (isset($old_from)) {
  1008. -
  1009. ini_set('sendmail_from', $old_from);
  1010. -
  1011. }
  1012. -
  1013.  
  1014. -
  1015. if(!$rt) {
  1016. -
  1017. $this->SetError($this->Lang('instantiate'));
  1018. -
  1019. return false;
  1020. -
  1021. }
  1022. -
  1023.  
  1024. -
  1025. return true;
  1026. -
  1027. }
  1028. -
  1029.  
  1030. -
  1031. /**
  1032. -
  1033. * Sends mail via SMTP using PhpSMTP (Author:
  1034. -
  1035. * Chris Ryan). Returns bool. Returns false if there is a
  1036. -
  1037. * bad MAIL FROM, RCPT, or DATA input.
  1038. -
  1039. * @access private
  1040. -
  1041. * @return bool
  1042. -
  1043. */
  1044. -
  1045. function SmtpSend($header, $body) {
  1046. -
  1047. include_once($this->PluginDir . 'class.smtp.php');
  1048. -
  1049. $error = '';
  1050. -
  1051. $bad_rcpt = array();
  1052. -
  1053.  
  1054. -
  1055. if(!$this->SmtpConnect()) {
  1056. -
  1057. return false;
  1058. -
  1059. }
  1060. -
  1061.  
  1062. -
  1063. $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
  1064. -
  1065. if(!$this->smtp->Mail($smtp_from)) {
  1066. -
  1067. $error = $this->Lang('from_failed') . $smtp_from;
  1068. -
  1069. $this->SetError($error);
  1070. -
  1071. $this->smtp->Reset();
  1072. -
  1073. return false;
  1074. -
  1075. }
  1076. -
  1077.  
  1078. -
  1079. /* Attempt to send attach all recipients */
  1080. -
  1081. for($i = 0; $i < count($this->to); $i++) {
  1082. -
  1083. if(!$this->smtp->Recipient($this->to[$i][0])) {
  1084. -
  1085. $bad_rcpt[] = $this->to[$i][0];
  1086. -
  1087. }
  1088. -
  1089. }
  1090. -
  1091. for($i = 0; $i < count($this->cc); $i++) {
  1092. -
  1093. if(!$this->smtp->Recipient($this->cc[$i][0])) {
  1094. -
  1095. $bad_rcpt[] = $this->cc[$i][0];
  1096. -
  1097. }
  1098. -
  1099. }
  1100. -
  1101. for($i = 0; $i < count($this->bcc); $i++) {
  1102. -
  1103. if(!$this->smtp->Recipient($this->bcc[$i][0])) {
  1104. -
  1105. $bad_rcpt[] = $this->bcc[$i][0];
  1106. -
  1107. }
  1108. -
  1109. }
  1110. -
  1111.  
  1112. -
  1113. if(count($bad_rcpt) > 0) { // Create error message
  1114. -
  1115. for($i = 0; $i < count($bad_rcpt); $i++) {
  1116. -
  1117. if($i != 0) {
  1118. -
  1119. $error .= ', ';
  1120. -
  1121. }
  1122. -
  1123. $error .= $bad_rcpt[$i];
  1124. -
  1125. }
  1126. -
  1127. $error = $this->Lang('recipients_failed') . $error;
  1128. -
  1129. $this->SetError($error);
  1130. -
  1131. $this->smtp->Reset();
  1132. -
  1133. return false;
  1134. -
  1135. }
  1136. -
  1137.  
  1138. -
  1139. if(!$this->smtp->Data($header . $body)) {
  1140. -
  1141. $this->SetError($this->Lang('data_not_accepted'));
  1142. -
  1143. $this->smtp->Reset();
  1144. -
  1145. return false;
  1146. -
  1147. }
  1148. -
  1149. if($this->SMTPKeepAlive == true) {
  1150. -
  1151. $this->smtp->Reset();
  1152. -
  1153. } else {
  1154. -
  1155. $this->SmtpClose();
  1156. -
  1157. }
  1158. -
  1159.  
  1160. -
  1161. return true;
  1162. -
  1163. }
  1164. -
  1165.  
  1166. -
  1167. /**
  1168. -
  1169. * Initiates a connection to an SMTP server. Returns false if the
  1170. -
  1171. * operation failed.
  1172. -
  1173. * @access private
  1174. -
  1175. * @return bool
  1176. -
  1177. */
  1178. -
  1179. function SmtpConnect() {
  1180. -
  1181. if($this->smtp == NULL) {
  1182. -
  1183. $this->smtp = new SMTP();
  1184. -
  1185. }
  1186. -
  1187.  
  1188. -
  1189. $this->smtp->do_debug = $this->SMTPDebug;
  1190. -
  1191. $hosts = explode(';', $this->Host);
  1192. -
  1193. $index = 0;
  1194. -
  1195. $connection = ($this->smtp->Connected());
  1196. -
  1197.  
  1198. -
  1199. /* Retry while there is no connection */
  1200. -
  1201. while($index < count($hosts) && $connection == false) {
  1202. -
  1203. $hostinfo = array();
  1204. -
  1205. if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
  1206. -
  1207. $host = $hostinfo[1];
  1208. -
  1209. $port = $hostinfo[2];
  1210. -
  1211. } else {
  1212. -
  1213. $host = $hosts[$index];
  1214. -
  1215. $port = $this->Port;
  1216. -
  1217. }
  1218. -
  1219.  
  1220. -
  1221. if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) {
  1222. -
  1223. if ($this->Helo != '') {
  1224. -
  1225. $this->smtp->Hello($this->Helo);
  1226. -
  1227. } else {
  1228. -
  1229. $this->smtp->Hello($this->ServerHostname());
  1230. -
  1231. }
  1232. -
  1233.  
  1234. -
  1235. $connection = true;
  1236. -
  1237. if($this->SMTPAuth) {
  1238. -
  1239. if(!$this->smtp->Authenticate($this->Username, $this->Password)) {
  1240. -
  1241. $this->SetError($this->Lang('authenticate'));
  1242. -
  1243. $this->smtp->Reset();
  1244. -
  1245. $connection = false;
  1246. -
  1247. }
  1248. -
  1249. }
  1250. -
  1251. }
  1252. -
  1253. $index++;
  1254. -
  1255. }
  1256. -
  1257. if(!$connection) {
  1258. -
  1259. $this->SetError($this->Lang('connect_host'));
  1260. -
  1261. }
  1262. -
  1263.  
  1264. -
  1265. return $connection;
  1266. -
  1267. }
  1268. -
  1269.  
  1270. -
  1271. /**
  1272. -
  1273. * Closes the active SMTP session if one exists.
  1274. -
  1275. * @return void
  1276. -
  1277. */
  1278. -
  1279. function SmtpClose() {
  1280. -
  1281. if($this->smtp != NULL) {
  1282. -
  1283. if($this->smtp->Connected()) {
  1284. -
  1285. $this->smtp->Quit();
  1286. -
  1287. $this->smtp->Close();
  1288. -
  1289. }
  1290. -
  1291. }
  1292. -
  1293. }
  1294. -
  1295.  
  1296. -
  1297. /**
  1298. -
  1299. * Sets the language for all class error messages. Returns false
  1300. -
  1301. * if it cannot load the language file. The default language type
  1302. -
  1303. * is English.
  1304. -
  1305. * @param string $lang_type Type of language (e.g. Portuguese: "br")
  1306. -
  1307. * @param string $lang_path Path to the language file directory
  1308. -
  1309. * @access public
  1310. -
  1311. * @return bool
  1312. -
  1313. */
  1314. -
  1315. function SetLanguage($lang_type, $lang_path = 'language/') {
  1316. -
  1317. if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) {
  1318. -
  1319. include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
  1320. -
  1321. } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) {
  1322. -
  1323. include($lang_path.'phpmailer.lang-en.php');
  1324. -
  1325. } else {
  1326. -
  1327. $PHPMAILER_LANG = array();
  1328. -
  1329. $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' .
  1330. -
  1331. $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
  1332. -
  1333. $PHPMAILER_LANG["execute"] = 'Could not execute: ';
  1334. -
  1335. $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
  1336. -
  1337. $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
  1338. -
  1339. $PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
  1340. -
  1341. $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' .
  1342. -
  1343. $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
  1344. -
  1345. $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
  1346. -
  1347. $PHPMAILER_LANG["file_access"] = 'Could not access file: ';
  1348. -
  1349. $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
  1350. -
  1351. $PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
  1352. -
  1353. $PHPMAILER_LANG["signing"] = 'Signing Error: ';
  1354. -
  1355. }
  1356. -
  1357. $this->language = $PHPMAILER_LANG;
  1358. -
  1359.  
  1360. -
  1361. return true;
  1362. -
  1363. }
  1364. -
  1365.  
  1366. -
  1367. /////////////////////////////////////////////////
  1368. -
  1369. // METHODS, MESSAGE CREATION
  1370. -
  1371. /////////////////////////////////////////////////
  1372. -
  1373.  
  1374. -
  1375. -
  1376.  
  1377. -
  1378. /**
  1379. -
  1380. * Creates recipient headers.
  1381. -
  1382. * @access private
  1383. -
  1384. * @return string
  1385. -
  1386. */
  1387. -
  1388. function AddrAppend($type, $addr) {
  1389. -
  1390. $addr_str = $type . ': ';
  1391. -
  1392. $addr_str .= $this->AddrFormat($addr[0]);
  1393. -
  1394. if(count($addr) > 1) {
  1395. -
  1396. for($i = 1; $i < count($addr); $i++) {
  1397. -
  1398. $addr_str .= ', ' . $this->AddrFormat($addr[$i]);
  1399. -
  1400. }
  1401. -
  1402. }
  1403. -
  1404. $addr_str .= $this->LE;
  1405. -
  1406.  
  1407. -
  1408. return $addr_str;
  1409. -
  1410. }
  1411. -
  1412.  
  1413. -
  1414. /**
  1415. -
  1416. * Formats an address correctly.
  1417. -
  1418. * @access private
  1419. -
  1420. * @return string
  1421. -
  1422. */
  1423. -
  1424. function AddrFormat($addr) {
  1425. -
  1426. if(empty($addr[1])) {
  1427. -
  1428. $formatted = $this->SecureHeader($addr[0]);
  1429. -
  1430. } else {
  1431. -
  1432. $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">";
  1433. -
  1434. }
  1435. -
  1436.  
  1437. -
  1438. return $formatted;
  1439. -
  1440. }
  1441. -
  1442.  
  1443. -
  1444. /**
  1445. -
  1446. * Wraps message for use with mailers that do not
  1447. -
  1448. * automatically perform wrapping and for quoted-printable.
  1449. -
  1450. * Original written by philippe.
  1451. -
  1452. * @access private
  1453. -
  1454. * @return string
  1455. -
  1456. */
  1457. -
  1458. function WrapText($message, $length, $qp_mode = false) {
  1459. -
  1460. $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
  1461. -
  1462. // If utf-8 encoding is used, we will need to make sure we don't
  1463. -
  1464. // split multibyte characters when we wrap
  1465. -
  1466. $is_utf8 = (strtolower($this->CharSet) == "utf-8");
  1467. -
  1468.  
  1469. -
  1470. $message = $this->FixEOL($message);
  1471. -
  1472. if (substr($message, -1) == $this->LE) {
  1473. -
  1474. $message = substr($message, 0, -1);
  1475. -
  1476. }
  1477. -
  1478.  
  1479. -
  1480. $line = explode($this->LE, $message);
  1481. -
  1482. $message = '';
  1483. -
  1484. for ($i=0 ;$i < count($line); $i++) {
  1485. -
  1486. $line_part = explode(' ', $line[$i]);
  1487. -
  1488. $buf = '';
  1489. -
  1490. for ($e = 0; $e<count($line_part); $e++) {
  1491. -
  1492. $word = $line_part[$e];
  1493. -
  1494. if ($qp_mode and (strlen($word) > $length)) {
  1495. -
  1496. $space_left = $length - strlen($buf) - 1;
  1497. -
  1498. if ($e != 0) {
  1499. -
  1500. if ($space_left > 20) {
  1501. -
  1502. $len = $space_left;
  1503. -
  1504. if ($is_utf8) {
  1505. -
  1506. $len = $this->UTF8CharBoundary($word, $len);
  1507. -
  1508. } elseif (substr($word, $len - 1, 1) == "=") {
  1509. -
  1510. $len--;
  1511. -
  1512. } elseif (substr($word, $len - 2, 1) == "=") {
  1513. -
  1514. $len -= 2;
  1515. -
  1516. }
  1517. -
  1518. $part = substr($word, 0, $len);
  1519. -
  1520. $word = substr($word, $len);
  1521. -
  1522. $buf .= ' ' . $part;
  1523. -
  1524. $message .= $buf . sprintf("=%s", $this->LE);
  1525. -
  1526. } else {
  1527. -
  1528. $message .= $buf . $soft_break;
  1529. -
  1530. }
  1531. -
  1532. $buf = '';
  1533. -
  1534. }
  1535. -
  1536. while (strlen($word) > 0) {
  1537. -
  1538. $len = $length;
  1539. -
  1540. if ($is_utf8) {
  1541. -
  1542. $len = $this->UTF8CharBoundary($word, $len);
  1543. -
  1544. } elseif (substr($word, $len - 1, 1) == "=") {
  1545. -
  1546. $len--;
  1547. -
  1548. } elseif (substr($word, $len - 2, 1) == "=") {
  1549. -
  1550. $len -= 2;
  1551. -
  1552. }
  1553. -
  1554. $part = substr($word, 0, $len);
  1555. -
  1556. $word = substr($word, $len);
  1557. -
  1558.  
  1559. -
  1560. if (strlen($word) > 0) {
  1561. -
  1562. $message .= $part . sprintf("=%s", $this->LE);
  1563. -
  1564. } else {
  1565. -
  1566. $buf = $part;
  1567. -
  1568. }
  1569. -
  1570. }
  1571. -
  1572. } else {
  1573. -
  1574. $buf_o = $buf;
  1575. -
  1576. $buf .= ($e == 0) ? $word : (' ' . $word);
  1577. -
  1578.  
  1579. -
  1580. if (strlen($buf) > $length and $buf_o != '') {
  1581. -
  1582. $message .= $buf_o . $soft_break;
  1583. -
  1584. $buf = $word;
  1585. -
  1586. }
  1587. -
  1588. }
  1589. -
  1590. }
  1591. -
  1592. $message .= $buf . $this->LE;
  1593. -
  1594. }
  1595. -
  1596.  
  1597. -
  1598. return $message;
  1599. -
  1600. }
  1601. -
  1602.  
  1603. -
  1604. /**
  1605. -
  1606. * Finds last character boundary prior to maxLength in a utf-8
  1607. -
  1608. * quoted (printable) encoded string.
  1609. -
  1610. * Original written by Colin Brown.
  1611. -
  1612. * @access private
  1613. -
  1614. * @param string $encodedText utf-8 QP text
  1615. -
  1616. * @param int $maxLength find last character boundary prior to this length
  1617. -
  1618. * @return int
  1619. -
  1620. */
  1621. -
  1622. function UTF8CharBoundary($encodedText, $maxLength) {
  1623. -
  1624. $foundSplitPos = false;
  1625. -
  1626. $lookBack = 3;
  1627. -
  1628. while (!$foundSplitPos) {
  1629. -
  1630. $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
  1631. -
  1632. $encodedCharPos = strpos($lastChunk, "=");
  1633. -
  1634. if ($encodedCharPos !== false) {
  1635. -
  1636. // Found start of encoded character byte within $lookBack block.
  1637. -
  1638. // Check the encoded byte value (the 2 chars after the '=')
  1639. -
  1640. $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
  1641. -
  1642. $dec = hexdec($hex);
  1643. -
  1644. if ($dec < 128) { // Single byte character.
  1645. -
  1646. // If the encoded char was found at pos 0, it will fit
  1647. -
  1648. // otherwise reduce maxLength to start of the encoded char
  1649. -
  1650. $maxLength = ($encodedCharPos == 0) ? $maxLength :
  1651. -
  1652. $maxLength - ($lookBack - $encodedCharPos);
  1653. -
  1654. $foundSplitPos = true;
  1655. -
  1656. } elseif ($dec >= 192) { // First byte of a multi byte character
  1657. -
  1658. // Reduce maxLength to split at start of character
  1659. -
  1660. $maxLength = $maxLength - ($lookBack - $encodedCharPos);
  1661. -
  1662. $foundSplitPos = true;
  1663. -
  1664. } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
  1665. -
  1666. $lookBack += 3;
  1667. -
  1668. }
  1669. -
  1670. } else {
  1671. -
  1672. // No encoded character found
  1673. -
  1674. $foundSplitPos = true;
  1675. -
  1676. }
  1677. -
  1678. }
  1679. -
  1680. return $maxLength;
  1681. -
  1682. }
  1683. -
  1684.  
  1685. -
  1686. /**
  1687. -
  1688. * Set the body wrapping.
  1689. -
  1690. * @access private
  1691. -
  1692. * @return void
  1693. -
  1694. */
  1695. -
  1696. function SetWordWrap() {
  1697. -
  1698. if($this->WordWrap < 1) {
  1699. -
  1700. return;
  1701. -
  1702. }
  1703. -
  1704.  
  1705. -
  1706. switch($this->message_type) {
  1707. -
  1708. case 'alt':
  1709. -
  1710. /* fall through */
  1711. -
  1712. case 'alt_attachments':
  1713. -
  1714. $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
  1715. -
  1716. break;
  1717. -
  1718. default:
  1719. -
  1720. $this->Body = $this->WrapText($this->Body, $this->WordWrap);
  1721. -
  1722. break;
  1723. -
  1724. }
  1725. -
  1726. }
  1727. -
  1728.  
  1729. -
  1730. /**
  1731. -
  1732. * Assembles message header.
  1733. -
  1734. * @access private
  1735. -
  1736. * @return string
  1737. -
  1738. */
  1739. -
  1740. function CreateHeader() {
  1741. -
  1742. $result = '';
  1743. -
  1744.  
  1745. -
  1746. /* Set the boundaries */
  1747. -
  1748. $uniq_id = md5(uniqid(time()));
  1749. -
  1750. $this->boundary[1] = 'b1_' . $uniq_id;
  1751. -
  1752. $this->boundary[2] = 'b2_' . $uniq_id;
  1753. -
  1754.  
  1755. -
  1756. $result .= $this->HeaderLine('Date', $this->RFCDate());
  1757. -
  1758. if($this->Sender == '') {
  1759. -
  1760. $result .= $this->HeaderLine('Return-Path', trim($this->From));
  1761. -
  1762. } else {
  1763. -
  1764. $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
  1765. -
  1766. }
  1767. -
  1768.  
  1769. -
  1770. /* To be created automatically by mail() */
  1771. -
  1772. if($this->Mailer != 'mail') {
  1773. -
  1774. if(count($this->to) > 0) {
  1775. -
  1776. $result .= $this->AddrAppend('To', $this->to);
  1777. -
  1778. } elseif (count($this->cc) == 0) {
  1779. -
  1780. $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
  1781. -
  1782. }
  1783. -
  1784. }
  1785. -
  1786.  
  1787. -
  1788. $from = array();
  1789. -
  1790. $from[0][0] = trim($this->From);
  1791. -
  1792. $from[0][1] = $this->FromName;
  1793. -
  1794. $result .= $this->AddrAppend('From', $from);
  1795. -
  1796.  
  1797. -
  1798. /* sendmail and mail() extract Cc from the header before sending */
  1799. -
  1800. if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) {
  1801. -
  1802. $result .= $this->AddrAppend('Cc', $this->cc);
  1803. -
  1804. }
  1805. -
  1806.  
  1807. -
  1808. /* sendmail and mail() extract Bcc from the header before sending */
  1809. -
  1810. if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
  1811. -
  1812. $result .= $this->AddrAppend('Bcc', $this->bcc);
  1813. -
  1814. }
  1815. -
  1816.  
  1817. -
  1818. if(count($this->ReplyTo) > 0) {
  1819. -
  1820. $result .= $this->AddrAppend('Reply-To', $this->ReplyTo);
  1821. -
  1822. }
  1823. -
  1824.  
  1825. -
  1826. /* mail() sets the subject itself */
  1827. -
  1828. if($this->Mailer != 'mail') {
  1829. -
  1830. $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject)));
  1831. -
  1832. }
  1833. -
  1834.  
  1835. -
  1836. if($this->MessageID != '') {
  1837. -
  1838. $result .= $this->HeaderLine('Message-ID',$this->MessageID);
  1839. -
  1840. } else {
  1841. -
  1842. $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
  1843. -
  1844. }
  1845. -
  1846. $result .= $this->HeaderLine('X-Priority', $this->Priority);
  1847. -
  1848. $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']');
  1849. -
  1850.  
  1851. -
  1852. if($this->ConfirmReadingTo != '') {
  1853. -
  1854. $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
  1855. -
  1856. }
  1857. -
  1858.  
  1859. -
  1860. // Add custom headers
  1861. -
  1862. for($index = 0; $index < count($this->CustomHeader); $index++) {
  1863. -
  1864. $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
  1865. -
  1866. }
  1867. -
  1868. if (!$this->sign_key_file) {
  1869. -
  1870. $result .= $this->HeaderLine('MIME-Version', '1.0');
  1871. -
  1872. $result .= $this->GetMailMIME();
  1873. -
  1874. }
  1875. -
  1876.  
  1877. -
  1878. return $result;
  1879. -
  1880. }
  1881. -
  1882.  
  1883. -
  1884. /**
  1885. -
  1886. * Returns the message MIME.
  1887. -
  1888. * @access private
  1889. -
  1890. * @return string
  1891. -
  1892. */
  1893. -
  1894. function GetMailMIME() {
  1895. -
  1896. $result = '';
  1897. -
  1898. switch($this->message_type) {
  1899. -
  1900. case 'plain':
  1901. -
  1902. $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
  1903. -
  1904. $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet);
  1905. -
  1906. break;
  1907. -
  1908. case 'attachments':
  1909. -
  1910. /* fall through */
  1911. -
  1912. case 'alt_attachments':
  1913. -
  1914. if($this->InlineImageExists()){
  1915. -
  1916. $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE);
  1917. -
  1918. } else {
  1919. -
  1920. $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;');
  1921. -
  1922. $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  1923. -
  1924. }
  1925. -
  1926. break;
  1927. -
  1928. case 'alt':
  1929. -
  1930. $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
  1931. -
  1932. $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
  1933. -
  1934. break;
  1935. -
  1936. }
  1937. -
  1938.  
  1939. -
  1940. if($this->Mailer != 'mail') {
  1941. -
  1942. $result .= $this->LE.$this->LE;
  1943. -
  1944. }
  1945. -
  1946.  
  1947. -
  1948. return $result;
  1949. -
  1950. }
  1951. -
  1952.  
  1953. -
  1954. /**
  1955. -
  1956. * Assembles the message body. Returns an empty string on failure.
  1957. -
  1958. * @access private
  1959. -
  1960. * @return string
  1961. -
  1962. */
  1963. -
  1964. function CreateBody() {
  1965. -
  1966. $result = '';
  1967. -
  1968. if ($this->sign_key_file) {
  1969. -
  1970. $result .= $this->GetMailMIME();
  1971. -
  1972. }
  1973. -
  1974.  
  1975. -
  1976. $this->SetWordWrap();
  1977. -
  1978.  
  1979. -
  1980. switch($this->message_type) {
  1981. -
  1982. case 'alt':
  1983. -
  1984. $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', '');
  1985. -
  1986. $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  1987. -
  1988. $result .= $this->LE.$this->LE;
  1989. -
  1990. $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', '');
  1991. -
  1992. $result .= $this->EncodeString($this->Body, $this->Encoding);
  1993. -
  1994. $result .= $this->LE.$this->LE;
  1995. -
  1996. $result .= $this->EndBoundary($this->boundary[1]);
  1997. -
  1998. break;
  1999. -
  2000. case 'plain':
  2001. -
  2002. $result .= $this->EncodeString($this->Body, $this->Encoding);
  2003. -
  2004. break;
  2005. -
  2006. case 'attachments':
  2007. -
  2008. $result .= $this->GetBoundary($this->boundary[1], '', '', '');
  2009. -
  2010. $result .= $this->EncodeString($this->Body, $this->Encoding);
  2011. -
  2012. $result .= $this->LE;
  2013. -
  2014. $result .= $this->AttachAll();
  2015. -
  2016. break;
  2017. -
  2018. case 'alt_attachments':
  2019. -
  2020. $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
  2021. -
  2022. $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE);
  2023. -
  2024. $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body
  2025. -
  2026. $result .= $this->EncodeString($this->AltBody, $this->Encoding);
  2027. -
  2028. $result .= $this->LE.$this->LE;
  2029. -
  2030. $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body
  2031. -
  2032. $result .= $this->EncodeString($this->Body, $this->Encoding);
  2033. -
  2034. $result .= $this->LE.$this->LE;
  2035. -
  2036. $result .= $this->EndBoundary($this->boundary[2]);
  2037. -
  2038. $result .= $this->AttachAll();
  2039. -
  2040. break;
  2041. -
  2042. }
  2043. -
  2044.  
  2045. -
  2046. if($this->IsError()) {
  2047. -
  2048. $result = '';
  2049. -
  2050. } else if ($this->sign_key_file) {
  2051. -
  2052. $file = tempnam("", "mail");
  2053. -
  2054. $fp = fopen($file, "w");
  2055. -
  2056. fwrite($fp, $result);
  2057. -
  2058. fclose($fp);
  2059. -
  2060. $signed = tempnam("", "signed");
  2061. -
  2062.  
  2063. -
  2064. if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) {
  2065. -
  2066. $fp = fopen($signed, "r");
  2067. -
  2068. $result = fread($fp, filesize($this->sign_key_file));
  2069. -
  2070. $result = '';
  2071. -
  2072. while(!feof($fp)){
  2073. -
  2074. $result = $result . fread($fp, 1024);
  2075. -
  2076. }
  2077. -
  2078. fclose($fp);
  2079. -
  2080. } else {
  2081. -
  2082. $this->SetError($this->Lang("signing").openssl_error_string());
  2083. -
  2084. $result = '';
  2085. -
  2086. }
  2087. -
  2088.  
  2089. -
  2090. unlink($file);
  2091. -
  2092. unlink($signed);
  2093. -
  2094. }
  2095. -
  2096.  
  2097. -
  2098. return $result;
  2099. -
  2100. }
  2101. -
  2102.  
  2103. -
  2104. /**
  2105. -
  2106. * Returns the start of a message boundary.
  2107. -
  2108. * @access private
  2109. -
  2110. */
  2111. -
  2112. function GetBoundary($boundary, $charSet, $contentType, $encoding) {
  2113. -
  2114. $result = '';
  2115. -
  2116. if($charSet == '') {
  2117. -
  2118. $charSet = $this->CharSet;
  2119. -
  2120. }
  2121. -
  2122. if($contentType == '') {
  2123. -
  2124. $contentType = $this->ContentType;
  2125. -
  2126. }
  2127. -
  2128. if($encoding == '') {
  2129. -
  2130. $encoding = $this->Encoding;
  2131. -
  2132. }
  2133. -
  2134. $result .= $this->TextLine('--' . $boundary);
  2135. -
  2136. $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet);
  2137. -
  2138. $result .= $this->LE;
  2139. -
  2140. $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
  2141. -
  2142. $result .= $this->LE;
  2143. -
  2144.  
  2145. -
  2146. return $result;
  2147. -
  2148. }
  2149. -
  2150.  
  2151. -
  2152. /**
  2153. -
  2154. * Returns the end of a message boundary.
  2155. -
  2156. * @access private
  2157. -
  2158. */
  2159. -
  2160. function EndBoundary($boundary) {
  2161. -
  2162. return $this->LE . '--' . $boundary . '--' . $this->LE;
  2163. -
  2164. }
  2165. -
  2166.  
  2167. -
  2168. /**
  2169. -
  2170. * Sets the message type.
  2171. -
  2172. * @access private
  2173. -
  2174. * @return void
  2175. -
  2176. */
  2177. -
  2178. function SetMessageType() {
  2179. -
  2180. if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) {
  2181. -
  2182. $this->message_type = 'plain';
  2183. -
  2184. } else {
  2185. -
  2186. if(count($this->attachment) > 0) {
  2187. -
  2188. $this->message_type = 'attachments';
  2189. -
  2190. }
  2191. -
  2192. if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) {
  2193. -
  2194. $this->message_type = 'alt';
  2195. -
  2196. }
  2197. -
  2198. if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) {
  2199. -
  2200. $this->message_type = 'alt_attachments';
  2201. -
  2202. }
  2203. -
  2204. }
  2205. -
  2206. }
  2207. -
  2208.  
  2209. -
  2210. /* Returns a formatted header line.
  2211. -
  2212. * @access private
  2213. -
  2214. * @return string
  2215. -
  2216. */
  2217. -
  2218. function HeaderLine($name, $value) {
  2219. -
  2220. return $name . ': ' . $value . $this->LE;
  2221. -
  2222. }
  2223. -
  2224.  
  2225. -
  2226. /**
  2227. -
  2228. * Returns a formatted mail line.
  2229. -
  2230. * @access private
  2231. -
  2232. * @return string
  2233. -
  2234. */
  2235. -
  2236. function TextLine($value) {
  2237. -
  2238. return $value . $this->LE;
  2239. -
  2240. }
  2241. -
  2242.  
  2243. -
  2244. /////////////////////////////////////////////////
  2245. -
  2246. // CLASS METHODS, ATTACHMENTS
  2247. -
  2248. /////////////////////////////////////////////////
  2249. -
  2250.  
  2251. -
  2252. -
  2253.  
  2254. -
  2255. /**
  2256. -
  2257. * Adds an attachment from a path on the filesystem.
  2258. -
  2259. * Returns false if the file could not be found
  2260. -
  2261. * or accessed.
  2262. -
  2263. * @param string $path Path to the attachment.
  2264. -
  2265. * @param string $name Overrides the attachment name.
  2266. -
  2267. * @param string $encoding File encoding (see $Encoding).
  2268. -
  2269. * @param string $type File extension (MIME) type.
  2270. -
  2271. * @return bool
  2272. -
  2273. */
  2274. -
  2275. function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2276. -
  2277. if(!@is_file($path)) {
  2278. -
  2279. $this->SetError($this->Lang('file_access') . $path);
  2280. -
  2281. return false;
  2282. -
  2283. }
  2284. -
  2285.  
  2286. -
  2287. $filename = basename($path);
  2288. -
  2289. if($name == '') {
  2290. -
  2291. $name = $filename;
  2292. -
  2293. }
  2294. -
  2295.  
  2296. -
  2297. $cur = count($this->attachment);
  2298. -
  2299. $this->attachment[$cur][0] = $path;
  2300. -
  2301. $this->attachment[$cur][1] = $filename;
  2302. -
  2303. $this->attachment[$cur][2] = $name;
  2304. -
  2305. $this->attachment[$cur][3] = $encoding;
  2306. -
  2307. $this->attachment[$cur][4] = $type;
  2308. -
  2309. $this->attachment[$cur][5] = false; // isStringAttachment
  2310. -
  2311. $this->attachment[$cur][6] = 'attachment';
  2312. -
  2313. $this->attachment[$cur][7] = 0;
  2314. -
  2315.  
  2316. -
  2317. return true;
  2318. -
  2319. }
  2320. -
  2321.  
  2322. -
  2323. /**
  2324. -
  2325. * Attaches all fs, string, and binary attachments to the message.
  2326. -
  2327. * Returns an empty string on failure.
  2328. -
  2329. * @access private
  2330. -
  2331. * @return string
  2332. -
  2333. */
  2334. -
  2335. function AttachAll() {
  2336. -
  2337. /* Return text of body */
  2338. -
  2339. $mime = array();
  2340. -
  2341.  
  2342. -
  2343. /* Add all attachments */
  2344. -
  2345. for($i = 0; $i < count($this->attachment); $i++) {
  2346. -
  2347. /* Check for string attachment */
  2348. -
  2349. $bString = $this->attachment[$i][5];
  2350. -
  2351. if ($bString) {
  2352. -
  2353. $string = $this->attachment[$i][0];
  2354. -
  2355. } else {
  2356. -
  2357. $path = $this->attachment[$i][0];
  2358. -
  2359. }
  2360. -
  2361.  
  2362. -
  2363. $filename = $this->attachment[$i][1];
  2364. -
  2365. $name = $this->attachment[$i][2];
  2366. -
  2367. $encoding = $this->attachment[$i][3];
  2368. -
  2369. $type = $this->attachment[$i][4];
  2370. -
  2371. $disposition = $this->attachment[$i][6];
  2372. -
  2373. $cid = $this->attachment[$i][7];
  2374. -
  2375.  
  2376. -
  2377. $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
  2378. -
  2379. $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE);
  2380. -
  2381. $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
  2382. -
  2383.  
  2384. -
  2385. if($disposition == 'inline') {
  2386. -
  2387. $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
  2388. -
  2389. }
  2390. -
  2391.  
  2392. -
  2393. $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE);
  2394. -
  2395.  
  2396. -
  2397. /* Encode as string attachment */
  2398. -
  2399. if($bString) {
  2400. -
  2401. $mime[] = $this->EncodeString($string, $encoding);
  2402. -
  2403. if($this->IsError()) {
  2404. -
  2405. return '';
  2406. -
  2407. }
  2408. -
  2409. $mime[] = $this->LE.$this->LE;
  2410. -
  2411. } else {
  2412. -
  2413. $mime[] = $this->EncodeFile($path, $encoding);
  2414. -
  2415. if($this->IsError()) {
  2416. -
  2417. return '';
  2418. -
  2419. }
  2420. -
  2421. $mime[] = $this->LE.$this->LE;
  2422. -
  2423. }
  2424. -
  2425. }
  2426. -
  2427.  
  2428. -
  2429. $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);
  2430. -
  2431.  
  2432. -
  2433. return join('', $mime);
  2434. -
  2435. }
  2436. -
  2437.  
  2438. -
  2439. /**
  2440. -
  2441. * Encodes attachment in requested format. Returns an
  2442. -
  2443. * empty string on failure.
  2444. -
  2445. * @access private
  2446. -
  2447. * @return string
  2448. -
  2449. */
  2450. -
  2451. function EncodeFile ($path, $encoding = 'base64') {
  2452. -
  2453. if(!@$fd = fopen($path, 'rb')) {
  2454. -
  2455. $this->SetError($this->Lang('file_open') . $path);
  2456. -
  2457. return '';
  2458. -
  2459. }
  2460. -
  2461. $magic_quotes = get_magic_quotes_runtime();
  2462. -
  2463. set_magic_quotes_runtime(0);
  2464. -
  2465. $file_buffer = fread($fd, filesize($path));
  2466. -
  2467. $file_buffer = $this->EncodeString($file_buffer, $encoding);
  2468. -
  2469. fclose($fd);
  2470. -
  2471. set_magic_quotes_runtime($magic_quotes);
  2472. -
  2473.  
  2474. -
  2475. return $file_buffer;
  2476. -
  2477. }
  2478. -
  2479.  
  2480. -
  2481. /**
  2482. -
  2483. * Encodes string to requested format. Returns an
  2484. -
  2485. * empty string on failure.
  2486. -
  2487. * @access private
  2488. -
  2489. * @return string
  2490. -
  2491. */
  2492. -
  2493. function EncodeString ($str, $encoding = 'base64') {
  2494. -
  2495. $encoded = '';
  2496. -
  2497. switch(strtolower($encoding)) {
  2498. -
  2499. case 'base64':
  2500. -
  2501. /* chunk_split is found in PHP >= 3.0.6 */
  2502. -
  2503. $encoded = chunk_split(base64_encode($str), 76, $this->LE);
  2504. -
  2505. break;
  2506. -
  2507. case '7bit':
  2508. -
  2509. case '8bit':
  2510. -
  2511. $encoded = $this->FixEOL($str);
  2512. -
  2513. if (substr($encoded, -(strlen($this->LE))) != $this->LE)
  2514. -
  2515. $encoded .= $this->LE;
  2516. -
  2517. break;
  2518. -
  2519. case 'binary':
  2520. -
  2521. $encoded = $str;
  2522. -
  2523. break;
  2524. -
  2525. case 'quoted-printable':
  2526. -
  2527. $encoded = $this->EncodeQP($str);
  2528. -
  2529. break;
  2530. -
  2531. default:
  2532. -
  2533. $this->SetError($this->Lang('encoding') . $encoding);
  2534. -
  2535. break;
  2536. -
  2537. }
  2538. -
  2539. return $encoded;
  2540. -
  2541. }
  2542. -
  2543.  
  2544. -
  2545. /**
  2546. -
  2547. * Encode a header string to best of Q, B, quoted or none.
  2548. -
  2549. * @access private
  2550. -
  2551. * @return string
  2552. -
  2553. */
  2554. -
  2555. function EncodeHeader ($str, $position = 'text') {
  2556. -
  2557. $x = 0;
  2558. -
  2559.  
  2560. -
  2561. switch (strtolower($position)) {
  2562. -
  2563. case 'phrase':
  2564. -
  2565. if (!preg_match('/[\200-\377]/', $str)) {
  2566. -
  2567. /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */
  2568. -
  2569. $encoded = addcslashes($str, "\0..\37\177\\\"");
  2570. -
  2571. if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
  2572. -
  2573. return ($encoded);
  2574. -
  2575. } else {
  2576. -
  2577. return ("\"$encoded\"");
  2578. -
  2579. }
  2580. -
  2581. }
  2582. -
  2583. $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
  2584. -
  2585. break;
  2586. -
  2587. case 'comment':
  2588. -
  2589. $x = preg_match_all('/[()"]/', $str, $matches);
  2590. -
  2591. /* Fall-through */
  2592. -
  2593. case 'text':
  2594. -
  2595. default:
  2596. -
  2597. $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
  2598. -
  2599. break;
  2600. -
  2601. }
  2602. -
  2603.  
  2604. -
  2605. if ($x == 0) {
  2606. -
  2607. return ($str);
  2608. -
  2609. }
  2610. -
  2611.  
  2612. -
  2613. $maxlen = 75 - 7 - strlen($this->CharSet);
  2614. -
  2615. /* Try to select the encoding which should produce the shortest output */
  2616. -
  2617. if (strlen($str)/3 < $x) {
  2618. -
  2619. $encoding = 'B';
  2620. -
  2621. if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
  2622. -
  2623. // Use a custom function which correctly encodes and wraps long
  2624. -
  2625. // multibyte strings without breaking lines within a character
  2626. -
  2627. $encoded = $this->Base64EncodeWrapMB($str);
  2628. -
  2629. } else {
  2630. -
  2631. $encoded = base64_encode($str);
  2632. -
  2633. $maxlen -= $maxlen % 4;
  2634. -
  2635. $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
  2636. -
  2637. }
  2638. -
  2639. } else {
  2640. -
  2641. $encoding = 'Q';
  2642. -
  2643. $encoded = $this->EncodeQ($str, $position);
  2644. -
  2645. $encoded = $this->WrapText($encoded, $maxlen, true);
  2646. -
  2647. $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
  2648. -
  2649. }
  2650. -
  2651.  
  2652. -
  2653. $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
  2654. -
  2655. $encoded = trim(str_replace("\n", $this->LE, $encoded));
  2656. -
  2657.  
  2658. -
  2659. return $encoded;
  2660. -
  2661. }
  2662. -
  2663.  
  2664. -
  2665. /**
  2666. -
  2667. * Checks if a string contains multibyte characters.
  2668. -
  2669. * @access private
  2670. -
  2671. * @param string $str multi-byte text to wrap encode
  2672. -
  2673. * @return bool
  2674. -
  2675. */
  2676. -
  2677. function HasMultiBytes($str) {
  2678. -
  2679. if (function_exists('mb_strlen')) {
  2680. -
  2681. return (strlen($str) > mb_strlen($str, $this->CharSet));
  2682. -
  2683. } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
  2684. -
  2685. return False;
  2686. -
  2687. }
  2688. -
  2689. }
  2690. -
  2691.  
  2692. -
  2693. /**
  2694. -
  2695. * Correctly encodes and wraps long multibyte strings for mail headers
  2696. -
  2697. * without breaking lines within a character.
  2698. -
  2699. * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
  2700. -
  2701. * @access private
  2702. -
  2703. * @param string $str multi-byte text to wrap encode
  2704. -
  2705. * @return string
  2706. -
  2707. */
  2708. -
  2709. function Base64EncodeWrapMB($str) {
  2710. -
  2711. $start = "=?".$this->CharSet."?B?";
  2712. -
  2713. $end = "?=";
  2714. -
  2715. $encoded = "";
  2716. -
  2717.  
  2718. -
  2719. $mb_length = mb_strlen($str, $this->CharSet);
  2720. -
  2721. // Each line must have length <= 75, including $start and $end
  2722. -
  2723. $length = 75 - strlen($start) - strlen($end);
  2724. -
  2725. // Average multi-byte ratio
  2726. -
  2727. $ratio = $mb_length / strlen($str);
  2728. -
  2729. // Base64 has a 4:3 ratio
  2730. -
  2731. $offset = $avgLength = floor($length * $ratio * .75);
  2732. -
  2733.  
  2734. -
  2735. for ($i = 0; $i < $mb_length; $i += $offset) {
  2736. -
  2737. $lookBack = 0;
  2738. -
  2739.  
  2740. -
  2741. do {
  2742. -
  2743. $offset = $avgLength - $lookBack;
  2744. -
  2745. $chunk = mb_substr($str, $i, $offset, $this->CharSet);
  2746. -
  2747. $chunk = base64_encode($chunk);
  2748. -
  2749. $lookBack++;
  2750. -
  2751. }
  2752. -
  2753. while (strlen($chunk) > $length);
  2754. -
  2755.  
  2756. -
  2757. $encoded .= $chunk . $this->LE;
  2758. -
  2759. }
  2760. -
  2761.  
  2762. -
  2763. // Chomp the last linefeed
  2764. -
  2765. $encoded = substr($encoded, 0, -strlen($this->LE));
  2766. -
  2767. return $encoded;
  2768. -
  2769. }
  2770. -
  2771.  
  2772. -
  2773. /**
  2774. -
  2775. * Encode string to quoted-printable.
  2776. -
  2777. * @access private
  2778. -
  2779. * @return string
  2780. -
  2781. */
  2782. -
  2783. function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) {
  2784. -
  2785. $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
  2786. -
  2787. $lines = preg_split('/(?:\r\n|\r|\n)/', $input);
  2788. -
  2789. $eol = "\r\n";
  2790. -
  2791. $escape = '=';
  2792. -
  2793. $output = '';
  2794. -
  2795. while( list(, $line) = each($lines) ) {
  2796. -
  2797. $linlen = strlen($line);
  2798. -
  2799. $newline = '';
  2800. -
  2801. for($i = 0; $i < $linlen; $i++) {
  2802. -
  2803. $c = substr( $line, $i, 1 );
  2804. -
  2805. $dec = ord( $c );
  2806. -
  2807. if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E
  2808. -
  2809. $c = '=2E';
  2810. -
  2811. }
  2812. -
  2813. if ( $dec == 32 ) {
  2814. -
  2815. if ( $i == ( $linlen - 1 ) ) { // convert space at eol only
  2816. -
  2817. $c = '=20';
  2818. -
  2819. } else if ( $space_conv ) {
  2820. -
  2821. $c = '=20';
  2822. -
  2823. }
  2824. -
  2825. } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
  2826. -
  2827. $h2 = floor($dec/16);
  2828. -
  2829. $h1 = floor($dec%16);
  2830. -
  2831. $c = $escape.$hex[$h2].$hex[$h1];
  2832. -
  2833. }
  2834. -
  2835. if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
  2836. -
  2837. $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
  2838. -
  2839. $newline = '';
  2840. -
  2841. // check if newline first character will be point or not
  2842. -
  2843. if ( $dec == 46 ) {
  2844. -
  2845. $c = '=2E';
  2846. -
  2847. }
  2848. -
  2849. }
  2850. -
  2851. $newline .= $c;
  2852. -
  2853. } // end of for
  2854. -
  2855. $output .= $newline.$eol;
  2856. -
  2857. } // end of while
  2858. -
  2859. return $output;
  2860. -
  2861. }
  2862. -
  2863.  
  2864. -
  2865. /**
  2866. -
  2867. * Encode string to q encoding.
  2868. -
  2869. * @access private
  2870. -
  2871. * @return string
  2872. -
  2873. */
  2874. -
  2875. function EncodeQ ($str, $position = 'text') {
  2876. -
  2877. /* There should not be any EOL in the string */
  2878. -
  2879. $encoded = preg_replace("[\r\n]", '', $str);
  2880. -
  2881.  
  2882. -
  2883. switch (strtolower($position)) {
  2884. -
  2885. case 'phrase':
  2886. -
  2887. $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2888. -
  2889. break;
  2890. -
  2891. case 'comment':
  2892. -
  2893. $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2894. -
  2895. case 'text':
  2896. -
  2897. default:
  2898. -
  2899. /* Replace every high ascii, control =, ? and _ characters */
  2900. -
  2901. $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
  2902. -
  2903. "'='.sprintf('%02X', ord('\\1'))", $encoded);
  2904. -
  2905. break;
  2906. -
  2907. }
  2908. -
  2909.  
  2910. -
  2911. /* Replace every spaces to _ (more readable than =20) */
  2912. -
  2913. $encoded = str_replace(' ', '_', $encoded);
  2914. -
  2915.  
  2916. -
  2917. return $encoded;
  2918. -
  2919. }
  2920. -
  2921.  
  2922. -
  2923. /**
  2924. -
  2925. * Adds a string or binary attachment (non-filesystem) to the list.
  2926. -
  2927. * This method can be used to attach ascii or binary data,
  2928. -
  2929. * such as a BLOB record from a database.
  2930. -
  2931. * @param string $string String attachment data.
  2932. -
  2933. * @param string $filename Name of the attachment.
  2934. -
  2935. * @param string $encoding File encoding (see $Encoding).
  2936. -
  2937. * @param string $type File extension (MIME) type.
  2938. -
  2939. * @return void
  2940. -
  2941. */
  2942. -
  2943. function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') {
  2944. -
  2945. /* Append to $attachment array */
  2946. -
  2947. $cur = count($this->attachment);
  2948. -
  2949. $this->attachment[$cur][0] = $string;
  2950. -
  2951. $this->attachment[$cur][1] = $filename;
  2952. -
  2953. $this->attachment[$cur][2] = $filename;
  2954. -
  2955. $this->attachment[$cur][3] = $encoding;
  2956. -
  2957. $this->attachment[$cur][4] = $type;
  2958. -
  2959. $this->attachment[$cur][5] = true; // isString
  2960. -
  2961. $this->attachment[$cur][6] = 'attachment';
  2962. -
  2963. $this->attachment[$cur][7] = 0;
  2964. -
  2965. }
  2966. -
  2967.  
  2968. -
  2969. /**
  2970. -
  2971. * Adds an embedded attachment. This can include images, sounds, and
  2972. -
  2973. * just about any other document. Make sure to set the $type to an
  2974. -
  2975. * image type. For JPEG images use "image/jpeg" and for GIF images
  2976. -
  2977. * use "image/gif".
  2978. -
  2979. * @param string $path Path to the attachment.
  2980. -
  2981. * @param string $cid Content ID of the attachment. Use this to identify
  2982. -
  2983. * the Id for accessing the image in an HTML form.
  2984. -
  2985. * @param string $name Overrides the attachment name.
  2986. -
  2987. * @param string $encoding File encoding (see $Encoding).
  2988. -
  2989. * @param string $type File extension (MIME) type.
  2990. -
  2991. * @return bool
  2992. -
  2993. */
  2994. -
  2995. function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
  2996. -
  2997.  
  2998. -
  2999. if(!@is_file($path)) {
  3000. -
  3001. $this->SetError($this->Lang('file_access') . $path);
  3002. -
  3003. return false;
  3004. -
  3005. }
  3006. -
  3007.  
  3008. -
  3009. $filename = basename($path);
  3010. -
  3011. if($name == '') {
  3012. -
  3013. $name = $filename;
  3014. -
  3015. }
  3016. -
  3017.  
  3018. -
  3019. /* Append to $attachment array */
  3020. -
  3021. $cur = count($this->attachment);
  3022. -
  3023. $this->attachment[$cur][0] = $path;
  3024. -
  3025. $this->attachment[$cur][1] = $filename;
  3026. -
  3027. $this->attachment[$cur][2] = $name;
  3028. -
  3029. $this->attachment[$cur][3] = $encoding;
  3030. -
  3031. $this->attachment[$cur][4] = $type;
  3032. -
  3033. $this->attachment[$cur][5] = false;
  3034. -
  3035. $this->attachment[$cur][6] = 'inline';
  3036. -
  3037. $this->attachment[$cur][7] = $cid;
  3038. -
  3039.  
  3040. -
  3041. return true;
  3042. -
  3043. }
  3044. -
  3045.  
  3046. -
  3047. /**
  3048. -
  3049. * Returns true if an inline attachment is present.
  3050. -
  3051. * @access private
  3052. -
  3053. * @return bool
  3054. -
  3055. */
  3056. -
  3057. function InlineImageExists() {
  3058. -
  3059. $result = false;
  3060. -
  3061. for($i = 0; $i < count($this->attachment); $i++) {
  3062. -
  3063. if($this->attachment[$i][6] == 'inline') {
  3064. -
  3065. $result = true;
  3066. -
  3067. break;
  3068. -
  3069. }
  3070. -
  3071. }
  3072. -
  3073.  
  3074. -
  3075. return $result;
  3076. -
  3077. }
  3078. -
  3079.  
  3080. -
  3081. /////////////////////////////////////////////////
  3082. -
  3083. // CLASS METHODS, MESSAGE RESET
  3084. -
  3085. /////////////////////////////////////////////////
  3086. -
  3087.  
  3088. -
  3089. -
  3090.  
  3091. -
  3092. /**
  3093. -
  3094. * Clears all recipients assigned in the TO array. Returns void.
  3095. -
  3096. * @return void
  3097. -
  3098. */
  3099. -
  3100. function ClearAddresses() {
  3101. -
  3102. $this->to = array();
  3103. -
  3104. }
  3105. -
  3106.  
  3107. -
  3108. /**
  3109. -
  3110. * Clears all recipients assigned in the CC array. Returns void.
  3111. -
  3112. * @return void
  3113. -
  3114. */
  3115. -
  3116. function ClearCCs() {
  3117. -
  3118. $this->cc = array();
  3119. -
  3120. }
  3121. -
  3122.  
  3123. -
  3124. /**
  3125. -
  3126. * Clears all recipients assigned in the BCC array. Returns void.
  3127. -
  3128. * @return void
  3129. -
  3130. */
  3131. -
  3132. function ClearBCCs() {
  3133. -
  3134. $this->bcc = array();
  3135. -
  3136. }
  3137. -
  3138.  
  3139. -
  3140. /**
  3141. -
  3142. * Clears all recipients assigned in the ReplyTo array. Returns void.
  3143. -
  3144. * @return void
  3145. -
  3146. */
  3147. -
  3148. function ClearReplyTos() {
  3149. -
  3150. $this->ReplyTo = array();
  3151. -
  3152. }
  3153. -
  3154.  
  3155. -
  3156. /**
  3157. -
  3158. * Clears all recipients assigned in the TO, CC and BCC
  3159. -
  3160. * array. Returns void.
  3161. -
  3162. * @return void
  3163. -
  3164. */
  3165. -
  3166. function ClearAllRecipients() {
  3167. -
  3168. $this->to = array();
  3169. -
  3170. $this->cc = array();
  3171. -
  3172. $this->bcc = array();
  3173. -
  3174. }
  3175. -
  3176.  
  3177. -
  3178. /**
  3179. -
  3180. * Clears all previously set filesystem, string, and binary
  3181. -
  3182. * attachments. Returns void.
  3183. -
  3184. * @return void
  3185. -
  3186. */
  3187. -
  3188. function ClearAttachments() {
  3189. -
  3190. $this->attachment = array();
  3191. -
  3192. }
  3193. -
  3194.  
  3195. -
  3196. /**
  3197. -
  3198. * Clears all custom headers. Returns void.
  3199. -
  3200. * @return void
  3201. -
  3202. */
  3203. -
  3204. function ClearCustomHeaders() {
  3205. -
  3206. $this->CustomHeader = array();
  3207. -
  3208. }
  3209. -
  3210.  
  3211. -
  3212. /////////////////////////////////////////////////
  3213. -
  3214. // CLASS METHODS, MISCELLANEOUS
  3215. -
  3216. /////////////////////////////////////////////////
  3217. -
  3218.  
  3219. -
  3220. -
  3221.  
  3222. -
  3223. /**
  3224. -
  3225. * Adds the error message to the error container.
  3226. -
  3227. * Returns void.
  3228. -
  3229. * @access private
  3230. -
  3231. * @return void
  3232. -
  3233. */
  3234. -
  3235. function SetError($msg) {
  3236. -
  3237. $this->error_count++;
  3238. -
  3239. $this->ErrorInfo = $msg;
  3240. -
  3241. }
  3242. -
  3243.  
  3244. -
  3245. /**
  3246. -
  3247. * Returns the proper RFC 822 formatted date.
  3248. -
  3249. * @access private
  3250. -
  3251. * @return string
  3252. -
  3253. */
  3254. -
  3255. function RFCDate() {
  3256. -
  3257. $tz = date('Z');
  3258. -
  3259. $tzs = ($tz < 0) ? '-' : '+';
  3260. -
  3261. $tz = abs($tz);
  3262. -
  3263. $tz = (int)($tz/3600)*100 + ($tz%3600)/60;
  3264. -
  3265. $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
  3266. -
  3267.  
  3268. -
  3269. return $result;
  3270. -
  3271. }
  3272. -
  3273.  
  3274. -
  3275. /**
  3276. -
  3277. * Returns the appropriate server variable. Should work with both
  3278. -
  3279. * PHP 4.1.0+ as well as older versions. Returns an empty string
  3280. -
  3281. * if nothing is found.
  3282. -
  3283. * @access private
  3284. -
  3285. * @return mixed
  3286. -
  3287. */
  3288. -
  3289. function ServerVar($varName) {
  3290. -
  3291. global $HTTP_SERVER_VARS;
  3292. -
  3293. global $HTTP_ENV_VARS;
  3294. -
  3295.  
  3296. -
  3297. if(!isset($_SERVER)) {
  3298. -
  3299. $_SERVER = $HTTP_SERVER_VARS;
  3300. -
  3301. if(!isset($_SERVER['REMOTE_ADDR'])) {
  3302. -
  3303. $_SERVER = $HTTP_ENV_VARS; // must be Apache
  3304. -
  3305. }
  3306. -
  3307. }
  3308. -
  3309.  
  3310. -
  3311. if(isset($_SERVER[$varName])) {
  3312. -
  3313. return $_SERVER[$varName];
  3314. -
  3315. } else {
  3316. -
  3317. return '';
  3318. -
  3319. }
  3320. -
  3321. }
  3322. -
  3323.  
  3324. -
  3325. /**
  3326. -
  3327. * Returns the server hostname or 'localhost.localdomain' if unknown.
  3328. -
  3329. * @access private
  3330. -
  3331. * @return string
  3332. -
  3333. */
  3334. -
  3335. function ServerHostname() {
  3336. -
  3337. if ($this->Hostname != '') {
  3338. -
  3339. $result = $this->Hostname;
  3340. -
  3341. } elseif ($this->ServerVar('SERVER_NAME') != '') {
  3342. -
  3343. $result = $this->ServerVar('SERVER_NAME');
  3344. -
  3345. } else {
  3346. -
  3347. $result = 'localhost.localdomain';
  3348. -
  3349. }
  3350. -
  3351.  
  3352. -
  3353. return $result;
  3354. -
  3355. }
  3356. -
  3357.  
  3358. -
  3359. /**
  3360. -
  3361. * Returns a message in the appropriate language.
  3362. -
  3363. * @access private
  3364. -
  3365. * @return string
  3366. -
  3367. */
  3368. -
  3369. function Lang($key) {
  3370. -
  3371. if(count($this->language) < 1) {
  3372. -
  3373. $this->SetLanguage('en'); // set the default language
  3374. -
  3375. }
  3376. -
  3377.  
  3378. -
  3379. if(isset($this->language[$key])) {
  3380. -
  3381. return $this->language[$key];
  3382. -
  3383. } else {
  3384. -
  3385. return 'Language string failed to load: ' . $key;
  3386. -
  3387. }
  3388. -
  3389. }
  3390. -
  3391.  
  3392. -
  3393. /**
  3394. -
  3395. * Returns true if an error occurred.
  3396. -
  3397. * @return bool
  3398. -
  3399. */
  3400. -
  3401. function IsError() {
  3402. -
  3403. return ($this->error_count > 0);
  3404. -
  3405. }
  3406. -
  3407.  
  3408. -
  3409. /**
  3410. -
  3411. * Changes every end of line from CR or LF to CRLF.
  3412. -
  3413. * @access private
  3414. -
  3415. * @return string
  3416. -
  3417. */
  3418. -
  3419. function FixEOL($str) {
  3420. -
  3421. $str = str_replace("\r\n", "\n", $str);
  3422. -
  3423. $str = str_replace("\r", "\n", $str);
  3424. -
  3425. $str = str_replace("\n", $this->LE, $str);
  3426. -
  3427. return $str;
  3428. -
  3429. }
  3430. -
  3431.  
  3432. -
  3433. /**
  3434. -
  3435. * Adds a custom header.
  3436. -
  3437. * @return void
  3438. -
  3439. */
  3440. -
  3441. function AddCustomHeader($custom_header) {
  3442. -
  3443. $this->CustomHeader[] = explode(':', $custom_header, 2);
  3444. -
  3445. }
  3446. -
  3447.  
  3448. -
  3449. /**
  3450. -
  3451. * Evaluates the message and returns modifications for inline images and backgrounds
  3452. -
  3453. * @access public
  3454. -
  3455. * @return $message
  3456. -
  3457. */
  3458. -
  3459. function MsgHTML($message,$basedir='') {
  3460. -
  3461. preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
  3462. -
  3463. if(isset($images[2])) {
  3464. -
  3465. foreach($images[2] as $i => $url) {
  3466. -
  3467. // do not change urls for absolute images (thanks to corvuscorax)
  3468. -
  3469. if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
  3470. -
  3471. $filename = basename($url);
  3472. -
  3473. $directory = dirname($url);
  3474. -
  3475. ($directory == '.')?$directory='':'';
  3476. -
  3477. $cid = 'cid:' . md5($filename);
  3478. -
  3479. $fileParts = split("\.", $filename);
  3480. -
  3481. $ext = $fileParts[1];
  3482. -
  3483. $mimeType = $this->_mime_types($ext);
  3484. -
  3485. if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; }
  3486. -
  3487. if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; }
  3488. -
  3489. if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) {
  3490. -
  3491. $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message);
  3492. -
  3493. }
  3494. -
  3495. }
  3496. -
  3497. }
  3498. -
  3499. }
  3500. -
  3501. $this->IsHTML(true);
  3502. -
  3503. $this->Body = $message;
  3504. -
  3505. $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
  3506. -
  3507. if ( !empty($textMsg) && empty($this->AltBody) ) {
  3508. -
  3509. $this->AltBody = html_entity_decode($textMsg);
  3510. -
  3511. }
  3512. -
  3513. if ( empty($this->AltBody) ) {
  3514. -
  3515. $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n";
  3516. -
  3517. }
  3518. -
  3519. }
  3520. -
  3521.  
  3522. -
  3523. /**
  3524. -
  3525. * Gets the mime type of the embedded or inline image
  3526. -
  3527. * @access private
  3528. -
  3529. * @return mime type of ext
  3530. -
  3531. */
  3532. -
  3533. function _mime_types($ext = '') {
  3534. -
  3535. $mimes = array(
  3536. -
  3537. 'ai' => 'application/postscript',
  3538. -
  3539. 'aif' => 'audio/x-aiff',
  3540. -
  3541. 'aifc' => 'audio/x-aiff',
  3542. -
  3543. 'aiff' => 'audio/x-aiff',
  3544. -
  3545. 'avi' => 'video/x-msvideo',
  3546. -
  3547. 'bin' => 'application/macbinary',
  3548. -
  3549. 'bmp' => 'image/bmp',
  3550. -
  3551. 'class' => 'application/octet-stream',
  3552. -
  3553. 'cpt' => 'application/mac-compactpro',
  3554. -
  3555. 'css' => 'text/css',
  3556. -
  3557. 'dcr' => 'application/x-director',
  3558. -
  3559. 'dir' => 'application/x-director',
  3560. -
  3561. 'dll' => 'application/octet-stream',
  3562. -
  3563. 'dms' => 'application/octet-stream',
  3564. -
  3565. 'doc' => 'application/msword',
  3566. -
  3567. 'dvi' => 'application/x-dvi',
  3568. -
  3569. 'dxr' => 'application/x-director',
  3570. -
  3571. 'eml' => 'message/rfc822',
  3572. -
  3573. 'eps' => 'application/postscript',
  3574. -
  3575. 'exe' => 'application/octet-stream',
  3576. -
  3577. 'gif' => 'image/gif',
  3578. -
  3579. 'gtar' => 'application/x-gtar',
  3580. -
  3581. 'htm' => 'text/html',
  3582. -
  3583. 'html' => 'text/html',
  3584. -
  3585. 'jpe' => 'image/jpeg',
  3586. -
  3587. 'jpeg' => 'image/jpeg',
  3588. -
  3589. 'jpg' => 'image/jpeg',
  3590. -
  3591. 'hqx' => 'application/mac-binhex40',
  3592. -
  3593. 'js' => 'application/x-javascript',
  3594. -
  3595. 'lha' => 'application/octet-stream',
  3596. -
  3597. 'log' => 'text/plain',
  3598. -
  3599. 'lzh' => 'application/octet-stream',
  3600. -
  3601. 'mid' => 'audio/midi',
  3602. -
  3603. 'midi' => 'audio/midi',
  3604. -
  3605. 'mif' => 'application/vnd.mif',
  3606. -
  3607. 'mov' => 'video/quicktime',
  3608. -
  3609. 'movie' => 'video/x-sgi-movie',
  3610. -
  3611. 'mp2' => 'audio/mpeg',
  3612. -
  3613. 'mp3' => 'audio/mpeg',
  3614. -
  3615. 'mpe' => 'video/mpeg',
  3616. -
  3617. 'mpeg' => 'video/mpeg',
  3618. -
  3619. 'mpg' => 'video/mpeg',
  3620. -
  3621. 'mpga' => 'audio/mpeg',
  3622. -
  3623. 'oda' => 'application/oda',
  3624. -
  3625. 'pdf' => 'application/pdf',
  3626. -
  3627. 'php' => 'application/x-httpd-php',
  3628. -
  3629. 'php3' => 'application/x-httpd-php',
  3630. -
  3631. 'php4' => 'application/x-httpd-php',
  3632. -
  3633. 'phps' => 'application/x-httpd-php-source',
  3634. -
  3635. 'phtml' => 'application/x-httpd-php',
  3636. -
  3637. 'png' => 'image/png',
  3638. -
  3639. 'ppt' => 'application/vnd.ms-powerpoint',
  3640. -
  3641. 'ps' => 'application/postscript',
  3642. -
  3643. 'psd' => 'application/octet-stream',
  3644. -
  3645. 'qt' => 'video/quicktime',
  3646. -
  3647. 'ra' => 'audio/x-realaudio',
  3648. -
  3649. 'ram' => 'audio/x-pn-realaudio',
  3650. -
  3651. 'rm' => 'audio/x-pn-realaudio',
  3652. -
  3653. 'rpm' => 'audio/x-pn-realaudio-plugin',
  3654. -
  3655. 'rtf' => 'text/rtf',
  3656. -
  3657. 'rtx' => 'text/richtext',
  3658. -
  3659. 'rv' => 'video/vnd.rn-realvideo',
  3660. -
  3661. 'sea' => 'application/octet-stream',
  3662. -
  3663. 'shtml' => 'text/html',
  3664. -
  3665. 'sit' => 'application/x-stuffit',
  3666. -
  3667. 'so' => 'application/octet-stream',
  3668. -
  3669. 'smi' => 'application/smil',
  3670. -
  3671. 'smil' => 'application/smil',
  3672. -
  3673. 'swf' => 'application/x-shockwave-flash',
  3674. -
  3675. 'tar' => 'application/x-tar',
  3676. -
  3677. 'text' => 'text/plain',
  3678. -
  3679. 'txt' => 'text/plain',
  3680. -
  3681. 'tgz' => 'application/x-tar',
  3682. -
  3683. 'tif' => 'image/tiff',
  3684. -
  3685. 'tiff' => 'image/tiff',
  3686. -
  3687. 'wav' => 'audio/x-wav',
  3688. -
  3689. 'wbxml' => 'application/vnd.wap.wbxml',
  3690. -
  3691. 'wmlc' => 'application/vnd.wap.wmlc',
  3692. -
  3693. 'word' => 'application/msword',
  3694. -
  3695. 'xht' => 'application/xhtml+xml',
  3696. -
  3697. 'xhtml' => 'application/xhtml+xml',
  3698. -
  3699. 'xl' => 'application/excel',
  3700. -
  3701. 'xls' => 'application/vnd.ms-excel',
  3702. -
  3703. 'xml' => 'text/xml',
  3704. -
  3705. 'xsl' => 'text/xml',
  3706. -
  3707. 'zip' => 'application/zip'
  3708. -
  3709. );
  3710. -
  3711. return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
  3712. -
  3713. }
  3714. -
  3715.  
  3716. -
  3717. /**
  3718. -
  3719. * Set (or reset) Class Objects (variables)
  3720. -
  3721. *
  3722. -
  3723. * Usage Example:
  3724. -
  3725. * $page->set('X-Priority', '3');
  3726. -
  3727. *
  3728. -
  3729. * @access public
  3730. -
  3731. * @param string $name Parameter Name
  3732. -
  3733. * @param mixed $value Parameter Value
  3734. -
  3735. * NOTE: will not work with arrays, there are no arrays to set/reset
  3736. -
  3737. */
  3738. -
  3739. function set ( $name, $value = '' ) {
  3740. -
  3741. if ( isset($this->$name) ) {
  3742. -
  3743. $this->$name = $value;
  3744. -
  3745. } else {
  3746. -
  3747. $this->SetError('Cannot set or reset variable ' . $name);
  3748. -
  3749. return false;
  3750. -
  3751. }
  3752. -
  3753. }
  3754. -
  3755.  
  3756. -
  3757. /**
  3758. -
  3759. * Read a file from a supplied filename and return it.
  3760. -
  3761. *
  3762. -
  3763. * @access public
  3764. -
  3765. * @param string $filename Parameter File Name
  3766. -
  3767. */
  3768. -
  3769. function getFile($filename) {
  3770. -
  3771. $return = '';
  3772. -
  3773. if ($fp = fopen($filename, 'rb')) {
  3774. -
  3775. while (!feof($fp)) {
  3776. -
  3777. $return .= fread($fp, 1024);
  3778. -
  3779. }
  3780. -
  3781. fclose($fp);
  3782. -
  3783. return $return;
  3784. -
  3785. } else {
  3786. -
  3787. return false;
  3788. -
  3789. }
  3790. -
  3791. }
  3792. -
  3793.  
  3794. -
  3795. /**
  3796. -
  3797. * Strips newlines to prevent header injection.
  3798. -
  3799. * @access private
  3800. -
  3801. * @param string $str String
  3802. -
  3803. * @return string
  3804. -
  3805. */
  3806. -
  3807. function SecureHeader($str) {
  3808. -
  3809. $str = trim($str);
  3810. -
  3811. $str = str_replace("\r", "", $str);
  3812. -
  3813. $str = str_replace("\n", "", $str);
  3814. -
  3815. return $str;
  3816. -
  3817. }
  3818. -
  3819.  
  3820. -
  3821. /**
  3822. -
  3823. * Set the private key file and password to sign the message.
  3824. -
  3825. *
  3826. -
  3827. * @access public
  3828. -
  3829. * @param string $key_filename Parameter File Name
  3830. -
  3831. * @param string $key_pass Password for private key
  3832. -
  3833. */
  3834. -
  3835. function Sign($cert_filename, $key_filename, $key_pass) {
  3836. -
  3837. $this->sign_cert_file = $cert_filename;
  3838. -
  3839. $this->sign_key_file = $key_filename;
  3840. -
  3841. $this->sign_key_pass = $key_pass;
  3842. -
  3843. }
  3844. -
  3845.  
  3846. -
  3847. }
  3848. -
  3849.  
  3850. -
  3851. ?>
  3852. -
-
-

- Documentation generated on Thu, 02 Apr 2009 21:19:47 -0400 by phpDocumentor 1.3.0RC3 -

- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.pop3.php.html b/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.pop3.php.html deleted file mode 100644 index 3fbc19de2..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.pop3.php.html +++ /dev/null @@ -1,460 +0,0 @@ - - - - - - File Source for class.pop3.php - - - - -

Source for file class.pop3.php

-

Documentation is available at class.pop3.php

-
-
  1. <?php
  2. -
  3. /*~ class.pop3.php
  4. -
  5. .---------------------------------------------------------------------------.
  6. -
  7. | Software: PHPMailer - PHP email class |
  8. -
  9. | Version: 2.0.4 |
  10. -
  11. | Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
  12. -
  13. | Info: http://phpmailer.sourceforge.net |
  14. -
  15. | Support: http://sourceforge.net/projects/phpmailer/ |
  16. -
  17. | ------------------------------------------------------------------------- |
  18. -
  19. | Author: Andy Prevost (project admininistrator) |
  20. -
  21. | Author: Brent R. Matzelle (original founder) |
  22. -
  23. | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
  24. -
  25. | Copyright (c) 2001-2003, Brent R. Matzelle |
  26. -
  27. | ------------------------------------------------------------------------- |
  28. -
  29. | License: Distributed under the Lesser General Public License (LGPL) |
  30. -
  31. | http://www.gnu.org/copyleft/lesser.html |
  32. -
  33. | This program is distributed in the hope that it will be useful - WITHOUT |
  34. -
  35. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
  36. -
  37. | FITNESS FOR A PARTICULAR PURPOSE. |
  38. -
  39. | ------------------------------------------------------------------------- |
  40. -
  41. | We offer a number of paid services (www.codeworxtech.com): |
  42. -
  43. | - Web Hosting on highly optimized fast and secure servers |
  44. -
  45. | - Technology Consulting |
  46. -
  47. | - Oursourcing (highly qualified programmers and graphic designers) |
  48. -
  49. '---------------------------------------------------------------------------'
  50. -
  51.  
  52. -
  53.  
  54. -
  55.  
  56. -
  57. /**
  58. -
  59. * POP Before SMTP Authentication Class
  60. -
  61. *
  62. -
  63. * Author: Richard Davey (rich@corephp.co.uk)
  64. -
  65. * License: LGPL, see PHPMailer License
  66. -
  67. *
  68. -
  69. * Specifically for PHPMailer to allow POP before SMTP authentication.
  70. -
  71. * Does not yet work with APOP - if you have an APOP account, contact me
  72. -
  73. * and we can test changes to this script.
  74. -
  75. *
  76. -
  77. * This class is based on the structure of the SMTP class by Chris Ryan
  78. -
  79. *
  80. -
  81. * This class is rfc 1939 compliant and implements all the commands
  82. -
  83. * required for POP3 connection, authentication and disconnection.
  84. -
  85. *
  86. -
  87. * @package PHPMailer
  88. -
  89. * @author Richard Davey
  90. -
  91. */
  92. -
  93.  
  94. -
  95. class POP3
  96. -
  97. {
  98. -
  99. /**
  100. -
  101. * Default POP3 port
  102. -
  103. * @var int
  104. -
  105. */
  106. -
  107. var $POP3_PORT = 110;
  108. -
  109.  
  110. -
  111. /**
  112. -
  113. * Default Timeout
  114. -
  115. * @var int
  116. -
  117. */
  118. -
  119. var $POP3_TIMEOUT = 30;
  120. -
  121.  
  122. -
  123. /**
  124. -
  125. * POP3 Carriage Return + Line Feed
  126. -
  127. * @var string
  128. -
  129. */
  130. -
  131. var $CRLF = "\r\n";
  132. -
  133.  
  134. -
  135. /**
  136. -
  137. * Displaying Debug warnings? (0 = now, 1+ = yes)
  138. -
  139. * @var int
  140. -
  141. */
  142. -
  143. var $do_debug = 2;
  144. -
  145.  
  146. -
  147. /**
  148. -
  149. * POP3 Mail Server
  150. -
  151. * @var string
  152. -
  153. */
  154. -
  155. var $host;
  156. -
  157.  
  158. -
  159. /**
  160. -
  161. * POP3 Port
  162. -
  163. * @var int
  164. -
  165. */
  166. -
  167. var $port;
  168. -
  169.  
  170. -
  171. /**
  172. -
  173. * POP3 Timeout Value
  174. -
  175. * @var int
  176. -
  177. */
  178. -
  179. var $tval;
  180. -
  181.  
  182. -
  183. /**
  184. -
  185. * POP3 Username
  186. -
  187. * @var string
  188. -
  189. */
  190. -
  191. var $username;
  192. -
  193.  
  194. -
  195. /**
  196. -
  197. * POP3 Password
  198. -
  199. * @var string
  200. -
  201. */
  202. -
  203. var $password;
  204. -
  205.  
  206. -
  207. /**#@+
  208. -
  209. * @access private
  210. -
  211. */
  212. -
  213. var $pop_conn;
  214. -
  215. var $connected;
  216. -
  217. var $error; // Error log array
  218. -
  219. -
  220. /**#@-*/
  221. -
  222.  
  223. -
  224. /**
  225. -
  226. * Constructor, sets the initial values
  227. -
  228. *
  229. -
  230. * @return POP3
  231. -
  232. */
  233. -
  234. function POP3 ()
  235. -
  236. {
  237. -
  238. $this->pop_conn = 0;
  239. -
  240. $this->connected = false;
  241. -
  242. $this->error = null;
  243. -
  244. }
  245. -
  246.  
  247. -
  248. /**
  249. -
  250. * Combination of public events - connect, login, disconnect
  251. -
  252. *
  253. -
  254. * @param string $host
  255. -
  256. * @param integer $port
  257. -
  258. * @param integer $tval
  259. -
  260. * @param string $username
  261. -
  262. * @param string $password
  263. -
  264. */
  265. -
  266. function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0)
  267. -
  268. {
  269. -
  270. $this->host = $host;
  271. -
  272.  
  273. -
  274. // If no port value is passed, retrieve it
  275. -
  276. if ($port == false)
  277. -
  278. {
  279. -
  280. $this->port = $this->POP3_PORT;
  281. -
  282. }
  283. -
  284. else
  285. -
  286. {
  287. -
  288. $this->port = $port;
  289. -
  290. }
  291. -
  292.  
  293. -
  294. // If no port value is passed, retrieve it
  295. -
  296. if ($tval == false)
  297. -
  298. {
  299. -
  300. $this->tval = $this->POP3_TIMEOUT;
  301. -
  302. }
  303. -
  304. else
  305. -
  306. {
  307. -
  308. $this->tval = $tval;
  309. -
  310. }
  311. -
  312.  
  313. -
  314. $this->do_debug = $debug_level;
  315. -
  316. $this->username = $username;
  317. -
  318. $this->password = $password;
  319. -
  320.  
  321. -
  322. // Refresh the error log
  323. -
  324. $this->error = null;
  325. -
  326.  
  327. -
  328. // Connect
  329. -
  330. $result = $this->Connect($this->host, $this->port, $this->tval);
  331. -
  332.  
  333. -
  334. if ($result)
  335. -
  336. {
  337. -
  338. $login_result = $this->Login($this->username, $this->password);
  339. -
  340.  
  341. -
  342. if ($login_result)
  343. -
  344. {
  345. -
  346. $this->Disconnect();
  347. -
  348.  
  349. -
  350. return true;
  351. -
  352. }
  353. -
  354.  
  355. -
  356. }
  357. -
  358.  
  359. -
  360. // We need to disconnect regardless if the login succeeded
  361. -
  362. $this->Disconnect();
  363. -
  364.  
  365. -
  366. return false;
  367. -
  368. }
  369. -
  370.  
  371. -
  372. /**
  373. -
  374. * Connect to the POP3 server
  375. -
  376. *
  377. -
  378. * @param string $host
  379. -
  380. * @param integer $port
  381. -
  382. * @param integer $tval
  383. -
  384. * @return boolean
  385. -
  386. */
  387. -
  388. function Connect ($host, $port = false, $tval = 30)
  389. -
  390. {
  391. -
  392. // Are we already connected?
  393. -
  394. if ($this->connected)
  395. -
  396. {
  397. -
  398. return true;
  399. -
  400. }
  401. -
  402.  
  403. -
  404. /*
  405. -
  406. On Windows this will raise a PHP Warning error if the hostname doesn't exist.
  407. -
  408. Rather than supress it with @fsockopen, let's capture it cleanly instead
  409. -
  410. */
  411. -
  412.  
  413. -
  414. set_error_handler(array(&$this, 'catchWarning'));
  415. -
  416.  
  417. -
  418. // Connect to the POP3 server
  419. -
  420. $this->pop_conn = fsockopen($host, // POP3 Host
  421. -
  422. $port, // Port #
  423. -
  424. $errno, // Error Number
  425. -
  426. $errstr, // Error Message
  427. -
  428. $tval); // Timeout (seconds)
  429. -
  430.  
  431. -
  432. // Restore the error handler
  433. -
  434. restore_error_handler();
  435. -
  436.  
  437. -
  438. // Does the Error Log now contain anything?
  439. -
  440. if ($this->error && $this->do_debug >= 1)
  441. -
  442. {
  443. -
  444. $this->displayErrors();
  445. -
  446. }
  447. -
  448.  
  449. -
  450. // Did we connect?
  451. -
  452. if ($this->pop_conn == false)
  453. -
  454. {
  455. -
  456. // It would appear not...
  457. -
  458. $this->error = array(
  459. -
  460. 'error' => "Failed to connect to server $host on port $port",
  461. -
  462. 'errno' => $errno,
  463. -
  464. 'errstr' => $errstr
  465. -
  466. );
  467. -
  468.  
  469. -
  470. if ($this->do_debug >= 1)
  471. -
  472. {
  473. -
  474. $this->displayErrors();
  475. -
  476. }
  477. -
  478.  
  479. -
  480. return false;
  481. -
  482. }
  483. -
  484.  
  485. -
  486. // Increase the stream time-out
  487. -
  488.  
  489. -
  490. // Check for PHP 4.3.0 or later
  491. -
  492. if (version_compare(phpversion(), '4.3.0', 'ge'))
  493. -
  494. {
  495. -
  496. stream_set_timeout($this->pop_conn, $tval, 0);
  497. -
  498. }
  499. -
  500. else
  501. -
  502. {
  503. -
  504. // Does not work on Windows
  505. -
  506. if (substr(PHP_OS, 0, 3) !== 'WIN')
  507. -
  508. {
  509. -
  510. socket_set_timeout($this->pop_conn, $tval, 0);
  511. -
  512. }
  513. -
  514. }
  515. -
  516.  
  517. -
  518. // Get the POP3 server response
  519. -
  520. $pop3_response = $this->getResponse();
  521. -
  522.  
  523. -
  524. // Check for the +OK
  525. -
  526. if ($this->checkResponse($pop3_response))
  527. -
  528. {
  529. -
  530. // The connection is established and the POP3 server is talking
  531. -
  532. $this->connected = true;
  533. -
  534. return true;
  535. -
  536. }
  537. -
  538.  
  539. -
  540. }
  541. -
  542.  
  543. -
  544. /**
  545. -
  546. * Login to the POP3 server (does not support APOP yet)
  547. -
  548. *
  549. -
  550. * @param string $username
  551. -
  552. * @param string $password
  553. -
  554. * @return boolean
  555. -
  556. */
  557. -
  558. function Login ($username = '', $password = '')
  559. -
  560. {
  561. -
  562. if ($this->connected == false)
  563. -
  564. {
  565. -
  566. $this->error = 'Not connected to POP3 server';
  567. -
  568.  
  569. -
  570. if ($this->do_debug >= 1)
  571. -
  572. {
  573. -
  574. $this->displayErrors();
  575. -
  576. }
  577. -
  578. }
  579. -
  580.  
  581. -
  582. if (empty($username))
  583. -
  584. {
  585. -
  586. $username = $this->username;
  587. -
  588. }
  589. -
  590.  
  591. -
  592. if (empty($password))
  593. -
  594. {
  595. -
  596. $password = $this->password;
  597. -
  598. }
  599. -
  600.  
  601. -
  602. $pop_username = "USER $username" . $this->CRLF;
  603. -
  604. $pop_password = "PASS $password" . $this->CRLF;
  605. -
  606.  
  607. -
  608. // Send the Username
  609. -
  610. $this->sendString($pop_username);
  611. -
  612. $pop3_response = $this->getResponse();
  613. -
  614.  
  615. -
  616. if ($this->checkResponse($pop3_response))
  617. -
  618. {
  619. -
  620. // Send the Password
  621. -
  622. $this->sendString($pop_password);
  623. -
  624. $pop3_response = $this->getResponse();
  625. -
  626.  
  627. -
  628. if ($this->checkResponse($pop3_response))
  629. -
  630. {
  631. -
  632. return true;
  633. -
  634. }
  635. -
  636. else
  637. -
  638. {
  639. -
  640. return false;
  641. -
  642. }
  643. -
  644. }
  645. -
  646. else
  647. -
  648. {
  649. -
  650. return false;
  651. -
  652. }
  653. -
  654. }
  655. -
  656.  
  657. -
  658. /**
  659. -
  660. * Disconnect from the POP3 server
  661. -
  662. */
  663. -
  664. function Disconnect ()
  665. -
  666. {
  667. -
  668. $this->sendString('QUIT');
  669. -
  670.  
  671. -
  672. fclose($this->pop_conn);
  673. -
  674. }
  675. -
  676.  
  677. -
  678. /*
  679. -
  680. ---------------
  681. -
  682. Private Methods
  683. -
  684. ---------------
  685. -
  686. */
  687. -
  688.  
  689. -
  690. /**
  691. -
  692. * Get the socket response back.
  693. -
  694. * $size is the maximum number of bytes to retrieve
  695. -
  696. *
  697. -
  698. * @param integer $size
  699. -
  700. * @return string
  701. -
  702. */
  703. -
  704. function getResponse ($size = 128)
  705. -
  706. {
  707. -
  708. $pop3_response = fgets($this->pop_conn, $size);
  709. -
  710.  
  711. -
  712. return $pop3_response;
  713. -
  714. }
  715. -
  716.  
  717. -
  718. /**
  719. -
  720. * Send a string down the open socket connection to the POP3 server
  721. -
  722. *
  723. -
  724. * @param string $string
  725. -
  726. * @return integer
  727. -
  728. */
  729. -
  730. function sendString ($string)
  731. -
  732. {
  733. -
  734. $bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
  735. -
  736.  
  737. -
  738. return $bytes_sent;
  739. -
  740.  
  741. -
  742. }
  743. -
  744.  
  745. -
  746. /**
  747. -
  748. * Checks the POP3 server response for +OK or -ERR
  749. -
  750. *
  751. -
  752. * @param string $string
  753. -
  754. * @return boolean
  755. -
  756. */
  757. -
  758. function checkResponse ($string)
  759. -
  760. {
  761. -
  762. if (substr($string, 0, 3) !== '+OK')
  763. -
  764. {
  765. -
  766. $this->error = array(
  767. -
  768. 'error' => "Server reported an error: $string",
  769. -
  770. 'errno' => 0,
  771. -
  772. 'errstr' => ''
  773. -
  774. );
  775. -
  776.  
  777. -
  778. if ($this->do_debug >= 1)
  779. -
  780. {
  781. -
  782. $this->displayErrors();
  783. -
  784. }
  785. -
  786.  
  787. -
  788. return false;
  789. -
  790. }
  791. -
  792. else
  793. -
  794. {
  795. -
  796. return true;
  797. -
  798. }
  799. -
  800.  
  801. -
  802. }
  803. -
  804.  
  805. -
  806. /**
  807. -
  808. * If debug is enabled, display the error message array
  809. -
  810. *
  811. -
  812. */
  813. -
  814. function displayErrors ()
  815. -
  816. {
  817. -
  818. echo '<pre>';
  819. -
  820.  
  821. -
  822. foreach ($this->error as $single_error)
  823. -
  824. {
  825. -
  826. print_r($single_error);
  827. -
  828. }
  829. -
  830.  
  831. -
  832. echo '</pre>';
  833. -
  834. }
  835. -
  836.  
  837. -
  838. /**
  839. -
  840. * Takes over from PHP for the socket warning handler
  841. -
  842. *
  843. -
  844. * @param integer $errno
  845. -
  846. * @param string $errstr
  847. -
  848. * @param string $errfile
  849. -
  850. * @param integer $errline
  851. -
  852. */
  853. -
  854. function catchWarning ($errno, $errstr, $errfile, $errline)
  855. -
  856. {
  857. -
  858. $this->error[] = array(
  859. -
  860. 'error' => "Connecting to the POP3 server raised a PHP warning: ",
  861. -
  862. 'errno' => $errno,
  863. -
  864. 'errstr' => $errstr
  865. -
  866. );
  867. -
  868. }
  869. -
  870.  
  871. -
  872. // End of class
  873. -
  874.  
  875. -
  876. }
  877. -
  878. ?>
  879. -
-
-

- Documentation generated on Thu, 02 Apr 2009 21:19:49 -0400 by phpDocumentor 1.3.0RC3 -

- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.smtp.php.html b/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.smtp.php.html deleted file mode 100644 index 5dd8e6f8d..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/__filesource/fsource_PHPMailer__class.smtp.php.html +++ /dev/null @@ -1,1092 +0,0 @@ - - - - - - File Source for class.smtp.php - - - - -

Source for file class.smtp.php

-

Documentation is available at class.smtp.php

-
-
  1. <?php
  2. -
  3. /*~ class.smtp.php
  4. -
  5. .---------------------------------------------------------------------------.
  6. -
  7. | Software: PHPMailer - PHP email class |
  8. -
  9. | Version: 2.0.4 |
  10. -
  11. | Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
  12. -
  13. | Info: http://phpmailer.sourceforge.net |
  14. -
  15. | Support: http://sourceforge.net/projects/phpmailer/ |
  16. -
  17. | ------------------------------------------------------------------------- |
  18. -
  19. | Author: Andy Prevost (project admininistrator) |
  20. -
  21. | Author: Brent R. Matzelle (original founder) |
  22. -
  23. | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
  24. -
  25. | Copyright (c) 2001-2003, Brent R. Matzelle |
  26. -
  27. | ------------------------------------------------------------------------- |
  28. -
  29. | License: Distributed under the Lesser General Public License (LGPL) |
  30. -
  31. | http://www.gnu.org/copyleft/lesser.html |
  32. -
  33. | This program is distributed in the hope that it will be useful - WITHOUT |
  34. -
  35. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
  36. -
  37. | FITNESS FOR A PARTICULAR PURPOSE. |
  38. -
  39. | ------------------------------------------------------------------------- |
  40. -
  41. | We offer a number of paid services (www.codeworxtech.com): |
  42. -
  43. | - Web Hosting on highly optimized fast and secure servers |
  44. -
  45. | - Technology Consulting |
  46. -
  47. | - Oursourcing (highly qualified programmers and graphic designers) |
  48. -
  49. '---------------------------------------------------------------------------'
  50. -
  51.  
  52. -
  53.  
  54. -
  55.  
  56. -
  57. /**
  58. -
  59. * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
  60. -
  61. * commands except TURN which will always return a not implemented
  62. -
  63. * error. SMTP also provides some utility methods for sending mail
  64. -
  65. * to an SMTP server.
  66. -
  67. * @package PHPMailer
  68. -
  69. * @author Chris Ryan
  70. -
  71. */
  72. -
  73.  
  74. -
  75. class SMTP
  76. -
  77. {
  78. -
  79. /**
  80. -
  81. * SMTP server port
  82. -
  83. * @var int
  84. -
  85. */
  86. -
  87. var $SMTP_PORT = 25;
  88. -
  89.  
  90. -
  91. /**
  92. -
  93. * SMTP reply line ending
  94. -
  95. * @var string
  96. -
  97. */
  98. -
  99. var $CRLF = "\r\n";
  100. -
  101.  
  102. -
  103. /**
  104. -
  105. * Sets whether debugging is turned on
  106. -
  107. * @var bool
  108. -
  109. */
  110. -
  111. var $do_debug; # the level of debug to perform
  112. -
  113.  
  114. -
  115. -
  116.  
  117. -
  118. /**
  119. -
  120. * Sets VERP use on/off (default is off)
  121. -
  122. * @var bool
  123. -
  124. */
  125. -
  126. var $do_verp = false;
  127. -
  128.  
  129. -
  130. /**#@+
  131. -
  132. * @access private
  133. -
  134. */
  135. -
  136. var $smtp_conn; # the socket to the server
  137. -
  138. -
  139. var $error; # error if any on the last call
  140. -
  141. -
  142. var $helo_rply; # the reply the server sent to us for HELO
  143. -
  144. -
  145. /**#@-*/
  146. -
  147.  
  148. -
  149. /**
  150. -
  151. * Initialize the class so that the data is in a known state.
  152. -
  153. * @access public
  154. -
  155. * @return void
  156. -
  157. */
  158. -
  159. function SMTP() {
  160. -
  161. $this->smtp_conn = 0;
  162. -
  163. $this->error = null;
  164. -
  165. $this->helo_rply = null;
  166. -
  167.  
  168. -
  169. $this->do_debug = 0;
  170. -
  171. }
  172. -
  173.  
  174. -
  175. /***********************************************************
  176. -
  177. * CONNECTION FUNCTIONS *
  178. -
  179. ***********************************************************/
  180. -
  181.  
  182. -
  183.  
  184. -
  185. /**
  186. -
  187. * Connect to the server specified on the port specified.
  188. -
  189. * If the port is not specified use the default SMTP_PORT.
  190. -
  191. * If tval is specified then a connection will try and be
  192. -
  193. * established with the server for that number of seconds.
  194. -
  195. * If tval is not specified the default is 30 seconds to
  196. -
  197. * try on the connection.
  198. -
  199. *
  200. -
  201. * SMTP CODE SUCCESS: 220
  202. -
  203. * SMTP CODE FAILURE: 421
  204. -
  205. * @access public
  206. -
  207. * @return bool
  208. -
  209. */
  210. -
  211. function Connect($host,$port=0,$tval=30) {
  212. -
  213. # set the error val to null so there is no confusion
  214. -
  215. $this->error = null;
  216. -
  217.  
  218. -
  219. # make sure we are __not__ connected
  220. -
  221. if($this->connected()) {
  222. -
  223. # ok we are connected! what should we do?
  224. -
  225. # for now we will just give an error saying we
  226. -
  227. # are already connected
  228. -
  229. $this->error = array("error" => "Already connected to a server");
  230. -
  231. return false;
  232. -
  233. }
  234. -
  235.  
  236. -
  237. if(empty($port)) {
  238. -
  239. $port = $this->SMTP_PORT;
  240. -
  241. }
  242. -
  243.  
  244. -
  245. #connect to the smtp server
  246. -
  247. $this->smtp_conn = fsockopen($host, # the host of the server
  248. -
  249. $port, # the port to use
  250. -
  251. $errno, # error number if any
  252. -
  253. $errstr, # error message if any
  254. -
  255. $tval); # give up after ? secs
  256. -
  257. # verify we connected properly
  258. -
  259. if(empty($this->smtp_conn)) {
  260. -
  261. $this->error = array("error" => "Failed to connect to server",
  262. -
  263. "errno" => $errno,
  264. -
  265. "errstr" => $errstr);
  266. -
  267. if($this->do_debug >= 1) {
  268. -
  269. echo "SMTP -> ERROR: " . $this->error["error"] .
  270. -
  271. ": $errstr ($errno)" . $this->CRLF;
  272. -
  273. }
  274. -
  275. return false;
  276. -
  277. }
  278. -
  279.  
  280. -
  281. # sometimes the SMTP server takes a little longer to respond
  282. -
  283. # so we will give it a longer timeout for the first read
  284. -
  285. // Windows still does not have support for this timeout function
  286. -
  287. if(substr(PHP_OS, 0, 3) != "WIN")
  288. -
  289. socket_set_timeout($this->smtp_conn, $tval, 0);
  290. -
  291.  
  292. -
  293. # get any announcement stuff
  294. -
  295. $announce = $this->get_lines();
  296. -
  297.  
  298. -
  299. # set the timeout of any socket functions at 1/10 of a second
  300. -
  301. //if(function_exists("socket_set_timeout"))
  302. -
  303. // socket_set_timeout($this->smtp_conn, 0, 100000);
  304. -
  305.  
  306. -
  307. if($this->do_debug >= 2) {
  308. -
  309. echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
  310. -
  311. }
  312. -
  313.  
  314. -
  315. return true;
  316. -
  317. }
  318. -
  319.  
  320. -
  321. /**
  322. -
  323. * Performs SMTP authentication. Must be run after running the
  324. -
  325. * Hello() method. Returns true if successfully authenticated.
  326. -
  327. * @access public
  328. -
  329. * @return bool
  330. -
  331. */
  332. -
  333. function Authenticate($username, $password) {
  334. -
  335. // Start authentication
  336. -
  337. fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
  338. -
  339.  
  340. -
  341. $rply = $this->get_lines();
  342. -
  343. $code = substr($rply,0,3);
  344. -
  345.  
  346. -
  347. if($code != 334) {
  348. -
  349. $this->error =
  350. -
  351. array("error" => "AUTH not accepted from server",
  352. -
  353. "smtp_code" => $code,
  354. -
  355. "smtp_msg" => substr($rply,4));
  356. -
  357. if($this->do_debug >= 1) {
  358. -
  359. echo "SMTP -> ERROR: " . $this->error["error"] .
  360. -
  361. ": " . $rply . $this->CRLF;
  362. -
  363. }
  364. -
  365. return false;
  366. -
  367. }
  368. -
  369.  
  370. -
  371. // Send encoded username
  372. -
  373. fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
  374. -
  375.  
  376. -
  377. $rply = $this->get_lines();
  378. -
  379. $code = substr($rply,0,3);
  380. -
  381.  
  382. -
  383. if($code != 334) {
  384. -
  385. $this->error =
  386. -
  387. array("error" => "Username not accepted from server",
  388. -
  389. "smtp_code" => $code,
  390. -
  391. "smtp_msg" => substr($rply,4));
  392. -
  393. if($this->do_debug >= 1) {
  394. -
  395. echo "SMTP -> ERROR: " . $this->error["error"] .
  396. -
  397. ": " . $rply . $this->CRLF;
  398. -
  399. }
  400. -
  401. return false;
  402. -
  403. }
  404. -
  405.  
  406. -
  407. // Send encoded password
  408. -
  409. fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
  410. -
  411.  
  412. -
  413. $rply = $this->get_lines();
  414. -
  415. $code = substr($rply,0,3);
  416. -
  417.  
  418. -
  419. if($code != 235) {
  420. -
  421. $this->error =
  422. -
  423. array("error" => "Password not accepted from server",
  424. -
  425. "smtp_code" => $code,
  426. -
  427. "smtp_msg" => substr($rply,4));
  428. -
  429. if($this->do_debug >= 1) {
  430. -
  431. echo "SMTP -> ERROR: " . $this->error["error"] .
  432. -
  433. ": " . $rply . $this->CRLF;
  434. -
  435. }
  436. -
  437. return false;
  438. -
  439. }
  440. -
  441.  
  442. -
  443. return true;
  444. -
  445. }
  446. -
  447.  
  448. -
  449. /**
  450. -
  451. * Returns true if connected to a server otherwise false
  452. -
  453. * @access private
  454. -
  455. * @return bool
  456. -
  457. */
  458. -
  459. function Connected() {
  460. -
  461. if(!empty($this->smtp_conn)) {
  462. -
  463. $sock_status = socket_get_status($this->smtp_conn);
  464. -
  465. if($sock_status["eof"]) {
  466. -
  467. # hmm this is an odd situation... the socket is
  468. -
  469. # valid but we are not connected anymore
  470. -
  471. if($this->do_debug >= 1) {
  472. -
  473. echo "SMTP -> NOTICE:" . $this->CRLF .
  474. -
  475. "EOF caught while checking if connected";
  476. -
  477. }
  478. -
  479. $this->Close();
  480. -
  481. return false;
  482. -
  483. }
  484. -
  485. return true; # everything looks good
  486. -
  487. }
  488. -
  489. return false;
  490. -
  491. }
  492. -
  493.  
  494. -
  495. /**
  496. -
  497. * Closes the socket and cleans up the state of the class.
  498. -
  499. * It is not considered good to use this function without
  500. -
  501. * first trying to use QUIT.
  502. -
  503. * @access public
  504. -
  505. * @return void
  506. -
  507. */
  508. -
  509. function Close() {
  510. -
  511. $this->error = null; # so there is no confusion
  512. -
  513. $this->helo_rply = null;
  514. -
  515. if(!empty($this->smtp_conn)) {
  516. -
  517. # close the connection and cleanup
  518. -
  519. fclose($this->smtp_conn);
  520. -
  521. $this->smtp_conn = 0;
  522. -
  523. }
  524. -
  525. }
  526. -
  527.  
  528. -
  529. /*************************************************************
  530. -
  531. * SMTP COMMANDS *
  532. -
  533. *************************************************************/
  534. -
  535.  
  536. -
  537.  
  538. -
  539. /**
  540. -
  541. * Issues a data command and sends the msg_data to the server
  542. -
  543. * finializing the mail transaction. $msg_data is the message
  544. -
  545. * that is to be send with the headers. Each header needs to be
  546. -
  547. * on a single line followed by a <CRLF> with the message headers
  548. -
  549. * and the message body being seperated by and additional <CRLF>.
  550. -
  551. *
  552. -
  553. * Implements rfc 821: DATA <CRLF>
  554. -
  555. *
  556. -
  557. * SMTP CODE INTERMEDIATE: 354
  558. -
  559. * [data]
  560. -
  561. * <CRLF>.<CRLF>
  562. -
  563. * SMTP CODE SUCCESS: 250
  564. -
  565. * SMTP CODE FAILURE: 552,554,451,452
  566. -
  567. * SMTP CODE FAILURE: 451,554
  568. -
  569. * SMTP CODE ERROR : 500,501,503,421
  570. -
  571. * @access public
  572. -
  573. * @return bool
  574. -
  575. */
  576. -
  577. function Data($msg_data) {
  578. -
  579. $this->error = null; # so no confusion is caused
  580. -
  581.  
  582. -
  583. if(!$this->connected()) {
  584. -
  585. $this->error = array(
  586. -
  587. "error" => "Called Data() without being connected");
  588. -
  589. return false;
  590. -
  591. }
  592. -
  593.  
  594. -
  595. fputs($this->smtp_conn,"DATA" . $this->CRLF);
  596. -
  597.  
  598. -
  599. $rply = $this->get_lines();
  600. -
  601. $code = substr($rply,0,3);
  602. -
  603.  
  604. -
  605. if($this->do_debug >= 2) {
  606. -
  607. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  608. -
  609. }
  610. -
  611.  
  612. -
  613. if($code != 354) {
  614. -
  615. $this->error =
  616. -
  617. array("error" => "DATA command not accepted from server",
  618. -
  619. "smtp_code" => $code,
  620. -
  621. "smtp_msg" => substr($rply,4));
  622. -
  623. if($this->do_debug >= 1) {
  624. -
  625. echo "SMTP -> ERROR: " . $this->error["error"] .
  626. -
  627. ": " . $rply . $this->CRLF;
  628. -
  629. }
  630. -
  631. return false;
  632. -
  633. }
  634. -
  635.  
  636. -
  637. # the server is ready to accept data!
  638. -
  639. # according to rfc 821 we should not send more than 1000
  640. -
  641. # including the CRLF
  642. -
  643. # characters on a single line so we will break the data up
  644. -
  645. # into lines by \r and/or \n then if needed we will break
  646. -
  647. # each of those into smaller lines to fit within the limit.
  648. -
  649. # in addition we will be looking for lines that start with
  650. -
  651. # a period '.' and append and additional period '.' to that
  652. -
  653. # line. NOTE: this does not count towards are limit.
  654. -
  655.  
  656. -
  657. # normalize the line breaks so we know the explode works
  658. -
  659. $msg_data = str_replace("\r\n","\n",$msg_data);
  660. -
  661. $msg_data = str_replace("\r","\n",$msg_data);
  662. -
  663. $lines = explode("\n",$msg_data);
  664. -
  665.  
  666. -
  667. # we need to find a good way to determine is headers are
  668. -
  669. # in the msg_data or if it is a straight msg body
  670. -
  671. # currently I am assuming rfc 822 definitions of msg headers
  672. -
  673. # and if the first field of the first line (':' sperated)
  674. -
  675. # does not contain a space then it _should_ be a header
  676. -
  677. # and we can process all lines before a blank "" line as
  678. -
  679. # headers.
  680. -
  681. $field = substr($lines[0],0,strpos($lines[0],":"));
  682. -
  683. $in_headers = false;
  684. -
  685. if(!empty($field) && !strstr($field," ")) {
  686. -
  687. $in_headers = true;
  688. -
  689. }
  690. -
  691.  
  692. -
  693. $max_line_length = 998; # used below; set here for ease in change
  694. -
  695.  
  696. -
  697. while(list(,$line) = @each($lines)) {
  698. -
  699. $lines_out = null;
  700. -
  701. if($line == "" && $in_headers) {
  702. -
  703. $in_headers = false;
  704. -
  705. }
  706. -
  707. # ok we need to break this line up into several
  708. -
  709. # smaller lines
  710. -
  711. while(strlen($line) > $max_line_length) {
  712. -
  713. $pos = strrpos(substr($line,0,$max_line_length)," ");
  714. -
  715.  
  716. -
  717. # Patch to fix DOS attack
  718. -
  719. if(!$pos) {
  720. -
  721. $pos = $max_line_length - 1;
  722. -
  723. }
  724. -
  725.  
  726. -
  727. $lines_out[] = substr($line,0,$pos);
  728. -
  729. $line = substr($line,$pos + 1);
  730. -
  731. # if we are processing headers we need to
  732. -
  733. # add a LWSP-char to the front of the new line
  734. -
  735. # rfc 822 on long msg headers
  736. -
  737. if($in_headers) {
  738. -
  739. $line = "\t" . $line;
  740. -
  741. }
  742. -
  743. }
  744. -
  745. $lines_out[] = $line;
  746. -
  747.  
  748. -
  749. # now send the lines to the server
  750. -
  751. while(list(,$line_out) = @each($lines_out)) {
  752. -
  753. if(strlen($line_out) > 0)
  754. -
  755. {
  756. -
  757. if(substr($line_out, 0, 1) == ".") {
  758. -
  759. $line_out = "." . $line_out;
  760. -
  761. }
  762. -
  763. }
  764. -
  765. fputs($this->smtp_conn,$line_out . $this->CRLF);
  766. -
  767. }
  768. -
  769. }
  770. -
  771.  
  772. -
  773. # ok all the message data has been sent so lets get this
  774. -
  775. # over with aleady
  776. -
  777. fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
  778. -
  779.  
  780. -
  781. $rply = $this->get_lines();
  782. -
  783. $code = substr($rply,0,3);
  784. -
  785.  
  786. -
  787. if($this->do_debug >= 2) {
  788. -
  789. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  790. -
  791. }
  792. -
  793.  
  794. -
  795. if($code != 250) {
  796. -
  797. $this->error =
  798. -
  799. array("error" => "DATA not accepted from server",
  800. -
  801. "smtp_code" => $code,
  802. -
  803. "smtp_msg" => substr($rply,4));
  804. -
  805. if($this->do_debug >= 1) {
  806. -
  807. echo "SMTP -> ERROR: " . $this->error["error"] .
  808. -
  809. ": " . $rply . $this->CRLF;
  810. -
  811. }
  812. -
  813. return false;
  814. -
  815. }
  816. -
  817. return true;
  818. -
  819. }
  820. -
  821.  
  822. -
  823. /**
  824. -
  825. * Expand takes the name and asks the server to list all the
  826. -
  827. * people who are members of the _list_. Expand will return
  828. -
  829. * back and array of the result or false if an error occurs.
  830. -
  831. * Each value in the array returned has the format of:
  832. -
  833. * [ <full-name> <sp> ] <path>
  834. -
  835. * The definition of <path> is defined in rfc 821
  836. -
  837. *
  838. -
  839. * Implements rfc 821: EXPN <SP> <string> <CRLF>
  840. -
  841. *
  842. -
  843. * SMTP CODE SUCCESS: 250
  844. -
  845. * SMTP CODE FAILURE: 550
  846. -
  847. * SMTP CODE ERROR : 500,501,502,504,421
  848. -
  849. * @access public
  850. -
  851. * @return string array
  852. -
  853. */
  854. -
  855. function Expand($name) {
  856. -
  857. $this->error = null; # so no confusion is caused
  858. -
  859.  
  860. -
  861. if(!$this->connected()) {
  862. -
  863. $this->error = array(
  864. -
  865. "error" => "Called Expand() without being connected");
  866. -
  867. return false;
  868. -
  869. }
  870. -
  871.  
  872. -
  873. fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
  874. -
  875.  
  876. -
  877. $rply = $this->get_lines();
  878. -
  879. $code = substr($rply,0,3);
  880. -
  881.  
  882. -
  883. if($this->do_debug >= 2) {
  884. -
  885. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  886. -
  887. }
  888. -
  889.  
  890. -
  891. if($code != 250) {
  892. -
  893. $this->error =
  894. -
  895. array("error" => "EXPN not accepted from server",
  896. -
  897. "smtp_code" => $code,
  898. -
  899. "smtp_msg" => substr($rply,4));
  900. -
  901. if($this->do_debug >= 1) {
  902. -
  903. echo "SMTP -> ERROR: " . $this->error["error"] .
  904. -
  905. ": " . $rply . $this->CRLF;
  906. -
  907. }
  908. -
  909. return false;
  910. -
  911. }
  912. -
  913.  
  914. -
  915. # parse the reply and place in our array to return to user
  916. -
  917. $entries = explode($this->CRLF,$rply);
  918. -
  919. while(list(,$l) = @each($entries)) {
  920. -
  921. $list[] = substr($l,4);
  922. -
  923. }
  924. -
  925.  
  926. -
  927. return $list;
  928. -
  929. }
  930. -
  931.  
  932. -
  933. /**
  934. -
  935. * Sends the HELO command to the smtp server.
  936. -
  937. * This makes sure that we and the server are in
  938. -
  939. * the same known state.
  940. -
  941. *
  942. -
  943. * Implements from rfc 821: HELO <SP> <domain> <CRLF>
  944. -
  945. *
  946. -
  947. * SMTP CODE SUCCESS: 250
  948. -
  949. * SMTP CODE ERROR : 500, 501, 504, 421
  950. -
  951. * @access public
  952. -
  953. * @return bool
  954. -
  955. */
  956. -
  957. function Hello($host="") {
  958. -
  959. $this->error = null; # so no confusion is caused
  960. -
  961.  
  962. -
  963. if(!$this->connected()) {
  964. -
  965. $this->error = array(
  966. -
  967. "error" => "Called Hello() without being connected");
  968. -
  969. return false;
  970. -
  971. }
  972. -
  973.  
  974. -
  975. # if a hostname for the HELO was not specified determine
  976. -
  977. # a suitable one to send
  978. -
  979. if(empty($host)) {
  980. -
  981. # we need to determine some sort of appopiate default
  982. -
  983. # to send to the server
  984. -
  985. $host = "localhost";
  986. -
  987. }
  988. -
  989.  
  990. -
  991. // Send extended hello first (RFC 2821)
  992. -
  993. if(!$this->SendHello("EHLO", $host))
  994. -
  995. {
  996. -
  997. if(!$this->SendHello("HELO", $host))
  998. -
  999. return false;
  1000. -
  1001. }
  1002. -
  1003.  
  1004. -
  1005. return true;
  1006. -
  1007. }
  1008. -
  1009.  
  1010. -
  1011. /**
  1012. -
  1013. * Sends a HELO/EHLO command.
  1014. -
  1015. * @access private
  1016. -
  1017. * @return bool
  1018. -
  1019. */
  1020. -
  1021. function SendHello($hello, $host) {
  1022. -
  1023. fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
  1024. -
  1025.  
  1026. -
  1027. $rply = $this->get_lines();
  1028. -
  1029. $code = substr($rply,0,3);
  1030. -
  1031.  
  1032. -
  1033. if($this->do_debug >= 2) {
  1034. -
  1035. echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
  1036. -
  1037. }
  1038. -
  1039.  
  1040. -
  1041. if($code != 250) {
  1042. -
  1043. $this->error =
  1044. -
  1045. array("error" => $hello . " not accepted from server",
  1046. -
  1047. "smtp_code" => $code,
  1048. -
  1049. "smtp_msg" => substr($rply,4));
  1050. -
  1051. if($this->do_debug >= 1) {
  1052. -
  1053. echo "SMTP -> ERROR: " . $this->error["error"] .
  1054. -
  1055. ": " . $rply . $this->CRLF;
  1056. -
  1057. }
  1058. -
  1059. return false;
  1060. -
  1061. }
  1062. -
  1063.  
  1064. -
  1065. $this->helo_rply = $rply;
  1066. -
  1067.  
  1068. -
  1069. return true;
  1070. -
  1071. }
  1072. -
  1073.  
  1074. -
  1075. /**
  1076. -
  1077. * Gets help information on the keyword specified. If the keyword
  1078. -
  1079. * is not specified then returns generic help, ussually contianing
  1080. -
  1081. * A list of keywords that help is available on. This function
  1082. -
  1083. * returns the results back to the user. It is up to the user to
  1084. -
  1085. * handle the returned data. If an error occurs then false is
  1086. -
  1087. * returned with $this->error set appropiately.
  1088. -
  1089. *
  1090. -
  1091. * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
  1092. -
  1093. *
  1094. -
  1095. * SMTP CODE SUCCESS: 211,214
  1096. -
  1097. * SMTP CODE ERROR : 500,501,502,504,421
  1098. -
  1099. * @access public
  1100. -
  1101. * @return string
  1102. -
  1103. */
  1104. -
  1105. function Help($keyword="") {
  1106. -
  1107. $this->error = null; # to avoid confusion
  1108. -
  1109.  
  1110. -
  1111. if(!$this->connected()) {
  1112. -
  1113. $this->error = array(
  1114. -
  1115. "error" => "Called Help() without being connected");
  1116. -
  1117. return false;
  1118. -
  1119. }
  1120. -
  1121.  
  1122. -
  1123. $extra = "";
  1124. -
  1125. if(!empty($keyword)) {
  1126. -
  1127. $extra = " " . $keyword;
  1128. -
  1129. }
  1130. -
  1131.  
  1132. -
  1133. fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
  1134. -
  1135.  
  1136. -
  1137. $rply = $this->get_lines();
  1138. -
  1139. $code = substr($rply,0,3);
  1140. -
  1141.  
  1142. -
  1143. if($this->do_debug >= 2) {
  1144. -
  1145. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1146. -
  1147. }
  1148. -
  1149.  
  1150. -
  1151. if($code != 211 && $code != 214) {
  1152. -
  1153. $this->error =
  1154. -
  1155. array("error" => "HELP not accepted from server",
  1156. -
  1157. "smtp_code" => $code,
  1158. -
  1159. "smtp_msg" => substr($rply,4));
  1160. -
  1161. if($this->do_debug >= 1) {
  1162. -
  1163. echo "SMTP -> ERROR: " . $this->error["error"] .
  1164. -
  1165. ": " . $rply . $this->CRLF;
  1166. -
  1167. }
  1168. -
  1169. return false;
  1170. -
  1171. }
  1172. -
  1173.  
  1174. -
  1175. return $rply;
  1176. -
  1177. }
  1178. -
  1179.  
  1180. -
  1181. /**
  1182. -
  1183. * Starts a mail transaction from the email address specified in
  1184. -
  1185. * $from. Returns true if successful or false otherwise. If True
  1186. -
  1187. * the mail transaction is started and then one or more Recipient
  1188. -
  1189. * commands may be called followed by a Data command.
  1190. -
  1191. *
  1192. -
  1193. * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
  1194. -
  1195. *
  1196. -
  1197. * SMTP CODE SUCCESS: 250
  1198. -
  1199. * SMTP CODE SUCCESS: 552,451,452
  1200. -
  1201. * SMTP CODE SUCCESS: 500,501,421
  1202. -
  1203. * @access public
  1204. -
  1205. * @return bool
  1206. -
  1207. */
  1208. -
  1209. function Mail($from) {
  1210. -
  1211. $this->error = null; # so no confusion is caused
  1212. -
  1213.  
  1214. -
  1215. if(!$this->connected()) {
  1216. -
  1217. $this->error = array(
  1218. -
  1219. "error" => "Called Mail() without being connected");
  1220. -
  1221. return false;
  1222. -
  1223. }
  1224. -
  1225.  
  1226. -
  1227. $useVerp = ($this->do_verp ? "XVERP" : "");
  1228. -
  1229. fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
  1230. -
  1231.  
  1232. -
  1233. $rply = $this->get_lines();
  1234. -
  1235. $code = substr($rply,0,3);
  1236. -
  1237.  
  1238. -
  1239. if($this->do_debug >= 2) {
  1240. -
  1241. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1242. -
  1243. }
  1244. -
  1245.  
  1246. -
  1247. if($code != 250) {
  1248. -
  1249. $this->error =
  1250. -
  1251. array("error" => "MAIL not accepted from server",
  1252. -
  1253. "smtp_code" => $code,
  1254. -
  1255. "smtp_msg" => substr($rply,4));
  1256. -
  1257. if($this->do_debug >= 1) {
  1258. -
  1259. echo "SMTP -> ERROR: " . $this->error["error"] .
  1260. -
  1261. ": " . $rply . $this->CRLF;
  1262. -
  1263. }
  1264. -
  1265. return false;
  1266. -
  1267. }
  1268. -
  1269. return true;
  1270. -
  1271. }
  1272. -
  1273.  
  1274. -
  1275. /**
  1276. -
  1277. * Sends the command NOOP to the SMTP server.
  1278. -
  1279. *
  1280. -
  1281. * Implements from rfc 821: NOOP <CRLF>
  1282. -
  1283. *
  1284. -
  1285. * SMTP CODE SUCCESS: 250
  1286. -
  1287. * SMTP CODE ERROR : 500, 421
  1288. -
  1289. * @access public
  1290. -
  1291. * @return bool
  1292. -
  1293. */
  1294. -
  1295. function Noop() {
  1296. -
  1297. $this->error = null; # so no confusion is caused
  1298. -
  1299.  
  1300. -
  1301. if(!$this->connected()) {
  1302. -
  1303. $this->error = array(
  1304. -
  1305. "error" => "Called Noop() without being connected");
  1306. -
  1307. return false;
  1308. -
  1309. }
  1310. -
  1311.  
  1312. -
  1313. fputs($this->smtp_conn,"NOOP" . $this->CRLF);
  1314. -
  1315.  
  1316. -
  1317. $rply = $this->get_lines();
  1318. -
  1319. $code = substr($rply,0,3);
  1320. -
  1321.  
  1322. -
  1323. if($this->do_debug >= 2) {
  1324. -
  1325. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1326. -
  1327. }
  1328. -
  1329.  
  1330. -
  1331. if($code != 250) {
  1332. -
  1333. $this->error =
  1334. -
  1335. array("error" => "NOOP not accepted from server",
  1336. -
  1337. "smtp_code" => $code,
  1338. -
  1339. "smtp_msg" => substr($rply,4));
  1340. -
  1341. if($this->do_debug >= 1) {
  1342. -
  1343. echo "SMTP -> ERROR: " . $this->error["error"] .
  1344. -
  1345. ": " . $rply . $this->CRLF;
  1346. -
  1347. }
  1348. -
  1349. return false;
  1350. -
  1351. }
  1352. -
  1353. return true;
  1354. -
  1355. }
  1356. -
  1357.  
  1358. -
  1359. /**
  1360. -
  1361. * Sends the quit command to the server and then closes the socket
  1362. -
  1363. * if there is no error or the $close_on_error argument is true.
  1364. -
  1365. *
  1366. -
  1367. * Implements from rfc 821: QUIT <CRLF>
  1368. -
  1369. *
  1370. -
  1371. * SMTP CODE SUCCESS: 221
  1372. -
  1373. * SMTP CODE ERROR : 500
  1374. -
  1375. * @access public
  1376. -
  1377. * @return bool
  1378. -
  1379. */
  1380. -
  1381. function Quit($close_on_error=true) {
  1382. -
  1383. $this->error = null; # so there is no confusion
  1384. -
  1385.  
  1386. -
  1387. if(!$this->connected()) {
  1388. -
  1389. $this->error = array(
  1390. -
  1391. "error" => "Called Quit() without being connected");
  1392. -
  1393. return false;
  1394. -
  1395. }
  1396. -
  1397.  
  1398. -
  1399. # send the quit command to the server
  1400. -
  1401. fputs($this->smtp_conn,"quit" . $this->CRLF);
  1402. -
  1403.  
  1404. -
  1405. # get any good-bye messages
  1406. -
  1407. $byemsg = $this->get_lines();
  1408. -
  1409.  
  1410. -
  1411. if($this->do_debug >= 2) {
  1412. -
  1413. echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
  1414. -
  1415. }
  1416. -
  1417.  
  1418. -
  1419. $rval = true;
  1420. -
  1421. $e = null;
  1422. -
  1423.  
  1424. -
  1425. $code = substr($byemsg,0,3);
  1426. -
  1427. if($code != 221) {
  1428. -
  1429. # use e as a tmp var cause Close will overwrite $this->error
  1430. -
  1431. $e = array("error" => "SMTP server rejected quit command",
  1432. -
  1433. "smtp_code" => $code,
  1434. -
  1435. "smtp_rply" => substr($byemsg,4));
  1436. -
  1437. $rval = false;
  1438. -
  1439. if($this->do_debug >= 1) {
  1440. -
  1441. echo "SMTP -> ERROR: " . $e["error"] . ": " .
  1442. -
  1443. $byemsg . $this->CRLF;
  1444. -
  1445. }
  1446. -
  1447. }
  1448. -
  1449.  
  1450. -
  1451. if(empty($e) || $close_on_error) {
  1452. -
  1453. $this->Close();
  1454. -
  1455. }
  1456. -
  1457.  
  1458. -
  1459. return $rval;
  1460. -
  1461. }
  1462. -
  1463.  
  1464. -
  1465. /**
  1466. -
  1467. * Sends the command RCPT to the SMTP server with the TO: argument of $to.
  1468. -
  1469. * Returns true if the recipient was accepted false if it was rejected.
  1470. -
  1471. *
  1472. -
  1473. * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
  1474. -
  1475. *
  1476. -
  1477. * SMTP CODE SUCCESS: 250,251
  1478. -
  1479. * SMTP CODE FAILURE: 550,551,552,553,450,451,452
  1480. -
  1481. * SMTP CODE ERROR : 500,501,503,421
  1482. -
  1483. * @access public
  1484. -
  1485. * @return bool
  1486. -
  1487. */
  1488. -
  1489. function Recipient($to) {
  1490. -
  1491. $this->error = null; # so no confusion is caused
  1492. -
  1493.  
  1494. -
  1495. if(!$this->connected()) {
  1496. -
  1497. $this->error = array(
  1498. -
  1499. "error" => "Called Recipient() without being connected");
  1500. -
  1501. return false;
  1502. -
  1503. }
  1504. -
  1505.  
  1506. -
  1507. fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
  1508. -
  1509.  
  1510. -
  1511. $rply = $this->get_lines();
  1512. -
  1513. $code = substr($rply,0,3);
  1514. -
  1515.  
  1516. -
  1517. if($this->do_debug >= 2) {
  1518. -
  1519. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1520. -
  1521. }
  1522. -
  1523.  
  1524. -
  1525. if($code != 250 && $code != 251) {
  1526. -
  1527. $this->error =
  1528. -
  1529. array("error" => "RCPT not accepted from server",
  1530. -
  1531. "smtp_code" => $code,
  1532. -
  1533. "smtp_msg" => substr($rply,4));
  1534. -
  1535. if($this->do_debug >= 1) {
  1536. -
  1537. echo "SMTP -> ERROR: " . $this->error["error"] .
  1538. -
  1539. ": " . $rply . $this->CRLF;
  1540. -
  1541. }
  1542. -
  1543. return false;
  1544. -
  1545. }
  1546. -
  1547. return true;
  1548. -
  1549. }
  1550. -
  1551.  
  1552. -
  1553. /**
  1554. -
  1555. * Sends the RSET command to abort and transaction that is
  1556. -
  1557. * currently in progress. Returns true if successful false
  1558. -
  1559. * otherwise.
  1560. -
  1561. *
  1562. -
  1563. * Implements rfc 821: RSET <CRLF>
  1564. -
  1565. *
  1566. -
  1567. * SMTP CODE SUCCESS: 250
  1568. -
  1569. * SMTP CODE ERROR : 500,501,504,421
  1570. -
  1571. * @access public
  1572. -
  1573. * @return bool
  1574. -
  1575. */
  1576. -
  1577. function Reset() {
  1578. -
  1579. $this->error = null; # so no confusion is caused
  1580. -
  1581.  
  1582. -
  1583. if(!$this->connected()) {
  1584. -
  1585. $this->error = array(
  1586. -
  1587. "error" => "Called Reset() without being connected");
  1588. -
  1589. return false;
  1590. -
  1591. }
  1592. -
  1593.  
  1594. -
  1595. fputs($this->smtp_conn,"RSET" . $this->CRLF);
  1596. -
  1597.  
  1598. -
  1599. $rply = $this->get_lines();
  1600. -
  1601. $code = substr($rply,0,3);
  1602. -
  1603.  
  1604. -
  1605. if($this->do_debug >= 2) {
  1606. -
  1607. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1608. -
  1609. }
  1610. -
  1611.  
  1612. -
  1613. if($code != 250) {
  1614. -
  1615. $this->error =
  1616. -
  1617. array("error" => "RSET failed",
  1618. -
  1619. "smtp_code" => $code,
  1620. -
  1621. "smtp_msg" => substr($rply,4));
  1622. -
  1623. if($this->do_debug >= 1) {
  1624. -
  1625. echo "SMTP -> ERROR: " . $this->error["error"] .
  1626. -
  1627. ": " . $rply . $this->CRLF;
  1628. -
  1629. }
  1630. -
  1631. return false;
  1632. -
  1633. }
  1634. -
  1635.  
  1636. -
  1637. return true;
  1638. -
  1639. }
  1640. -
  1641.  
  1642. -
  1643. /**
  1644. -
  1645. * Starts a mail transaction from the email address specified in
  1646. -
  1647. * $from. Returns true if successful or false otherwise. If True
  1648. -
  1649. * the mail transaction is started and then one or more Recipient
  1650. -
  1651. * commands may be called followed by a Data command. This command
  1652. -
  1653. * will send the message to the users terminal if they are logged
  1654. -
  1655. * in.
  1656. -
  1657. *
  1658. -
  1659. * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
  1660. -
  1661. *
  1662. -
  1663. * SMTP CODE SUCCESS: 250
  1664. -
  1665. * SMTP CODE SUCCESS: 552,451,452
  1666. -
  1667. * SMTP CODE SUCCESS: 500,501,502,421
  1668. -
  1669. * @access public
  1670. -
  1671. * @return bool
  1672. -
  1673. */
  1674. -
  1675. function Send($from) {
  1676. -
  1677. $this->error = null; # so no confusion is caused
  1678. -
  1679.  
  1680. -
  1681. if(!$this->connected()) {
  1682. -
  1683. $this->error = array(
  1684. -
  1685. "error" => "Called Send() without being connected");
  1686. -
  1687. return false;
  1688. -
  1689. }
  1690. -
  1691.  
  1692. -
  1693. fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
  1694. -
  1695.  
  1696. -
  1697. $rply = $this->get_lines();
  1698. -
  1699. $code = substr($rply,0,3);
  1700. -
  1701.  
  1702. -
  1703. if($this->do_debug >= 2) {
  1704. -
  1705. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1706. -
  1707. }
  1708. -
  1709.  
  1710. -
  1711. if($code != 250) {
  1712. -
  1713. $this->error =
  1714. -
  1715. array("error" => "SEND not accepted from server",
  1716. -
  1717. "smtp_code" => $code,
  1718. -
  1719. "smtp_msg" => substr($rply,4));
  1720. -
  1721. if($this->do_debug >= 1) {
  1722. -
  1723. echo "SMTP -> ERROR: " . $this->error["error"] .
  1724. -
  1725. ": " . $rply . $this->CRLF;
  1726. -
  1727. }
  1728. -
  1729. return false;
  1730. -
  1731. }
  1732. -
  1733. return true;
  1734. -
  1735. }
  1736. -
  1737.  
  1738. -
  1739. /**
  1740. -
  1741. * Starts a mail transaction from the email address specified in
  1742. -
  1743. * $from. Returns true if successful or false otherwise. If True
  1744. -
  1745. * the mail transaction is started and then one or more Recipient
  1746. -
  1747. * commands may be called followed by a Data command. This command
  1748. -
  1749. * will send the message to the users terminal if they are logged
  1750. -
  1751. * in and send them an email.
  1752. -
  1753. *
  1754. -
  1755. * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
  1756. -
  1757. *
  1758. -
  1759. * SMTP CODE SUCCESS: 250
  1760. -
  1761. * SMTP CODE SUCCESS: 552,451,452
  1762. -
  1763. * SMTP CODE SUCCESS: 500,501,502,421
  1764. -
  1765. * @access public
  1766. -
  1767. * @return bool
  1768. -
  1769. */
  1770. -
  1771. function SendAndMail($from) {
  1772. -
  1773. $this->error = null; # so no confusion is caused
  1774. -
  1775.  
  1776. -
  1777. if(!$this->connected()) {
  1778. -
  1779. $this->error = array(
  1780. -
  1781. "error" => "Called SendAndMail() without being connected");
  1782. -
  1783. return false;
  1784. -
  1785. }
  1786. -
  1787.  
  1788. -
  1789. fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
  1790. -
  1791.  
  1792. -
  1793. $rply = $this->get_lines();
  1794. -
  1795. $code = substr($rply,0,3);
  1796. -
  1797.  
  1798. -
  1799. if($this->do_debug >= 2) {
  1800. -
  1801. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1802. -
  1803. }
  1804. -
  1805.  
  1806. -
  1807. if($code != 250) {
  1808. -
  1809. $this->error =
  1810. -
  1811. array("error" => "SAML not accepted from server",
  1812. -
  1813. "smtp_code" => $code,
  1814. -
  1815. "smtp_msg" => substr($rply,4));
  1816. -
  1817. if($this->do_debug >= 1) {
  1818. -
  1819. echo "SMTP -> ERROR: " . $this->error["error"] .
  1820. -
  1821. ": " . $rply . $this->CRLF;
  1822. -
  1823. }
  1824. -
  1825. return false;
  1826. -
  1827. }
  1828. -
  1829. return true;
  1830. -
  1831. }
  1832. -
  1833.  
  1834. -
  1835. /**
  1836. -
  1837. * Starts a mail transaction from the email address specified in
  1838. -
  1839. * $from. Returns true if successful or false otherwise. If True
  1840. -
  1841. * the mail transaction is started and then one or more Recipient
  1842. -
  1843. * commands may be called followed by a Data command. This command
  1844. -
  1845. * will send the message to the users terminal if they are logged
  1846. -
  1847. * in or mail it to them if they are not.
  1848. -
  1849. *
  1850. -
  1851. * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
  1852. -
  1853. *
  1854. -
  1855. * SMTP CODE SUCCESS: 250
  1856. -
  1857. * SMTP CODE SUCCESS: 552,451,452
  1858. -
  1859. * SMTP CODE SUCCESS: 500,501,502,421
  1860. -
  1861. * @access public
  1862. -
  1863. * @return bool
  1864. -
  1865. */
  1866. -
  1867. function SendOrMail($from) {
  1868. -
  1869. $this->error = null; # so no confusion is caused
  1870. -
  1871.  
  1872. -
  1873. if(!$this->connected()) {
  1874. -
  1875. $this->error = array(
  1876. -
  1877. "error" => "Called SendOrMail() without being connected");
  1878. -
  1879. return false;
  1880. -
  1881. }
  1882. -
  1883.  
  1884. -
  1885. fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
  1886. -
  1887.  
  1888. -
  1889. $rply = $this->get_lines();
  1890. -
  1891. $code = substr($rply,0,3);
  1892. -
  1893.  
  1894. -
  1895. if($this->do_debug >= 2) {
  1896. -
  1897. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  1898. -
  1899. }
  1900. -
  1901.  
  1902. -
  1903. if($code != 250) {
  1904. -
  1905. $this->error =
  1906. -
  1907. array("error" => "SOML not accepted from server",
  1908. -
  1909. "smtp_code" => $code,
  1910. -
  1911. "smtp_msg" => substr($rply,4));
  1912. -
  1913. if($this->do_debug >= 1) {
  1914. -
  1915. echo "SMTP -> ERROR: " . $this->error["error"] .
  1916. -
  1917. ": " . $rply . $this->CRLF;
  1918. -
  1919. }
  1920. -
  1921. return false;
  1922. -
  1923. }
  1924. -
  1925. return true;
  1926. -
  1927. }
  1928. -
  1929.  
  1930. -
  1931. /**
  1932. -
  1933. * This is an optional command for SMTP that this class does not
  1934. -
  1935. * support. This method is here to make the RFC821 Definition
  1936. -
  1937. * complete for this class and __may__ be implimented in the future
  1938. -
  1939. *
  1940. -
  1941. * Implements from rfc 821: TURN <CRLF>
  1942. -
  1943. *
  1944. -
  1945. * SMTP CODE SUCCESS: 250
  1946. -
  1947. * SMTP CODE FAILURE: 502
  1948. -
  1949. * SMTP CODE ERROR : 500, 503
  1950. -
  1951. * @access public
  1952. -
  1953. * @return bool
  1954. -
  1955. */
  1956. -
  1957. function Turn() {
  1958. -
  1959. $this->error = array("error" => "This method, TURN, of the SMTP ".
  1960. -
  1961. "is not implemented");
  1962. -
  1963. if($this->do_debug >= 1) {
  1964. -
  1965. echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
  1966. -
  1967. }
  1968. -
  1969. return false;
  1970. -
  1971. }
  1972. -
  1973.  
  1974. -
  1975. /**
  1976. -
  1977. * Verifies that the name is recognized by the server.
  1978. -
  1979. * Returns false if the name could not be verified otherwise
  1980. -
  1981. * the response from the server is returned.
  1982. -
  1983. *
  1984. -
  1985. * Implements rfc 821: VRFY <SP> <string> <CRLF>
  1986. -
  1987. *
  1988. -
  1989. * SMTP CODE SUCCESS: 250,251
  1990. -
  1991. * SMTP CODE FAILURE: 550,551,553
  1992. -
  1993. * SMTP CODE ERROR : 500,501,502,421
  1994. -
  1995. * @access public
  1996. -
  1997. * @return int
  1998. -
  1999. */
  2000. -
  2001. function Verify($name) {
  2002. -
  2003. $this->error = null; # so no confusion is caused
  2004. -
  2005.  
  2006. -
  2007. if(!$this->connected()) {
  2008. -
  2009. $this->error = array(
  2010. -
  2011. "error" => "Called Verify() without being connected");
  2012. -
  2013. return false;
  2014. -
  2015. }
  2016. -
  2017.  
  2018. -
  2019. fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
  2020. -
  2021.  
  2022. -
  2023. $rply = $this->get_lines();
  2024. -
  2025. $code = substr($rply,0,3);
  2026. -
  2027.  
  2028. -
  2029. if($this->do_debug >= 2) {
  2030. -
  2031. echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
  2032. -
  2033. }
  2034. -
  2035.  
  2036. -
  2037. if($code != 250 && $code != 251) {
  2038. -
  2039. $this->error =
  2040. -
  2041. array("error" => "VRFY failed on name '$name'",
  2042. -
  2043. "smtp_code" => $code,
  2044. -
  2045. "smtp_msg" => substr($rply,4));
  2046. -
  2047. if($this->do_debug >= 1) {
  2048. -
  2049. echo "SMTP -> ERROR: " . $this->error["error"] .
  2050. -
  2051. ": " . $rply . $this->CRLF;
  2052. -
  2053. }
  2054. -
  2055. return false;
  2056. -
  2057. }
  2058. -
  2059. return $rply;
  2060. -
  2061. }
  2062. -
  2063.  
  2064. -
  2065. /*****************************************************************
  2066. -
  2067. * INTERNAL FUNCTIONS *
  2068. -
  2069. ******************************************************************/
  2070. -
  2071.  
  2072. -
  2073.  
  2074. -
  2075. /**
  2076. -
  2077. * Read in as many lines as possible
  2078. -
  2079. * either before eof or socket timeout occurs on the operation.
  2080. -
  2081. * With SMTP we can tell if we have more lines to read if the
  2082. -
  2083. * 4th character is '-' symbol. If it is a space then we don't
  2084. -
  2085. * need to read anything else.
  2086. -
  2087. * @access private
  2088. -
  2089. * @return string
  2090. -
  2091. */
  2092. -
  2093. function get_lines() {
  2094. -
  2095. $data = "";
  2096. -
  2097. while($str = @fgets($this->smtp_conn,515)) {
  2098. -
  2099. if($this->do_debug >= 4) {
  2100. -
  2101. echo "SMTP -> get_lines(): \$data was \"$data\"" .
  2102. -
  2103. $this->CRLF;
  2104. -
  2105. echo "SMTP -> get_lines(): \$str is \"$str\"" .
  2106. -
  2107. $this->CRLF;
  2108. -
  2109. }
  2110. -
  2111. $data .= $str;
  2112. -
  2113. if($this->do_debug >= 4) {
  2114. -
  2115. echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
  2116. -
  2117. }
  2118. -
  2119. # if the 4th character is a space then we are done reading
  2120. -
  2121. # so just break the loop
  2122. -
  2123. if(substr($str,3,1) == " ") { break; }
  2124. -
  2125. }
  2126. -
  2127. return $data;
  2128. -
  2129. }
  2130. -
  2131.  
  2132. -
  2133. }
  2134. -
  2135.  
  2136. -
  2137.  
  2138. -
  2139. ?>
  2140. -
-
-

- Documentation generated on Thu, 02 Apr 2009 21:19:51 -0400 by phpDocumentor 1.3.0RC3 -

- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/blank.html b/plugin/PHPMailer_v2.0.4/phpdocs/blank.html deleted file mode 100644 index 04842f8d4..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/blank.html +++ /dev/null @@ -1,13 +0,0 @@ - - - PHPMailer version 2.0.4 - - - - -

PHPMailer version 2.0.4

-Welcome to PHPMailer!
-
-This documentation was generated by phpDocumentor v1.3.0RC3
- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/classtrees_PHPMailer.html b/plugin/PHPMailer_v2.0.4/phpdocs/classtrees_PHPMailer.html deleted file mode 100644 index 46ff94bc7..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/classtrees_PHPMailer.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - -

- -

-

Root class PHPMailer

- - -

Root class POP3

- - -

Root class SMTP

- - -

- Documentation generated on Thu, 02 Apr 2009 21:19:46 -0400 by phpDocumentor 1.3.0RC3 -

- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/elementindex.html b/plugin/PHPMailer_v2.0.4/phpdocs/elementindex.html deleted file mode 100644 index b1526d2dc..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/elementindex.html +++ /dev/null @@ -1,1049 +0,0 @@ - - - - - - - - - - - -

Full index

-

Package indexes

- -
-
- a - b - c - d - e - f - g - h - i - l - m - n - p - q - r - s - t - u - v - w -
- - -
-
a
- -
-
-
-
- $AltBody -
-
-
PHPMailer::$AltBody in class.phpmailer.php
-
Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.
-
-
- $attachment -
-
-
PHPMailer::$attachment in class.phpmailer.php
-
-
- AddAddress -
-
-
PHPMailer::AddAddress() in class.phpmailer.php
-
Adds a "To" address.
-
-
- AddAttachment -
-
-
PHPMailer::AddAttachment() in class.phpmailer.php
-
Adds an attachment from a path on the filesystem.
-
-
- AddBCC -
-
-
PHPMailer::AddBCC() in class.phpmailer.php
-
Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
-
-
- AddCC -
-
-
PHPMailer::AddCC() in class.phpmailer.php
-
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
-
-
- AddCustomHeader -
-
-
PHPMailer::AddCustomHeader() in class.phpmailer.php
-
Adds a custom header.
-
-
- AddEmbeddedImage -
-
-
PHPMailer::AddEmbeddedImage() in class.phpmailer.php
-
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
-
-
- AddReplyTo -
-
-
PHPMailer::AddReplyTo() in class.phpmailer.php
-
Adds a "Reply-To" address.
-
-
- AddStringAttachment -
-
-
PHPMailer::AddStringAttachment() in class.phpmailer.php
-
Adds a string or binary attachment (non-filesystem) to the list.
-
-
- Authenticate -
-
-
SMTP::Authenticate() in class.smtp.php
-
Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.
-
-
- Authorise -
-
-
POP3::Authorise() in class.pop3.php
-
Combination of public events - connect, login, disconnect
-
-
- -
-
b
- -
-
-
-
- $bcc -
-
-
PHPMailer::$bcc in class.phpmailer.php
-
-
- $Body -
-
-
PHPMailer::$Body in class.phpmailer.php
-
Sets the Body of the message. This can be either an HTML or text body.
-
-
- $boundary -
-
-
PHPMailer::$boundary in class.phpmailer.php
-
-
- -
-
c
- -
-
-
-
- $cc -
-
-
PHPMailer::$cc in class.phpmailer.php
-
-
- $CharSet -
-
-
PHPMailer::$CharSet in class.phpmailer.php
-
Sets the CharSet of the message.
-
-
- $ConfirmReadingTo -
-
-
PHPMailer::$ConfirmReadingTo in class.phpmailer.php
-
Sets the email address that a reading confirmation will be sent.
-
-
- $ContentType -
-
-
PHPMailer::$ContentType in class.phpmailer.php
-
Sets the Content-type of the message.
-
-
- $CRLF -
-
-
SMTP::$CRLF in class.smtp.php
-
SMTP reply line ending
-
-
- $CRLF -
-
-
POP3::$CRLF in class.pop3.php
-
POP3 Carriage Return + Line Feed
-
-
- $CustomHeader -
-
-
PHPMailer::$CustomHeader in class.phpmailer.php
-
-
- catchWarning -
-
-
POP3::catchWarning() in class.pop3.php
-
Takes over from PHP for the socket warning handler
-
-
- checkResponse -
-
-
POP3::checkResponse() in class.pop3.php
-
Checks the POP3 server response for +OK or -ERR
-
-
- ClearAddresses -
-
-
PHPMailer::ClearAddresses() in class.phpmailer.php
-
Clears all recipients assigned in the TO array. Returns void.
-
-
- ClearAllRecipients -
-
-
PHPMailer::ClearAllRecipients() in class.phpmailer.php
-
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
-
-
- ClearAttachments -
-
-
PHPMailer::ClearAttachments() in class.phpmailer.php
-
Clears all previously set filesystem, string, and binary attachments. Returns void.
-
-
- ClearBCCs -
-
-
PHPMailer::ClearBCCs() in class.phpmailer.php
-
Clears all recipients assigned in the BCC array. Returns void.
-
-
- ClearCCs -
-
-
PHPMailer::ClearCCs() in class.phpmailer.php
-
Clears all recipients assigned in the CC array. Returns void.
-
-
- ClearCustomHeaders -
-
-
PHPMailer::ClearCustomHeaders() in class.phpmailer.php
-
Clears all custom headers. Returns void.
-
-
- ClearReplyTos -
-
-
PHPMailer::ClearReplyTos() in class.phpmailer.php
-
Clears all recipients assigned in the ReplyTo array. Returns void.
-
-
- Close -
-
-
SMTP::Close() in class.smtp.php
-
Closes the socket and cleans up the state of the class.
-
-
- Connect -
-
-
SMTP::Connect() in class.smtp.php
-
Connect to the server specified on the port specified.
-
-
- Connect -
-
-
POP3::Connect() in class.pop3.php
-
Connect to the POP3 server
-
-
- class.phpmailer.php -
-
-
class.phpmailer.php in class.phpmailer.php
-
-
- class.pop3.php -
-
-
class.pop3.php in class.pop3.php
-
-
- class.smtp.php -
-
-
class.smtp.php in class.smtp.php
-
-
- -
-
d
- -
-
-
-
- $do_debug -
-
-
SMTP::$do_debug in class.smtp.php
-
Sets whether debugging is turned on
-
-
- $do_debug -
-
-
POP3::$do_debug in class.pop3.php
-
Displaying Debug warnings? (0 = now, 1+ = yes)
-
-
- $do_verp -
-
-
SMTP::$do_verp in class.smtp.php
-
Sets VERP use on/off (default is off)
-
-
- Data -
-
-
SMTP::Data() in class.smtp.php
-
Issues a data command and sends the msg_data to the server
-
-
- Disconnect -
-
-
POP3::Disconnect() in class.pop3.php
-
Disconnect from the POP3 server
-
-
- displayErrors -
-
-
POP3::displayErrors() in class.pop3.php
-
If debug is enabled, display the error message array
-
-
- -
-
e
- -
-
-
-
- $Encoding -
-
-
PHPMailer::$Encoding in class.phpmailer.php
-
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
-
-
- $ErrorInfo -
-
-
PHPMailer::$ErrorInfo in class.phpmailer.php
-
Holds the most recent mailer error message.
-
-
- $error_count -
-
-
PHPMailer::$error_count in class.phpmailer.php
-
-
- Expand -
-
-
SMTP::Expand() in class.smtp.php
-
Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.
-
-
- -
-
f
- -
-
-
-
- $From -
-
-
PHPMailer::$From in class.phpmailer.php
-
Sets the From email address for the message.
-
-
- $FromName -
-
-
PHPMailer::$FromName in class.phpmailer.php
-
Sets the From name of the message.
-
-
- -
-
g
- -
-
-
-
- getFile -
-
-
PHPMailer::getFile() in class.phpmailer.php
-
Read a file from a supplied filename and return it.
-
-
- getResponse -
-
-
POP3::getResponse() in class.pop3.php
-
Get the socket response back.
-
-
- -
-
h
- -
-
-
-
- $Helo -
-
-
PHPMailer::$Helo in class.phpmailer.php
-
Sets the SMTP HELO of the message (Default is $Hostname).
-
-
- $Host -
-
-
PHPMailer::$Host in class.phpmailer.php
-
Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
-
-
- $host -
-
-
POP3::$host in class.pop3.php
-
POP3 Mail Server
-
-
- $Hostname -
-
-
PHPMailer::$Hostname in class.phpmailer.php
-
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.
-
-
- HeaderLine -
-
-
PHPMailer::HeaderLine() in class.phpmailer.php
-
-
- Hello -
-
-
SMTP::Hello() in class.smtp.php
-
Sends the HELO command to the smtp server.
-
-
- Help -
-
-
SMTP::Help() in class.smtp.php
-
Gets help information on the keyword specified. If the keyword
-
-
- -
-
i
- -
-
-
-
- IsError -
-
-
PHPMailer::IsError() in class.phpmailer.php
-
Returns true if an error occurred.
-
-
- IsHTML -
-
-
PHPMailer::IsHTML() in class.phpmailer.php
-
Sets message type to HTML.
-
-
- IsMail -
-
-
PHPMailer::IsMail() in class.phpmailer.php
-
Sets Mailer to send message using PHP mail() function.
-
-
- IsQmail -
-
-
PHPMailer::IsQmail() in class.phpmailer.php
-
Sets Mailer to send message using the qmail MTA.
-
-
- IsSendmail -
-
-
PHPMailer::IsSendmail() in class.phpmailer.php
-
Sets Mailer to send message using the $Sendmail program.
-
-
- IsSMTP -
-
-
PHPMailer::IsSMTP() in class.phpmailer.php
-
Sets Mailer to send message using SMTP.
-
-
- -
-
l
- -
-
-
-
- $language -
-
-
PHPMailer::$language in class.phpmailer.php
-
-
- $LE -
-
-
PHPMailer::$LE in class.phpmailer.php
-
-
- Login -
-
-
POP3::Login() in class.pop3.php
-
Login to the POP3 server (does not support APOP yet)
-
-
- -
-
m
- -
-
-
-
- $Mailer -
-
-
PHPMailer::$Mailer in class.phpmailer.php
-
Method to send mail: ("mail", "sendmail", or "smtp").
-
-
- $MessageID -
-
-
PHPMailer::$MessageID in class.phpmailer.php
-
Sets the message ID to be used in the Message-Id header.
-
-
- $message_type -
-
-
PHPMailer::$message_type in class.phpmailer.php
-
-
- Mail -
-
-
SMTP::Mail() in class.smtp.php
-
Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.
-
-
- MsgHTML -
-
-
PHPMailer::MsgHTML() in class.phpmailer.php
-
Evaluates the message and returns modifications for inline images and backgrounds
-
-
- -
-
n
- -
-
-
-
- Noop -
-
-
SMTP::Noop() in class.smtp.php
-
Sends the command NOOP to the SMTP server.
-
-
- -
-
p
- -
-
-
-
- $Password -
-
-
PHPMailer::$Password in class.phpmailer.php
-
Sets SMTP password.
-
-
- $password -
-
-
POP3::$password in class.pop3.php
-
POP3 Password
-
-
- $PluginDir -
-
-
PHPMailer::$PluginDir in class.phpmailer.php
-
Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
-
-
- $POP3_PORT -
-
-
POP3::$POP3_PORT in class.pop3.php
-
Default POP3 port
-
-
- $POP3_TIMEOUT -
-
-
POP3::$POP3_TIMEOUT in class.pop3.php
-
Default Timeout
-
-
- $Port -
-
-
PHPMailer::$Port in class.phpmailer.php
-
Sets the default SMTP server port.
-
-
- $port -
-
-
POP3::$port in class.pop3.php
-
POP3 Port
-
-
- $Priority -
-
-
PHPMailer::$Priority in class.phpmailer.php
-
Email priority (1 = High, 3 = Normal, 5 = low).
-
-
- PHPMailer -
-
-
PHPMailer in class.phpmailer.php
-
-
- POP3 -
-
-
POP3::POP3() in class.pop3.php
-
Constructor, sets the initial values
-
-
- POP3 -
-
-
POP3 in class.pop3.php
-
-
- -
-
q
- -
-
-
-
- Quit -
-
-
SMTP::Quit() in class.smtp.php
-
Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.
-
-
- -
-
r
- -
-
-
-
- $ReplyTo -
-
-
PHPMailer::$ReplyTo in class.phpmailer.php
-
-
- Recipient -
-
-
SMTP::Recipient() in class.smtp.php
-
Sends the command RCPT to the SMTP server with the TO: argument of $to.
-
-
- Reset -
-
-
SMTP::Reset() in class.smtp.php
-
Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.
-
-
- -
-
s
- -
-
-
-
- $Sender -
-
-
PHPMailer::$Sender in class.phpmailer.php
-
Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
-
-
- $Sendmail -
-
-
PHPMailer::$Sendmail in class.phpmailer.php
-
Sets the path of the sendmail program.
-
-
- $sign_cert_file -
-
-
PHPMailer::$sign_cert_file in class.phpmailer.php
-
-
- $sign_key_file -
-
-
PHPMailer::$sign_key_file in class.phpmailer.php
-
-
- $sign_key_pass -
-
-
PHPMailer::$sign_key_pass in class.phpmailer.php
-
-
- $SingleTo -
-
-
PHPMailer::$SingleTo in class.phpmailer.php
-
Provides the ability to have the TO field process individual
-
-
- $smtp -
-
-
PHPMailer::$smtp in class.phpmailer.php
-
-
- $SMTPAuth -
-
-
PHPMailer::$SMTPAuth in class.phpmailer.php
-
Sets SMTP authentication. Utilizes the Username and Password variables.
-
-
- $SMTPDebug -
-
-
PHPMailer::$SMTPDebug in class.phpmailer.php
-
Sets SMTP class debugging on or off.
-
-
- $SMTPKeepAlive -
-
-
PHPMailer::$SMTPKeepAlive in class.phpmailer.php
-
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().
-
-
- $SMTPSecure -
-
-
PHPMailer::$SMTPSecure in class.phpmailer.php
-
Sets connection prefix.
-
-
- $SMTP_PORT -
-
-
SMTP::$SMTP_PORT in class.smtp.php
-
SMTP server port
-
-
- $Subject -
-
-
PHPMailer::$Subject in class.phpmailer.php
-
Sets the Subject of the message.
-
-
- Send -
-
-
SMTP::Send() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- Send -
-
-
PHPMailer::Send() in class.phpmailer.php
-
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
-
-
- SendAndMail -
-
-
SMTP::SendAndMail() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- SendOrMail -
-
-
SMTP::SendOrMail() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- sendString -
-
-
POP3::sendString() in class.pop3.php
-
Send a string down the open socket connection to the POP3 server
-
-
- set -
-
-
PHPMailer::set() in class.phpmailer.php
-
Set (or reset) Class Objects (variables)
-
-
- SetLanguage -
-
-
PHPMailer::SetLanguage() in class.phpmailer.php
-
Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
-
-
- Sign -
-
-
PHPMailer::Sign() in class.phpmailer.php
-
Set the private key file and password to sign the message.
-
-
- SMTP -
-
-
SMTP in class.smtp.php
-
-
- SMTP -
-
-
SMTP::SMTP() in class.smtp.php
-
Initialize the class so that the data is in a known state.
-
-
- SmtpClose -
-
-
PHPMailer::SmtpClose() in class.phpmailer.php
-
Closes the active SMTP session if one exists.
-
-
- -
-
t
- -
-
-
-
- $Timeout -
-
-
PHPMailer::$Timeout in class.phpmailer.php
-
Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
-
-
- $to -
-
-
PHPMailer::$to in class.phpmailer.php
-
-
- $tval -
-
-
POP3::$tval in class.pop3.php
-
POP3 Timeout Value
-
-
- Turn -
-
-
SMTP::Turn() in class.smtp.php
-
This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future
-
-
- -
-
u
- -
-
-
-
- $username -
-
-
POP3::$username in class.pop3.php
-
POP3 Username
-
-
- $Username -
-
-
PHPMailer::$Username in class.phpmailer.php
-
Sets SMTP username.
-
-
- -
-
v
- -
-
-
-
- $Version -
-
-
PHPMailer::$Version in class.phpmailer.php
-
Holds PHPMailer version.
-
-
- Verify -
-
-
SMTP::Verify() in class.smtp.php
-
Verifies that the name is recognized by the server.
-
-
- -
-
w
- -
-
-
-
- $WordWrap -
-
-
PHPMailer::$WordWrap in class.phpmailer.php
-
Sets word wrapping on the body of the message to a given number of characters.
-
-
- -
- a - b - c - d - e - f - g - h - i - l - m - n - p - q - r - s - t - u - v - w -
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/elementindex_PHPMailer.html b/plugin/PHPMailer_v2.0.4/phpdocs/elementindex_PHPMailer.html deleted file mode 100644 index 7694cdec6..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/elementindex_PHPMailer.html +++ /dev/null @@ -1,1046 +0,0 @@ - - - - - - - - - - - -

[PHPMailer] element index

-All elements -
-
- a - b - c - d - e - f - g - h - i - l - m - n - p - q - r - s - t - u - v - w -
- - -
-
a
- -
-
-
-
- $AltBody -
-
-
PHPMailer::$AltBody in class.phpmailer.php
-
Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.
-
-
- $attachment -
-
-
PHPMailer::$attachment in class.phpmailer.php
-
-
- AddAddress -
-
-
PHPMailer::AddAddress() in class.phpmailer.php
-
Adds a "To" address.
-
-
- AddAttachment -
-
-
PHPMailer::AddAttachment() in class.phpmailer.php
-
Adds an attachment from a path on the filesystem.
-
-
- AddBCC -
-
-
PHPMailer::AddBCC() in class.phpmailer.php
-
Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
-
-
- AddCC -
-
-
PHPMailer::AddCC() in class.phpmailer.php
-
Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
-
-
- AddCustomHeader -
-
-
PHPMailer::AddCustomHeader() in class.phpmailer.php
-
Adds a custom header.
-
-
- AddEmbeddedImage -
-
-
PHPMailer::AddEmbeddedImage() in class.phpmailer.php
-
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
-
-
- AddReplyTo -
-
-
PHPMailer::AddReplyTo() in class.phpmailer.php
-
Adds a "Reply-To" address.
-
-
- AddStringAttachment -
-
-
PHPMailer::AddStringAttachment() in class.phpmailer.php
-
Adds a string or binary attachment (non-filesystem) to the list.
-
-
- Authenticate -
-
-
SMTP::Authenticate() in class.smtp.php
-
Performs SMTP authentication. Must be run after running the Hello() method. Returns true if successfully authenticated.
-
-
- Authorise -
-
-
POP3::Authorise() in class.pop3.php
-
Combination of public events - connect, login, disconnect
-
-
- -
-
b
- -
-
-
-
- $bcc -
-
-
PHPMailer::$bcc in class.phpmailer.php
-
-
- $Body -
-
-
PHPMailer::$Body in class.phpmailer.php
-
Sets the Body of the message. This can be either an HTML or text body.
-
-
- $boundary -
-
-
PHPMailer::$boundary in class.phpmailer.php
-
-
- -
-
c
- -
-
-
-
- $cc -
-
-
PHPMailer::$cc in class.phpmailer.php
-
-
- $CharSet -
-
-
PHPMailer::$CharSet in class.phpmailer.php
-
Sets the CharSet of the message.
-
-
- $ConfirmReadingTo -
-
-
PHPMailer::$ConfirmReadingTo in class.phpmailer.php
-
Sets the email address that a reading confirmation will be sent.
-
-
- $ContentType -
-
-
PHPMailer::$ContentType in class.phpmailer.php
-
Sets the Content-type of the message.
-
-
- $CRLF -
-
-
SMTP::$CRLF in class.smtp.php
-
SMTP reply line ending
-
-
- $CRLF -
-
-
POP3::$CRLF in class.pop3.php
-
POP3 Carriage Return + Line Feed
-
-
- $CustomHeader -
-
-
PHPMailer::$CustomHeader in class.phpmailer.php
-
-
- catchWarning -
-
-
POP3::catchWarning() in class.pop3.php
-
Takes over from PHP for the socket warning handler
-
-
- checkResponse -
-
-
POP3::checkResponse() in class.pop3.php
-
Checks the POP3 server response for +OK or -ERR
-
-
- ClearAddresses -
-
-
PHPMailer::ClearAddresses() in class.phpmailer.php
-
Clears all recipients assigned in the TO array. Returns void.
-
-
- ClearAllRecipients -
-
-
PHPMailer::ClearAllRecipients() in class.phpmailer.php
-
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
-
-
- ClearAttachments -
-
-
PHPMailer::ClearAttachments() in class.phpmailer.php
-
Clears all previously set filesystem, string, and binary attachments. Returns void.
-
-
- ClearBCCs -
-
-
PHPMailer::ClearBCCs() in class.phpmailer.php
-
Clears all recipients assigned in the BCC array. Returns void.
-
-
- ClearCCs -
-
-
PHPMailer::ClearCCs() in class.phpmailer.php
-
Clears all recipients assigned in the CC array. Returns void.
-
-
- ClearCustomHeaders -
-
-
PHPMailer::ClearCustomHeaders() in class.phpmailer.php
-
Clears all custom headers. Returns void.
-
-
- ClearReplyTos -
-
-
PHPMailer::ClearReplyTos() in class.phpmailer.php
-
Clears all recipients assigned in the ReplyTo array. Returns void.
-
-
- Close -
-
-
SMTP::Close() in class.smtp.php
-
Closes the socket and cleans up the state of the class.
-
-
- Connect -
-
-
SMTP::Connect() in class.smtp.php
-
Connect to the server specified on the port specified.
-
-
- Connect -
-
-
POP3::Connect() in class.pop3.php
-
Connect to the POP3 server
-
-
- class.phpmailer.php -
-
-
class.phpmailer.php in class.phpmailer.php
-
-
- class.pop3.php -
-
-
class.pop3.php in class.pop3.php
-
-
- class.smtp.php -
-
-
class.smtp.php in class.smtp.php
-
-
- -
-
d
- -
-
-
-
- $do_debug -
-
-
SMTP::$do_debug in class.smtp.php
-
Sets whether debugging is turned on
-
-
- $do_debug -
-
-
POP3::$do_debug in class.pop3.php
-
Displaying Debug warnings? (0 = now, 1+ = yes)
-
-
- $do_verp -
-
-
SMTP::$do_verp in class.smtp.php
-
Sets VERP use on/off (default is off)
-
-
- Data -
-
-
SMTP::Data() in class.smtp.php
-
Issues a data command and sends the msg_data to the server
-
-
- Disconnect -
-
-
POP3::Disconnect() in class.pop3.php
-
Disconnect from the POP3 server
-
-
- displayErrors -
-
-
POP3::displayErrors() in class.pop3.php
-
If debug is enabled, display the error message array
-
-
- -
-
e
- -
-
-
-
- $Encoding -
-
-
PHPMailer::$Encoding in class.phpmailer.php
-
Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
-
-
- $ErrorInfo -
-
-
PHPMailer::$ErrorInfo in class.phpmailer.php
-
Holds the most recent mailer error message.
-
-
- $error_count -
-
-
PHPMailer::$error_count in class.phpmailer.php
-
-
- Expand -
-
-
SMTP::Expand() in class.smtp.php
-
Expand takes the name and asks the server to list all the people who are members of the _list_. Expand will return back and array of the result or false if an error occurs.
-
-
- -
-
f
- -
-
-
-
- $From -
-
-
PHPMailer::$From in class.phpmailer.php
-
Sets the From email address for the message.
-
-
- $FromName -
-
-
PHPMailer::$FromName in class.phpmailer.php
-
Sets the From name of the message.
-
-
- -
-
g
- -
-
-
-
- getFile -
-
-
PHPMailer::getFile() in class.phpmailer.php
-
Read a file from a supplied filename and return it.
-
-
- getResponse -
-
-
POP3::getResponse() in class.pop3.php
-
Get the socket response back.
-
-
- -
-
h
- -
-
-
-
- $Helo -
-
-
PHPMailer::$Helo in class.phpmailer.php
-
Sets the SMTP HELO of the message (Default is $Hostname).
-
-
- $Host -
-
-
PHPMailer::$Host in class.phpmailer.php
-
Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").
-
-
- $host -
-
-
POP3::$host in class.pop3.php
-
POP3 Mail Server
-
-
- $Hostname -
-
-
PHPMailer::$Hostname in class.phpmailer.php
-
Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.
-
-
- HeaderLine -
-
-
PHPMailer::HeaderLine() in class.phpmailer.php
-
-
- Hello -
-
-
SMTP::Hello() in class.smtp.php
-
Sends the HELO command to the smtp server.
-
-
- Help -
-
-
SMTP::Help() in class.smtp.php
-
Gets help information on the keyword specified. If the keyword
-
-
- -
-
i
- -
-
-
-
- IsError -
-
-
PHPMailer::IsError() in class.phpmailer.php
-
Returns true if an error occurred.
-
-
- IsHTML -
-
-
PHPMailer::IsHTML() in class.phpmailer.php
-
Sets message type to HTML.
-
-
- IsMail -
-
-
PHPMailer::IsMail() in class.phpmailer.php
-
Sets Mailer to send message using PHP mail() function.
-
-
- IsQmail -
-
-
PHPMailer::IsQmail() in class.phpmailer.php
-
Sets Mailer to send message using the qmail MTA.
-
-
- IsSendmail -
-
-
PHPMailer::IsSendmail() in class.phpmailer.php
-
Sets Mailer to send message using the $Sendmail program.
-
-
- IsSMTP -
-
-
PHPMailer::IsSMTP() in class.phpmailer.php
-
Sets Mailer to send message using SMTP.
-
-
- -
-
l
- -
-
-
-
- $language -
-
-
PHPMailer::$language in class.phpmailer.php
-
-
- $LE -
-
-
PHPMailer::$LE in class.phpmailer.php
-
-
- Login -
-
-
POP3::Login() in class.pop3.php
-
Login to the POP3 server (does not support APOP yet)
-
-
- -
-
m
- -
-
-
-
- $Mailer -
-
-
PHPMailer::$Mailer in class.phpmailer.php
-
Method to send mail: ("mail", "sendmail", or "smtp").
-
-
- $MessageID -
-
-
PHPMailer::$MessageID in class.phpmailer.php
-
Sets the message ID to be used in the Message-Id header.
-
-
- $message_type -
-
-
PHPMailer::$message_type in class.phpmailer.php
-
-
- Mail -
-
-
SMTP::Mail() in class.smtp.php
-
Starts a mail transaction from the email address specified in $from. Returns true if successful or false otherwise. If True the mail transaction is started and then one or more Recipient commands may be called followed by a Data command.
-
-
- MsgHTML -
-
-
PHPMailer::MsgHTML() in class.phpmailer.php
-
Evaluates the message and returns modifications for inline images and backgrounds
-
-
- -
-
n
- -
-
-
-
- Noop -
-
-
SMTP::Noop() in class.smtp.php
-
Sends the command NOOP to the SMTP server.
-
-
- -
-
p
- -
-
-
-
- $Password -
-
-
PHPMailer::$Password in class.phpmailer.php
-
Sets SMTP password.
-
-
- $password -
-
-
POP3::$password in class.pop3.php
-
POP3 Password
-
-
- $PluginDir -
-
-
PHPMailer::$PluginDir in class.phpmailer.php
-
Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
-
-
- $POP3_PORT -
-
-
POP3::$POP3_PORT in class.pop3.php
-
Default POP3 port
-
-
- $POP3_TIMEOUT -
-
-
POP3::$POP3_TIMEOUT in class.pop3.php
-
Default Timeout
-
-
- $Port -
-
-
PHPMailer::$Port in class.phpmailer.php
-
Sets the default SMTP server port.
-
-
- $port -
-
-
POP3::$port in class.pop3.php
-
POP3 Port
-
-
- $Priority -
-
-
PHPMailer::$Priority in class.phpmailer.php
-
Email priority (1 = High, 3 = Normal, 5 = low).
-
-
- PHPMailer -
-
-
PHPMailer in class.phpmailer.php
-
-
- POP3 -
-
-
POP3::POP3() in class.pop3.php
-
Constructor, sets the initial values
-
-
- POP3 -
-
-
POP3 in class.pop3.php
-
-
- -
-
q
- -
-
-
-
- Quit -
-
-
SMTP::Quit() in class.smtp.php
-
Sends the quit command to the server and then closes the socket if there is no error or the $close_on_error argument is true.
-
-
- -
-
r
- -
-
-
-
- $ReplyTo -
-
-
PHPMailer::$ReplyTo in class.phpmailer.php
-
-
- Recipient -
-
-
SMTP::Recipient() in class.smtp.php
-
Sends the command RCPT to the SMTP server with the TO: argument of $to.
-
-
- Reset -
-
-
SMTP::Reset() in class.smtp.php
-
Sends the RSET command to abort and transaction that is currently in progress. Returns true if successful false otherwise.
-
-
- -
-
s
- -
-
-
-
- $Sender -
-
-
PHPMailer::$Sender in class.phpmailer.php
-
Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
-
-
- $Sendmail -
-
-
PHPMailer::$Sendmail in class.phpmailer.php
-
Sets the path of the sendmail program.
-
-
- $sign_cert_file -
-
-
PHPMailer::$sign_cert_file in class.phpmailer.php
-
-
- $sign_key_file -
-
-
PHPMailer::$sign_key_file in class.phpmailer.php
-
-
- $sign_key_pass -
-
-
PHPMailer::$sign_key_pass in class.phpmailer.php
-
-
- $SingleTo -
-
-
PHPMailer::$SingleTo in class.phpmailer.php
-
Provides the ability to have the TO field process individual
-
-
- $smtp -
-
-
PHPMailer::$smtp in class.phpmailer.php
-
-
- $SMTPAuth -
-
-
PHPMailer::$SMTPAuth in class.phpmailer.php
-
Sets SMTP authentication. Utilizes the Username and Password variables.
-
-
- $SMTPDebug -
-
-
PHPMailer::$SMTPDebug in class.phpmailer.php
-
Sets SMTP class debugging on or off.
-
-
- $SMTPKeepAlive -
-
-
PHPMailer::$SMTPKeepAlive in class.phpmailer.php
-
Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().
-
-
- $SMTPSecure -
-
-
PHPMailer::$SMTPSecure in class.phpmailer.php
-
Sets connection prefix.
-
-
- $SMTP_PORT -
-
-
SMTP::$SMTP_PORT in class.smtp.php
-
SMTP server port
-
-
- $Subject -
-
-
PHPMailer::$Subject in class.phpmailer.php
-
Sets the Subject of the message.
-
-
- Send -
-
-
SMTP::Send() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- Send -
-
-
PHPMailer::Send() in class.phpmailer.php
-
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
-
-
- SendAndMail -
-
-
SMTP::SendAndMail() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- SendOrMail -
-
-
SMTP::SendOrMail() in class.smtp.php
-
Starts a mail transaction from the email address specified in
-
-
- sendString -
-
-
POP3::sendString() in class.pop3.php
-
Send a string down the open socket connection to the POP3 server
-
-
- set -
-
-
PHPMailer::set() in class.phpmailer.php
-
Set (or reset) Class Objects (variables)
-
-
- SetLanguage -
-
-
PHPMailer::SetLanguage() in class.phpmailer.php
-
Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
-
-
- Sign -
-
-
PHPMailer::Sign() in class.phpmailer.php
-
Set the private key file and password to sign the message.
-
-
- SMTP -
-
-
SMTP in class.smtp.php
-
-
- SMTP -
-
-
SMTP::SMTP() in class.smtp.php
-
Initialize the class so that the data is in a known state.
-
-
- SmtpClose -
-
-
PHPMailer::SmtpClose() in class.phpmailer.php
-
Closes the active SMTP session if one exists.
-
-
- -
-
t
- -
-
-
-
- $Timeout -
-
-
PHPMailer::$Timeout in class.phpmailer.php
-
Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
-
-
- $to -
-
-
PHPMailer::$to in class.phpmailer.php
-
-
- $tval -
-
-
POP3::$tval in class.pop3.php
-
POP3 Timeout Value
-
-
- Turn -
-
-
SMTP::Turn() in class.smtp.php
-
This is an optional command for SMTP that this class does not support. This method is here to make the RFC821 Definition complete for this class and __may__ be implimented in the future
-
-
- -
-
u
- -
-
-
-
- $username -
-
-
POP3::$username in class.pop3.php
-
POP3 Username
-
-
- $Username -
-
-
PHPMailer::$Username in class.phpmailer.php
-
Sets SMTP username.
-
-
- -
-
v
- -
-
-
-
- $Version -
-
-
PHPMailer::$Version in class.phpmailer.php
-
Holds PHPMailer version.
-
-
- Verify -
-
-
SMTP::Verify() in class.smtp.php
-
Verifies that the name is recognized by the server.
-
-
- -
-
w
- -
-
-
-
- $WordWrap -
-
-
PHPMailer::$WordWrap in class.phpmailer.php
-
Sets word wrapping on the body of the message to a given number of characters.
-
-
- -
- a - b - c - d - e - f - g - h - i - l - m - n - p - q - r - s - t - u - v - w -
- \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/index.html b/plugin/PHPMailer_v2.0.4/phpdocs/index.html deleted file mode 100644 index 3d66c1e28..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - PHPMailer version 2.0.4 - - - - - - - - - - - <H2>Frame Alert</H2> - <P>This document is designed to be viewed using the frames feature. - If you see this message, you are using a non-frame-capable web client.</P> - - - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/li_PHPMailer.html b/plugin/PHPMailer_v2.0.4/phpdocs/li_PHPMailer.html deleted file mode 100644 index e88a5803a..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/li_PHPMailer.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - -
PHPMailer
-
- -
- -
Description
-
- Class trees
- Index of elements
-
- - - -
Classes
-
PHPMailer
-
POP3
-
SMTP
-
Files
-
class.phpmailer.php
-
class.pop3.php
-
class.smtp.php
- - -
-
-

phpDocumentor v 1.3.0RC3

- - \ No newline at end of file diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/media/banner.css b/plugin/PHPMailer_v2.0.4/phpdocs/media/banner.css deleted file mode 100644 index f2149ebb4..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/media/banner.css +++ /dev/null @@ -1,32 +0,0 @@ -body -{ - background-color: #CCCCFF; - margin: 0px; - padding: 0px; -} - -/* Banner (top bar) classes */ - -.banner { } - -.banner-menu -{ - clear: both; - padding: .5em; - border-top: 2px solid #6666AA; -} - -.banner-title -{ - text-align: right; - font-size: 20pt; - font-weight: bold; - margin: .2em; -} - -.package-selector -{ - background-color: #AAAADD; - border: 1px solid black; - color: yellow; -} diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/media/stylesheet.css b/plugin/PHPMailer_v2.0.4/phpdocs/media/stylesheet.css deleted file mode 100644 index 94870fb5a..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/media/stylesheet.css +++ /dev/null @@ -1,144 +0,0 @@ -a { color: #336699; text-decoration: none; } -a:hover { color: #6699CC; text-decoration: underline; } -a:active { color: #6699CC; text-decoration: underline; } - -body { background : #FFFFFF; } -body, table { font-family: Georgia, Times New Roman, Times, serif; font-size: 10pt } -p, li { line-height: 140% } -a img { border: 0px; } -dd { margin-left: 0px; padding-left: 1em; } - -/* Page layout/boxes */ - -.info-box {} -.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #CCCCFF } -.info-box-body { border: 1px solid #999999; padding: .5em; } -.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } - -.oddrow { background-color: #F8F8F8; border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} -.evenrow { border: 1px solid #AAAAAA; padding: .5em; margin-bottom: 1em} - -.page-body { max-width: 800px; margin: auto; } -.tree dl { margin: 0px } - -/* Index formatting classes */ - -.index-item-body { margin-top: .5em; margin-bottom: .5em} -.index-item-description { margin-top: .25em } -.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } -.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} -.index-letter-title { font-size: 12pt; font-weight: bold } -.index-letter-menu { text-align: center; margin: 1em } -.index-letter { font-size: 12pt } - -/* Docbook classes */ - -.description {} -.short-description { font-weight: bold; color: #666666; } -.tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } -.parameters { padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; } -.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } -.package { } -.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } -.package-details { font-size: 85%; } -.sub-package { font-weight: bold; font-size: 120% } -.tutorial { border-width: thin; border-color: #0066ff } -.tutorial-nav-box { width: 100%; border: 1px solid #999999; background-color: #F8F8F8; } -.nav-button-disabled { color: #999999; } -.nav-button:active, -.nav-button:focus, -.nav-button:hover { background-color: #DDDDDD; outline: 1px solid #999999; text-decoration: none } -.folder-title { font-style: italic } - -/* Generic formatting */ - -.field { font-weight: bold; } -.detail { font-size: 8pt; } -.notes { font-style: italic; font-size: 8pt; } -.separator { background-color: #999999; height: 2px; } -.warning { color: #FF6600; } -.disabled { font-style: italic; color: #999999; } - -/* Code elements */ - -.line-number { } - -.class-table { width: 100%; } -.class-table-header { border-bottom: 1px dotted #666666; text-align: left} -.class-name { color: #000000; font-weight: bold; } - -.method-summary { padding-left: 1em; font-size: 8pt } -.method-header { } -.method-definition { margin-bottom: .3em } -.method-title { font-weight: bold; } -.method-name { font-weight: bold; } -.method-signature { font-size: 85%; color: #666666; margin: .5em 0em } -.method-result { font-style: italic; } - -.var-summary { padding-left: 1em; font-size: 8pt; } -.var-header { } -.var-title { margin-bottom: .3em } -.var-type { font-style: italic; } -.var-name { font-weight: bold; } -.var-default {} -.var-description { font-weight: normal; color: #000000; } - -.include-title { } -.include-type { font-style: italic; } -.include-name { font-weight: bold; } - -.const-title { } -.const-name { font-weight: bold; } - -/* Syntax highlighting */ - -.src-code { border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; } -*[class="src-code"] { line-height : 0.5em } - -.src-comm { color: green; } -.src-id { } -.src-inc { color: #0000FF; } -.src-key { color: #0000FF; } -.src-num { color: #CC0000; } -.src-str { color: #66cccc; } -.src-sym { font-weight: bold; } -.src-var { } - -.src-php { font-weight: bold; } - -.src-doc { color: #009999 } -.src-doc-close-template { color: #0000FF } -.src-doc-coretag { color: #0099FF; font-weight: bold } -.src-doc-inlinetag { color: #0099FF } -.src-doc-internal { color: #6699cc } -.src-doc-tag { color: #0080CC } -.src-doc-template { color: #0000FF } -.src-doc-type { font-style: italic } -.src-doc-var { font-style: italic } - -.tute-tag { color: #009999 } -.tute-attribute-name { color: #0000FF } -.tute-attribute-value { color: #0099FF } -.tute-entity { font-weight: bold; } -.tute-comment { font-style: italic } -.tute-inline-tag { color: #636311; font-weight: bold } - -/* tutorial */ - -.authors { } -.author { font-style: italic; font-weight: bold } -.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } -.example { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; } -*[class="example"] { line-height : 0.5em } -.listing { border: 1px dashed #999999; background-color: #EEEEEE; padding: .5em; white-space: nowrap; } -*[class="listing"] { line-height : 0.5em } -.release-info { font-size: 85%; font-style: italic; margin: 1em 0em } -.ref-title-box { } -.ref-title { } -.ref-purpose { font-style: italic; color: #666666 } -.ref-synopsis { } -.title { font-weight: bold; margin: 1em 0em 0em 0em; padding: .25em; border: 2px solid #999999; background-color: #CCCCFF } -.cmd-synopsis { margin: 1em 0em } -.cmd-title { font-weight: bold } -.toc { margin-left: 2em; padding-left: 0em } - diff --git a/plugin/PHPMailer_v2.0.4/phpdocs/packages.html b/plugin/PHPMailer_v2.0.4/phpdocs/packages.html deleted file mode 100644 index fdf40b0b8..000000000 --- a/plugin/PHPMailer_v2.0.4/phpdocs/packages.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file