From 706be214656a95f583bd895abd7b42720befd01b Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 27 Jul 2003 13:26:07 +0000 Subject: [PATCH] Upgraded phpmailer to 1.70 --- lib/phpmailer/ChangeLog.txt | 33 + lib/phpmailer/README | 187 +- lib/phpmailer/class.phpmailer.php | 1416 +++++++------- lib/phpmailer/class.smtp.php | 1785 +++++++++--------- lib/phpmailer/docs/extending.html | 148 -- lib/phpmailer/docs/faq.html | 66 - lib/phpmailer/docs/timeoutfix.diff | 23 - lib/phpmailer/language/phpmailer.lang-br.php | 21 + lib/phpmailer/language/phpmailer.lang-en.php | 24 + lib/phpmailer/phpdoc/allclasses-frame.html | 25 - lib/phpmailer/phpdoc/deprecated-list.html | 87 - lib/phpmailer/phpdoc/help-doc.html | 136 -- lib/phpmailer/phpdoc/index-all.html | 293 --- lib/phpmailer/phpdoc/index.html | 22 - lib/phpmailer/phpdoc/overview-tree.html | 92 - lib/phpmailer/phpdoc/packages.html | 26 - lib/phpmailer/phpdoc/phpmailer.html | 1043 ---------- lib/phpmailer/phpdoc/serialized-form.html | 87 - lib/phpmailer/phpdoc/stylesheet.css | 29 - lib/phpmailer/test/phpmailer_test.php | 546 ------ lib/phpmailer/test/phpunit.php | 376 ---- lib/phpmailer/test/rocks.png | Bin 1280 -> 0 bytes 22 files changed, 1756 insertions(+), 4709 deletions(-) delete mode 100644 lib/phpmailer/docs/extending.html delete mode 100644 lib/phpmailer/docs/faq.html delete mode 100644 lib/phpmailer/docs/timeoutfix.diff create mode 100644 lib/phpmailer/language/phpmailer.lang-br.php create mode 100644 lib/phpmailer/language/phpmailer.lang-en.php delete mode 100644 lib/phpmailer/phpdoc/allclasses-frame.html delete mode 100644 lib/phpmailer/phpdoc/deprecated-list.html delete mode 100644 lib/phpmailer/phpdoc/help-doc.html delete mode 100644 lib/phpmailer/phpdoc/index-all.html delete mode 100644 lib/phpmailer/phpdoc/index.html delete mode 100644 lib/phpmailer/phpdoc/overview-tree.html delete mode 100644 lib/phpmailer/phpdoc/packages.html delete mode 100644 lib/phpmailer/phpdoc/phpmailer.html delete mode 100644 lib/phpmailer/phpdoc/serialized-form.html delete mode 100644 lib/phpmailer/phpdoc/stylesheet.css delete mode 100644 lib/phpmailer/test/phpmailer_test.php delete mode 100644 lib/phpmailer/test/phpunit.php delete mode 100644 lib/phpmailer/test/rocks.png diff --git a/lib/phpmailer/ChangeLog.txt b/lib/phpmailer/ChangeLog.txt index 5241078425..5753e97ce6 100644 --- a/lib/phpmailer/ChangeLog.txt +++ b/lib/phpmailer/ChangeLog.txt @@ -1,5 +1,38 @@ ChangeLog +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) diff --git a/lib/phpmailer/README b/lib/phpmailer/README index 18f66ed738..137349aff1 100644 --- a/lib/phpmailer/README +++ b/lib/phpmailer/README @@ -1,85 +1,102 @@ -phpmailer - PHP email class -============================== -http://phpmailer.sourceforge.net - -Please read LICENSE for information on this softwares availability and -distribution. - -Class Features: -- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs -- Redundant SMTP servers -- Multipart/alternative emails for mail clients that do not read HTML email -- Support for 8bit, base64, binary, and quoted-printable encoding -- Uses the same methods as the very popular AspEmail active server (COM) component -- SMTP authentication -- Word wrap -- Many 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 expose -any of the popular features that many email clients use nowadays like -HTML-based emails and attachments. There are two proprietary -development tools out there that have all the functionality built into -easy to use classes: AspEmail(tm) and AspMail. Both of these -programs are COM components only available on Windows. They are also a -little pricey for smaller projects. - -Since I do Linux development I’ve missed these tools for my PHP coding. -So I built a version myself that implements the same methods (object -calls) that the Windows-based components do. It is open source and the -LGPL license allows you to place the class in your proprietary PHP -projects. - - -Installation: - -Copy class.phpmailer.php into your php.ini include_path. If you are -using the SMTP mailer then place class.smtp.php in your path as well. - -Example - -IsSMTP(); // set mailer to use SMTP -$mail->Host = "smtp1.site.com;smtp2.site.com"; // specify main and backup server -$mail->SMTPAuth = true // turn on SMTP authentication -$mail->Username = "jswan" // SMTP username -$mail->Password = "secret" // SMTP password - -$mail->From = "from@email.com"; -$mail->FromName = "Mailer"; -$mail->AddAddress("josh@site.com", "Josh Adams"); -$mail->AddAddress("ellen@site.com"); // name is optional -$mail->AddReplyTo("info@site.com", "Information"); - -$mail->WordWrap = 50; // set word wrap to 50 characters -$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; - exit; -} - -echo "Message has been sent"; -?> - -CHANGELOG - -See ChangeLog.txt - -Download: http://sourceforge.net/project/showfiles.php?group_id=26031 - -Brent R. Matzelle +PHPMailer +Full Featured Email Transfer Class for PHP +========================================== + +http://phpmailer.sourceforge.net/ + +This software is licenced under the LGPL. Please read LICENSE for information on the +software availability and distribution. + +Class Features: +- Send emails with multiple TOs, CCs, BCCs and REPLY-TOs +- Redundant SMTP servers +- Multipart/alternative emails for mail clients that do not read HTML email +- Support for 8bit, base64, binary, and quoted-printable encoding +- Uses the same methods as the very popular AspEmail active server (COM) component +- SMTP authentication +- Native language support +- Word wrap, and 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 expose +any of the popular features that many email clients use nowadays like +HTML-based emails and attachments. There are two proprietary +development tools out there that have all the functionality built into +easy to use classes: AspEmail(tm) and AspMail. Both of these +programs are COM components only available on Windows. They are also a +little pricey for smaller projects. + +Since I do Linux development I’ve missed these tools for my PHP coding. +So I built a version myself that implements the same methods (object +calls) that the Windows-based components do. It is open source and the +LGPL license allows you to place the class in your proprietary PHP +projects. + + +Installation: + +Copy class.phpmailer.php into your php.ini include_path. If you are +using the SMTP mailer then place class.smtp.php in your path as well. +In the language directory you will find several files like +phpmailer.lang-en.php. If you look right before the .php extension +that there are two letters. These represent the language type of the +translation file. For instance "en" is the English file and "br" is +the Portuguese file. Chose the file that best fits with your language +and place it in the PHP include path. If your language is English +then you have nothing more to do. If it is a different language then +you must point PHPMailer to the correct translation. To do this, call +the PHPMailer SetLanguage method like so: + +// To load the Portuguese version +$mail->SetLanguage("br", "/optional/path/to/language/directory"); + +That's it. You should now be ready to use PHPMailer! + + +A Simple Example: + +IsSMTP(); // set mailer to use SMTP +$mail->Host = "smtp1.example.com;smtp2.example.com"; // specify main and backup server +$mail->SMTPAuth = true // turn on SMTP authentication +$mail->Username = "jswan" // SMTP username +$mail->Password = "secret" // SMTP password + +$mail->From = "from@example.com"; +$mail->FromName = "Mailer"; +$mail->AddAddress("josh@example.net", "Josh Adams"); +$mail->AddAddress("ellen@example.com"); // name is optional +$mail->AddReplyTo("info@example.com", "Information"); + +$mail->WordWrap = 50; // set word wrap to 50 characters +$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; + exit; +} + +echo "Message has been sent"; +?> + +CHANGELOG + +See ChangeLog.txt + +Download: http://sourceforge.net/project/showfiles.php?group_id=26031 + +Brent R. Matzelle diff --git a/lib/phpmailer/class.phpmailer.php b/lib/phpmailer/class.phpmailer.php index 481b1bbc97..69a81b966e 100644 --- a/lib/phpmailer/class.phpmailer.php +++ b/lib/phpmailer/class.phpmailer.php @@ -1,98 +1,88 @@ +// Copyright (C) 2001 - 2003 Brent R. Matzelle // // License: LGPL, see LICENSE //////////////////////////////////////////////////// /** - * phpmailer - PHP email transport class + * PHPMailer - PHP email transport class + * @package PHPMailer * @author Brent R. Matzelle + * @copyright 2001 - 2003 Brent R. Matzelle */ -class phpmailer +class PHPMailer { ///////////////////////////////////////////////// // PUBLIC VARIABLES ///////////////////////////////////////////////// /** - * Email priority (1 = High, 3 = Normal, 5 = low). Default value is 3. - * @public - * @type int + * Email priority (1 = High, 3 = Normal, 5 = low). + * @var int */ var $Priority = 3; /** - * Sets the CharSet of the message. Default value is "iso-8859-1". - * @public - * @type string + * Sets the CharSet of the message. + * @var string */ var $CharSet = "iso-8859-1"; /** - * Sets the Content-type of the message. Default value is "text/plain". - * @public - * @type string + * Sets the Content-type of the message. + * @var string */ var $ContentType = "text/plain"; /** - * Sets the Encoding of the message. Options for this are "8bit" (default), + * Sets the Encoding of the message. Options for this are "8bit", * "7bit", "binary", "base64", and "quoted-printable". - * @public - * @type string + * @var string */ var $Encoding = "8bit"; /** - * Holds the most recent mailer error message. Default value is "". - * @public - * @type string + * Holds the most recent mailer error message. + * @var string */ var $ErrorInfo = ""; /** - * Sets the From email address for the message. Default value is "root@localhost". - * @public - * @type string + * Sets the From email address for the message. + * @var string */ var $From = "root@localhost"; /** - * Sets the From name of the message. Default value is "Root User". - * @public - * @type string + * Sets the From name of the message. + * @var string */ var $FromName = "Root User"; /** * Sets the Sender email of the message. If not empty, will be sent via -f to sendmail - * or as 'MAIL FROM' in smtp mode. Default value is "". - * @public - * @type string + * or as 'MAIL FROM' in smtp mode. + * @var string */ var $Sender = ""; /** - * Sets the Subject of the message. Default value is "". - * @public - * @type string + * Sets the Subject of the message. + * @var string */ var $Subject = ""; /** * Sets the Body of the message. This can be either an HTML or text body. - * If HTML then run IsHTML(true). Default value is "". - * @public - * @type string + * If HTML then run IsHTML(true). + * @var string */ var $Body = ""; @@ -101,73 +91,55 @@ class phpmailer * 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. - * Default value is "". - * @public - * @type string + * @var string */ var $AltBody = ""; /** * Sets word wrapping on the body of the message to a given number of - * characters. Default value is 0 (off). - * @public - * @type int + * characters. + * @var int */ var $WordWrap = 0; /** * Method to send mail: ("mail", "sendmail", or "smtp"). - * Default value is "mail". - * @public - * @type string + * @var string */ var $Mailer = "mail"; /** - * Sets the path of the sendmail program. Default value is - * "/usr/sbin/sendmail". - * @public - * @type string + * Sets the path of the sendmail program. + * @var string */ var $Sendmail = "/usr/sbin/sendmail"; - - /** - * Turns Microsoft mail client headers on and off. Useful mostly - * for older clients. Default value is false (off). - * @public - * @type bool - */ - var $UseMSMailHeaders = false; /** - * Path to phpmailer plugins. This is now only useful if the SMTP class + * Path to PHPMailer plugins. This is now only useful if the SMTP class * is in a different directory than the PHP include path. - * Default is empty (""). - * @public - * @type string + * @var string */ var $PluginDir = ""; /** - * Holds phpmailer version. - * @public - * @type string + * Holds PHPMailer version. + * @var string */ - var $Version = "1.54"; + var $Version = "1.70"; /** - * Sets the email address that a reading confirmation will be sent. Default value is "". - * @public - * @type string + * Sets the email address that a reading confirmation will be sent. + * @var string */ var $ConfirmReadingTo = ""; /** - * Sets the line endings of the message. Default is "\n"; - * @public - * @type string + * 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'. + * @var string */ - var $LE = "\n"; + var $Hostname = ""; ///////////////////////////////////////////////// @@ -178,127 +150,88 @@ class phpmailer * 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.domain.com:25;smtp2.domain.com"). + * (e.g. "smtp1.example.com:25;smtp2.example.com"). * Hosts will be tried in order. - * Default value is "localhost". - * @public - * @type string + * @var string */ var $Host = "localhost"; /** - * Sets the default SMTP server port. Default value is 25. - * @public - * @type int + * Sets the default SMTP server port. + * @var int */ var $Port = 25; /** - * Sets the SMTP HELO of the message. - * Default value is "localhost.localdomain". - * @public - * @type string + * Sets the SMTP HELO of the message (Default is $Hostname). + * @var string */ - var $Helo = "localhost.localdomain"; + var $Helo = ""; /** * Sets SMTP authentication. Utilizes the Username and Password variables. - * Default value is false (off). - * @public - * @type bool + * @var bool */ var $SMTPAuth = false; /** - * Sets SMTP username. Default value is "". - * @public - * @type string + * Sets SMTP username. + * @var string */ var $Username = ""; /** - * Sets SMTP password. Default value is "". - * @public - * @type string + * Sets SMTP password. + * @var string */ var $Password = ""; /** * Sets the SMTP server timeout in seconds. This function will not - * work with the win32 version. Default value is 10. - * @public - * @type int + * work with the win32 version. + * @var int */ var $Timeout = 10; /** - * Sets SMTP class debugging on or off. Default value is false (off). - * @public - * @type bool + * Sets SMTP class debugging on or off. + * @var bool */ var $SMTPDebug = false; - - ///////////////////////////////////////////////// - // PRIVATE VARIABLES - ///////////////////////////////////////////////// - /** - * Holds all "To" addresses. - * @type array + * 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(). + * @var bool */ - var $to = array(); + var $SMTPKeepAlive = false; - /** - * Holds all "CC" addresses. - * @type array + /**#@+ + * @access private */ + var $smtp = NULL; + var $to = array(); var $cc = array(); - - /** - * Holds all "BCC" addresses. - * @type array - */ var $bcc = array(); - - /** - * Holds all "Reply-To" addresses. - * @type array - */ var $ReplyTo = array(); - - /** - * Holds all string and binary attachments. - * @type array - */ var $attachment = array(); - - /** - * Holds all custom headers. - * @type array - */ var $CustomHeader = array(); - - /** - * Holds the type of the message. - * @type string - */ var $message_type = ""; - - /** - * Holds the message boundaries. - * @type string array - */ var $boundary = array(); - + var $language = array(); + var $error_count = 0; + var $LE = "\n"; + /**#@-*/ + ///////////////////////////////////////////////// // VARIABLE METHODS ///////////////////////////////////////////////// /** - * Sets message type to HTML. Returns void. - * @public - * @returns void + * Sets message type to HTML. + * @param bool $bool + * @return void */ function IsHTML($bool) { if($bool == true) @@ -309,9 +242,7 @@ class phpmailer /** * Sets Mailer to send message using SMTP. - * Returns void. - * @public - * @returns void + * @return void */ function IsSMTP() { $this->Mailer = "smtp"; @@ -319,9 +250,7 @@ class phpmailer /** * Sets Mailer to send message using PHP mail() function. - * Returns void. - * @public - * @returns void + * @return void */ function IsMail() { $this->Mailer = "mail"; @@ -329,21 +258,17 @@ class phpmailer /** * Sets Mailer to send message using the $Sendmail program. - * Returns void. - * @public - * @returns void + * @return void */ function IsSendmail() { $this->Mailer = "sendmail"; } /** - * Sets Mailer to send message using the qmail MTA. Returns void. - * @public - * @returns void + * Sets Mailer to send message using the qmail MTA. + * @return void */ function IsQmail() { - //$this->Sendmail = "/var/qmail/bin/qmail-inject"; $this->Sendmail = "/var/qmail/bin/sendmail"; $this->Mailer = "sendmail"; } @@ -354,9 +279,10 @@ class phpmailer ///////////////////////////////////////////////// /** - * Adds a "To" address. Returns void. - * @public - * @returns void + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void */ function AddAddress($address, $name = "") { $cur = count($this->to); @@ -367,12 +293,11 @@ class phpmailer /** * Adds a "Cc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" - * mailer. This is a PHP bug that has been submitted - * on http://bugs.php.net. The *NIX version of PHP - * functions correctly. Returns void. - * @public - * @returns void - */ + * mailer. + * @param string $address + * @param string $name + * @return void + */ function AddCC($address, $name = "") { $cur = count($this->cc); $this->cc[$cur][0] = trim($address); @@ -382,12 +307,10 @@ class phpmailer /** * Adds a "Bcc" address. Note: this function works * with the SMTP mailer on win32, not with the "mail" - * mailer. This is a PHP bug that has been submitted - * on http://bugs.php.net. The *NIX version of PHP - * functions correctly. - * Returns void. - * @public - * @returns void + * mailer. + * @param string $address + * @param string $name + * @return void */ function AddBCC($address, $name = "") { $cur = count($this->bcc); @@ -396,9 +319,10 @@ class phpmailer } /** - * Adds a "Reply-to" address. Returns void. - * @public - * @returns void + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return void */ function AddReplyTo($address, $name = "") { $cur = count($this->ReplyTo); @@ -414,9 +338,8 @@ class phpmailer /** * 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. Returns bool. - * @public - * @returns bool + * variable to view description of the error. + * @return bool */ function Send() { $header = ""; @@ -424,7 +347,7 @@ class phpmailer if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - $this->error_handler("You must provide at least one recipient email address"); + $this->SetError($this->Lang("provide_address")); return false; } @@ -432,35 +355,31 @@ class phpmailer if(!empty($this->AltBody)) $this->ContentType = "multipart/alternative"; - // Attach sender information & date - $header = $this->received(); - $header .= sprintf("Date: %s%s", $this->rfc_date(), $this->LE); - $header .= $this->create_header(); - - if(!$body = $this->create_body()) - return false; + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); - //echo "

".$header . $body . "
"; // debugging + if($body == "") { return false; } // Choose the mailer if($this->Mailer == "sendmail") { - if(!$this->sendmail_send($header, $body)) + if(!$this->SendmailSend($header, $body)) return false; } elseif($this->Mailer == "mail") { - if(!$this->mail_send($header, $body)) + if(!$this->MailSend($header, $body)) return false; } elseif($this->Mailer == "smtp") { - if(!$this->smtp_send($header, $body)) + if(!$this->SmtpSend($header, $body)) return false; } else { - $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer)); + $this->SetError($this->Mailer . $this->Lang("mailer_not_supported")); return false; } @@ -468,112 +387,11 @@ class phpmailer } /** - * Sends mail message to an assigned queue directory. Has an optional - * sendTime argument. This is used when the user wants the - * message to be sent from the queue at a predetermined time. - * The data must be a valid timestamp like that returned from - * the time() or strtotime() functions. Returns false on failure - * or the message file name if success. - * @public - * @returns string - */ - function SendToQueue($queue_path, $send_time = 0) { - $message = array(); - $header = ""; - $body = ""; - - // If invalid or empty just set to the current time - if($send_time == 0) - $send_time = time(); - - if(!is_dir($queue_path)) - { - $this->error_handler("The supplied queue directory does not exist"); - return false; - } - - if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) - { - $this->error_handler("You must provide at least one recipient email address"); - return false; - } - - // Set whether the message is multipart/alternative - if(!empty($this->AltBody)) - $this->ContentType = "multipart/alternative"; - - $header = $this->create_header(); - if(!$body = $this->create_body()) - return false; - - // Seed randomizer - mt_srand(time()); - $msg_id = md5(uniqid(mt_rand())); - - $fp = fopen($queue_path . $msg_id . ".pqm", "wb"); - if(!$fp) - { - $this->error_handler(sprintf("Could not write to %s directory", $queue_path)); - return false; - } - - $message[] = sprintf("----START PQM HEADER----%s", $this->LE); - $message[] = sprintf("SendTime: %s%s", $send_time, $this->LE); - $message[] = sprintf("Mailer: %s%s", $this->Mailer, $this->LE); - - // Choose the mailer - if($this->Mailer == "sendmail") - { - $message[] = sprintf("Sendmail: %s%s", $this->Sendmail, $this->LE); - $message[] = sprintf("Sender: %s%s", $this->Sender, $this->LE); - } - elseif($this->Mailer == "mail") - { - $message[] = sprintf("Sender: %s%s", $this->Sender, $this->LE); - $message[] = sprintf("Subject: %s%s", $this->Subject, $this->LE); - $message[] = sprintf("to: %s%s", $this->addr_list($this->to), $this->LE); - } - elseif($this->Mailer == "smtp") - { - $message[] = sprintf("Host: %s%s", $this->Host, $this->LE); - $message[] = sprintf("Port: %d%s", $this->Port, $this->LE); - $message[] = sprintf("Helo: %s%s", $this->Helo, $this->LE); - $message[] = sprintf("Timeout: %d%s", $this->Timeout, $this->LE); - - if($this->SMTPAuth) - $auth_no = 1; - else - $auth_no = 0; - $message[] = sprintf("SMTPAuth: %d%s", $auth_no, $this->LE); - $message[] = sprintf("Username: %s%s", $this->Username, $this->LE); - $message[] = sprintf("Password: %s%s", $this->Password, $this->LE); - $message[] = sprintf("From: %s%s", $this->From, $this->LE); - - $message[] = sprintf("to: %s%s", $this->addr_list($this->to), $this->LE); - $message[] = sprintf("cc: %s%s", $this->addr_list($this->cc), $this->LE); - $message[] = sprintf("bcc: %s%s", $this->addr_list($this->bcc), $this->LE); - } - else - { - $this->error_handler(sprintf("%s mailer is not supported", $this->Mailer)); - return false; - } - - $message[] = sprintf("----END PQM HEADER----%s", $this->LE); // end of pqm header - $message[] = $header; - $message[] = $body; - - fwrite($fp, join("", $message)); - - return ($msg_id . ".pqm"); - } - - /** - * Sends mail using the $Sendmail program. Returns bool. - * @private - * @returns bool + * Sends mail using the $Sendmail program. + * @access private + * @return bool */ - function sendmail_send($header, $body) { + function SendmailSend($header, $body) { if ($this->Sender != "") $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender); else @@ -581,7 +399,7 @@ class phpmailer if(!@$mail = popen($sendmail, "w")) { - $this->error_handler(sprintf("Could not execute %s", $this->Sendmail)); + $this->SetError($this->Lang("execute") . $this->Sendmail); return false; } @@ -591,7 +409,7 @@ class phpmailer $result = pclose($mail) >> 8 & 0xFF; if($result != 0) { - $this->error_handler(sprintf("Could not execute %s", $this->Sendmail)); + $this->SetError($this->Lang("execute") . $this->Sendmail); return false; } @@ -599,13 +417,11 @@ class phpmailer } /** - * Sends mail using the PHP mail() function. Returns bool. - * @private - * @returns bool + * Sends mail using the PHP mail() function. + * @access private + * @return bool */ - function mail_send($header, $body) { - //$to = substr($this->addr_append("To", $this->to), 4, -2); - + function MailSend($header, $body) { // Cannot add Bcc's to the $to $to = $this->to[0][0]; // no extra comma for($i = 1; $i < count($this->to); $i++) @@ -619,21 +435,18 @@ class phpmailer if ($this->Sender != "" && PHP_VERSION >= "4.0.5") { - // The fifth parameter to mail is only available in PHP >= 4.0.5 $params = sprintf("-oi -f %s", $this->Sender); - $rt = @mail($to, $this->Subject, $body, $header, $params); + $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header, $params); } else - { - $rt = @mail($to, $this->Subject, $body, $header); - } + $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header); if (isset($old_from)) ini_set("sendmail_from", $old_from); if(!$rt) { - $this->error_handler("Could not instantiate mail()"); + $this->SetError($this->Lang("instantiate")); return false; } @@ -644,86 +457,61 @@ class phpmailer * Sends mail via SMTP using PhpSMTP (Author: * Chris Ryan). Returns bool. Returns false if there is a * bad MAIL FROM, RCPT, or DATA input. - * @private - * @returns bool + * @access private + * @return bool */ - function smtp_send($header, $body) { + function SmtpSend($header, $body) { // Include SMTP class code, but not twice include_once($this->PluginDir . "class.smtp.php"); - - $smtp = new SMTP; - - $smtp->do_debug = $this->SMTPDebug; - - // Try to connect to all SMTP servers - $hosts = explode(";", $this->Host); - $index = 0; - $connection = false; - $smtp_from = ""; + $error = ""; $bad_rcpt = array(); - $e = ""; - // Retry while there is no connection - while($index < count($hosts) && $connection == false) - { - if(strstr($hosts[$index], ":")) - list($host, $port) = explode(":", $hosts[$index]); - else - { - $host = $hosts[$index]; - $port = $this->Port; - } - - if($smtp->Connect($host, $port, $this->Timeout)) - $connection = true; - //printf("%s host could not connect
", $hosts[$index]); //debug only - $index++; - } - if(!$connection) + if($this->smtp == NULL) { - $this->error_handler("SMTP Error: could not connect to SMTP host server(s)"); - return false; + if(!$this->SmtpConnect()) + return false; } // Must perform HELO before authentication - $smtp->Hello($this->Helo); + if ($this->Helo != '') + $this->smtp->Hello($this->Helo); + else + $this->smtp->Hello($this->ServerHostname()); // If user requests SMTP authentication if($this->SMTPAuth) { - if(!$smtp->Authenticate($this->Username, $this->Password)) + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { - $this->error_handler("SMTP Error: Could not authenticate"); + $this->SetError($this->Lang("authenticate")); + $this->smtp->Reset(); return false; } } - if ($this->Sender == "") - $smtp_from = $this->From; - else - $smtp_from = $this->Sender; - - if(!$smtp->Mail(sprintf("<%s>", $smtp_from))) + $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { - $e = sprintf("SMTP Error: From address [%s] failed", $smtp_from); - $this->error_handler($e); + $error = $this->Lang("from_failed") . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); return false; } // Attempt to send attach all recipients for($i = 0; $i < count($this->to); $i++) { - if(!$smtp->Recipient(sprintf("<%s>", $this->to[$i][0]))) + if(!$this->smtp->Recipient($this->to[$i][0])) $bad_rcpt[] = $this->to[$i][0]; } for($i = 0; $i < count($this->cc); $i++) { - if(!$smtp->Recipient(sprintf("<%s>", $this->cc[$i][0]))) + if(!$this->smtp->Recipient($this->cc[$i][0])) $bad_rcpt[] = $this->cc[$i][0]; } for($i = 0; $i < count($this->bcc); $i++) { - if(!$smtp->Recipient(sprintf("<%s>", $this->bcc[$i][0]))) + if(!$this->smtp->Recipient($this->bcc[$i][0])) $bad_rcpt[] = $this->bcc[$i][0]; } @@ -732,81 +520,137 @@ class phpmailer { for($i = 0; $i < count($bad_rcpt); $i++) { - if($i != 0) - $e .= ", "; - $e .= $bad_rcpt[$i]; + if($i != 0) { $error .= ", "; } + $error .= $bad_rcpt[$i]; } - $e = sprintf("SMTP Error: The following recipients failed [%s]", $e); - $this->error_handler($e); - + $error = $this->Lang("recipients_failed") . $error; + $this->SetError($error); + $this->smtp->Reset(); return false; } - - if(!$smtp->Data(sprintf("%s%s", $header, $body))) + if(!$this->smtp->Data($header . $body)) { - $this->error_handler("SMTP Error: Data not accepted"); + $this->SetError($this->Lang("data_not_accepted")); + $this->smtp->Reset(); return false; } - $smtp->Quit(); + if($this->SMTPKeepAlive == true) + $this->smtp->Reset(); + else + $this->SmtpClose(); return true; } + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access private + * @return bool + */ + function SmtpConnect() { + if($this->smtp == NULL) { $this->smtp = new SMTP(); } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(";", $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + // Retry while there is no connection + while($index < count($hosts) && $connection == false) + { + if(strstr($hosts[$index], ":")) + list($host, $port) = explode(":", $hosts[$index]); + else + { + $host = $hosts[$index]; + $port = $this->Port; + } + + if($this->smtp->Connect($host, $port, $this->Timeout)) + $connection = true; + $index++; + } + if(!$connection) + $this->SetError($this->Lang("connect_host")); + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + function SmtpClose() { + if($this->smtp != NULL) + { + if($this->smtp->Connected()) + { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type, $lang_path = "") { + if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) + include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); + else if(file_exists($lang_path.'phpmailer.lang-en.php')) + include($lang_path.'phpmailer.lang-en.php'); + else + { + $this->SetError("Could not load language file"); + return false; + } + $this->language = $PHPMAILER_LANG; + + return true; + } ///////////////////////////////////////////////// // MESSAGE CREATION METHODS ///////////////////////////////////////////////// /** - * Creates recipient headers. Returns string. - * @private - * @returns string + * Creates recipient headers. + * @access private + * @return string */ - function addr_append($type, $addr) { + function AddrAppend($type, $addr) { $addr_str = $type . ": "; - $addr_str .= $this->addr_format($addr[0]); + $addr_str .= $this->AddrFormat($addr[0]); if(count($addr) > 1) { for($i = 1; $i < count($addr); $i++) - { - $addr_str .= sprintf(", %s", $this->addr_format($addr[$i])); - } + $addr_str .= sprintf(", %s", $this->AddrFormat($addr[$i])); $addr_str .= $this->LE; } else $addr_str .= $this->LE; - return($addr_str); - } - - /** - * Creates a semicolon delimited list for use in pqm files. - * @private - * @returns string - */ - function addr_list($list_array) { - $addr_list = ""; - for($i = 0; $i < count($list_array); $i++) - { - if($i > 0) - $addr_list .= ";"; - $addr_list .= $list_array[$i][0]; - } - - return $addr_list; + return $addr_str; } /** * Formats an address correctly. - * @private - * @returns string + * @access private + * @return string */ - function addr_format($addr) { + function AddrFormat($addr) { if(empty($addr[1])) $formatted = $addr[0]; else - $formatted = sprintf('"%s" <%s>', addslashes($addr[1]), $addr[0]); + $formatted = sprintf('%s <%s>', $this->EncodeHeader($addr[1], 'phrase'), $addr[0]); return $formatted; } @@ -814,19 +658,16 @@ class phpmailer /** * Wraps message for use with mailers that do not * automatically perform wrapping and for quoted-printable. - * Original written by philippe. Returns string. - * @private - * @returns string + * Original written by philippe. + * @access private + * @return string */ - function word_wrap($message, $length, $qp_mode = false) { - if ($qp_mode) - $soft_break = sprintf(" =%s", $this->LE); - else - $soft_break = $this->LE; + function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; - $message = $this->fix_eol($message); + $message = $this->FixEOL($message); if (substr($message, -1) == $this->LE) - $message = substr($message, 0, -1); + $message = substr($message, 0, -1); $line = explode($this->LE, $message); $message = ""; @@ -879,10 +720,8 @@ class phpmailer else { $buf_o = $buf; - if ($e == 0) - $buf .= $word; - else - $buf .= " " . $word; + $buf .= ($e == 0) ? $word : (" " . $word); + if (strlen($buf) > $length and $buf_o != "") { $message .= $buf_o . $soft_break; @@ -893,199 +732,261 @@ class phpmailer $message .= $buf . $this->LE; } - return ($message); + return $message; + } + + /** + * Set the body wrapping. + * @access private + * @return void + */ + function SetWordWrap() { + if($this->WordWrap < 1) + return; + + switch($this->message_type) + { + case "alt": + // fall through + case "alt_attachment": + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } } /** - * Assembles message header. Returns a string if successful - * or false if unsuccessful. - * @private - * @returns string + * Assembles message header. + * @access private + * @return string */ - function create_header() { - $header = array(); + function CreateHeader() { + $result = ""; // Set the boundaries $uniq_id = md5(uniqid(time())); $this->boundary[1] = "b1_" . $uniq_id; $this->boundary[2] = "b2_" . $uniq_id; + $result .= $this->Received(); + $result .= $this->HeaderLine("Date", $this->RFCDate()); + if($this->Sender == "") + $result .= $this->HeaderLine("Return-Path", trim($this->From)); + else + $result .= $this->HeaderLine("Return-Path", trim($this->Sender)); + // To be created automatically by mail() - if(($this->Mailer != "mail") && (count($this->to) > 0)) - $header[] = $this->addr_append("To", $this->to); + if($this->Mailer != "mail") + { + if(count($this->to) > 0) + $result .= $this->AddrAppend("To", $this->to); + else if (count($this->cc) == 0) + $result .= $this->HeaderLine("To", "undisclosed-recipients:;"); + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend("From", $from); - $header[] = sprintf("From: \"%s\" <%s>%s", addslashes($this->FromName), - trim($this->From), $this->LE); if(count($this->cc) > 0) - $header[] = $this->addr_append("Cc", $this->cc); + $result .= $this->AddrAppend("Cc", $this->cc); // sendmail and mail() extract Bcc from the header before sending if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0)) - $header[] = $this->addr_append("Bcc", $this->bcc); + $result .= $this->AddrAppend("Bcc", $this->bcc); if(count($this->ReplyTo) > 0) - $header[] = $this->addr_append("Reply-to", $this->ReplyTo); + $result .= $this->AddrAppend("Reply-to", $this->ReplyTo); // mail() sets the subject itself if($this->Mailer != "mail") - $header[] = sprintf("Subject: %s%s", trim($this->Subject), $this->LE); + $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject))); - $header[] = sprintf("X-Priority: %d%s", $this->Priority, $this->LE); - $header[] = sprintf("X-Mailer: phpmailer [version %s]%s", $this->Version, $this->LE); - $header[] = sprintf("Return-Path: %s%s", trim($this->From), $this->LE); + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + $result .= $this->HeaderLine("X-Priority", $this->Priority); + $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]"); if($this->ConfirmReadingTo != "") - $header[] = sprintf("Disposition-Notification-To: <%s>%s", - trim($this->ConfirmReadingTo), $this->LE); + { + $result .= $this->HeaderLine("Disposition-Notification-To", + "<" . trim($this->ConfirmReadingTo) . ">"); + } // Add custom headers for($index = 0; $index < count($this->CustomHeader); $index++) - $header[] = sprintf("%s%s", $this->CustomHeader[$index], $this->LE); - - if($this->UseMSMailHeaders) - $header[] = $this->AddMSMailHeaders(); - - $header[] = sprintf("MIME-Version: 1.0%s", $this->LE); - - // Determine what type of message this is - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) - $this->message_type = "plain"; - else { - if(count($this->attachment) > 0) - $this->message_type = "attachments"; - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) - $this->message_type = "alt"; - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) - $this->message_type = "alt_attachments"; + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), + $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); } - + $result .= $this->HeaderLine("MIME-Version", "1.0"); + switch($this->message_type) { case "plain": - $header[] = sprintf("Content-Transfer-Encoding: %s%s", - $this->Encoding, $this->LE); - $header[] = sprintf("Content-Type: %s; charset = \"%s\"", + $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); break; case "attachments": + // fall through case "alt_attachments": if($this->EmbeddedImageCount() > 0) { - $header[] = sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", "multipart/related", $this->LE, $this->LE, $this->boundary[1], $this->LE); } else { - $header[] = sprintf("Content-Type: %s;%s", - "multipart/mixed", $this->LE); - $header[] = sprintf("\tboundary=\"%s\"%s", $this->boundary[1], $this->LE); + $result .= $this->HeaderLine("Content-Type", "multipart/mixed;"); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); } break; case "alt": - $header[] = sprintf("Content-Type: %s;%s", - "multipart/alternative", $this->LE); - $header[] = sprintf("\tboundary=\"%s\"%s", $this->boundary[1], $this->LE); + $result .= $this->HeaderLine("Content-Type", "multipart/alternative;"); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); break; } - // No additional lines when using mail() function if($this->Mailer != "mail") - $header[] = $this->LE.$this->LE; + $result .= $this->LE.$this->LE; - return(join("", $header)); + return $result; } /** - * Assembles the message body. Returns a string if successful - * or false if unsuccessful. - * @private - * @returns string + * Assembles the message body. Returns an empty string on failure. + * @access private + * @return string */ - function create_body() { - $body = array(); + function CreateBody() { + $result = ""; - // wordwrap the message body if set - if($this->WordWrap > 0) - $this->Body = $this->word_wrap($this->Body, $this->WordWrap); + $this->SetWordWrap(); switch($this->message_type) { case "alt": - // Return text of body - $bndry = new Boundary($this->boundary[1]); - $bndry->CharSet = $this->CharSet; - $bndry->Encoding = $this->Encoding; - $body[] = $bndry->GetSource(); - - $body[] = sprintf("%s%s", $this->AltBody, $this->LE.$this->LE); - - $bndry = new Boundary($this->boundary[1]); - $bndry->CharSet = $this->CharSet; - $bndry->ContentType = "text/html"; - $bndry->Encoding = $this->Encoding; - $body[] = $bndry->GetSource(); + $result .= $this->GetBoundary($this->boundary[1], "", + "text/plain", ""); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], "", + "text/html", ""); - $body[] = sprintf("%s%s", $this->Body, $this->LE.$this->LE); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; - // End the boundary - $body[] = sprintf("%s--%s--%s", $this->LE, - $this->boundary[1], $this->LE.$this->LE); + $result .= $this->EndBoundary($this->boundary[1]); break; case "plain": - $body[] = $this->Body; + $result .= $this->EncodeString($this->Body, $this->Encoding); break; case "attachments": - $bndry = new Boundary($this->boundary[1]); - $bndry->CharSet = $this->CharSet; - $bndry->ContentType = $this->ContentType; - $bndry->Encoding = $this->Encoding; - $body[] = sprintf("%s%s%s%s", $bndry->GetSource(false), $this->LE, - $this->Body, $this->LE); + $result .= $this->GetBoundary($this->boundary[1], "", "", ""); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; - if(!$body[] = $this->attach_all()) - return false; + $result .= $this->AttachAll(); break; case "alt_attachments": - $body[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $body[] = sprintf("Content-Type: %s;%s" . - "\tboundary=\"%s\"%s", + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . + "\tboundary=\"%s\"%s", "multipart/alternative", $this->LE, $this->boundary[2], $this->LE.$this->LE); // Create text body - $bndry = new Boundary($this->boundary[2]); - $bndry->CharSet = $this->CharSet; - $bndry->ContentType = "text/plain"; - $bndry->Encoding = $this->Encoding; - $body[] = $bndry->GetSource() . $this->LE; - - $body[] = sprintf("%s%s", $this->AltBody, $this->LE.$this->LE); + $result .= $this->GetBoundary($this->boundary[2], "", + "text/plain", "") . $this->LE; + + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; // Create the HTML body - $bndry = new Boundary($this->boundary[2]); - $bndry->CharSet = $this->CharSet; - $bndry->ContentType = "text/html"; - $bndry->Encoding = $this->Encoding; - $body[] = $bndry->GetSource() . $this->LE; + $result .= $this->GetBoundary($this->boundary[2], "", + "text/html", "") . $this->LE; - $body[] = sprintf("%s%s", $this->Body, $this->LE.$this->LE); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; - $body[] = sprintf("%s--%s--%s", $this->LE, - $this->boundary[2], $this->LE.$this->LE); + $result .= $this->EndBoundary($this->boundary[2]); - if(!$body[] = $this->attach_all()) - return false; + $result .= $this->AttachAll(); break; } - // Add the encode string code here - $sBody = join("", $body); - $sBody = $this->encode_string($sBody, $this->Encoding); + if($this->IsError()) + $result = ""; + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access private + */ + 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->HeaderLine("Content-Transfer-Encoding", $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access private + */ + function EndBoundary($boundary) { + return $this->LE . "--" . $boundary . "--" . $this->LE; + } + + /** + * Sets the message type. + * @access private + * @return void + */ + function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) + $this->message_type = "plain"; + else + { + if(count($this->attachment) > 0) + $this->message_type = "attachments"; + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) + $this->message_type = "alt"; + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) + $this->message_type = "alt_attachments"; + } + } - return $sBody; + /** + * Returns a formatted header line. + * @access private + * @return string + */ + function HeaderLine($name, $value) { + return $name . ": " . $value . $this->LE; } + /** + * Returns a formatted mail line. + * @access private + * @return string + */ + function TextLine($value) { + return $value . $this->LE; + } ///////////////////////////////////////////////// // ATTACHMENT METHODS @@ -1093,17 +994,19 @@ class phpmailer /** * Adds an attachment from a path on the filesystem. - * Checks if attachment is valid and then adds - * the attachment to the list. * Returns false if the file could not be found * or accessed. - * @public - * @returns bool - */ - function AddAttachment($path, $name = "", $encoding = "base64", $type = "application/octet-stream") { + * @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 type. + * @return bool + */ + function AddAttachment($path, $name = "", $encoding = "base64", + $type = "application/octet-stream") { if(!@is_file($path)) { - $this->error_handler(sprintf("Could not access [%s] file", $path)); + $this->SetError($this->Lang("file_access") . $path); return false; } @@ -1127,11 +1030,11 @@ class phpmailer /** * Attaches all fs, string, and binary attachments to the message. - * Returns a string if successful or false if unsuccessful. - * @private - * @returns string + * Returns an empty string on failure. + * @access private + * @return string */ - function attach_all() { + function AttachAll() { // Return text of body $mime = array(); @@ -1139,15 +1042,12 @@ class phpmailer for($i = 0; $i < count($this->attachment); $i++) { // Check for string attachment - $isString = $this->attachment[$i][5]; - if ($isString) - { + $bString = $this->attachment[$i][5]; + if ($bString) $string = $this->attachment[$i][0]; - } else - { $path = $this->attachment[$i][0]; - } + $filename = $this->attachment[$i][1]; $name = $this->attachment[$i][2]; $encoding = $this->attachment[$i][3]; @@ -1161,69 +1061,67 @@ class phpmailer if($disposition == "inline") $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - else - $mime[] = sprintf("Content-ID: <%s>%s", $name, $this->LE); $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); // Encode as string attachment - if($isString) + if($bString) { - if(!$mime[] = sprintf("%s%s", $this->encode_string($string, $encoding), - $this->LE.$this->LE)) - return false; + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { return ""; } + $mime[] = $this->LE.$this->LE; } else { - if(!$mime[] = sprintf("%s%s", $this->encode_file($path, $encoding), - $this->LE.$this->LE)) - return false; - - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); - + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { return ""; } + $mime[] = $this->LE.$this->LE; } } - return(join("", $mime)); + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join("", $mime); } /** - * Encodes attachment in requested format. Returns a - * string if successful or false if unsuccessful. - * @private - * @returns string + * Encodes attachment in requested format. Returns an + * empty string on failure. + * @access private + * @return string */ - function encode_file ($path, $encoding = "base64") { + function EncodeFile ($path, $encoding = "base64") { if(!@$fd = fopen($path, "rb")) { - $this->error_handler(sprintf("File Error: Could not open file %s", $path)); - return false; + $this->SetError($this->Lang("file_open") . $path); + return ""; } - $file = fread($fd, filesize($path)); - $encoded = $this->encode_string($file, $encoding); + $file_buffer = fread($fd, filesize($path)); + $file_buffer = $this->EncodeString($file_buffer, $encoding); fclose($fd); - return($encoded); + return $file_buffer; } /** - * Encodes string to requested format. Returns a - * string if successful or false if unsuccessful. - * @private - * @returns string + * Encodes string to requested format. Returns an + * empty string on failure. + * @access private + * @return string */ - function encode_string ($str, $encoding = "base64") { + function EncodeString ($str, $encoding = "base64") { + $encoded = ""; switch(strtolower($encoding)) { case "base64": // chunk_split is found in PHP >= 3.0.6 - $encoded = chunk_split(base64_encode($str)); + $encoded = chunk_split(base64_encode($str), 76, $this->LE); break; case "7bit": case "8bit": - $encoded = $this->fix_eol($str); - if (substr($encoded, -2) != $this->LE) + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) $encoded .= $this->LE; break; @@ -1232,35 +1130,117 @@ class phpmailer break; case "quoted-printable": - $encoded = $this->encode_qp($str); + $encoded = $this->EncodeQP($str); break; default: - $this->error_handler(sprintf("Unknown encoding: %s", $encoding)); - return false; + $this->SetError($this->Lang("encoding") . $encoding); + break; } - return($encoded); + return $encoded; } /** - * Encode string to quoted-printable. Returns a string. - * @private - * @returns string + * Encode a header string to best of Q, B, quoted or none. + * @access private + * @return string */ - function encode_qp ($str) { - $encoded = $this->fix_eol($str); - if (substr($encoded, -2) != $this->LE) + function EncodeHeader ($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + // Can't use addslashes as we don't know what value has magic_quotes_sybase. + $encoded = addcslashes($str, "\0..\37\177\\\""); + + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) + return ($encoded); + else + return ("\"$encoded\""); + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + // Fall-through + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) + return ($str); + + $maxlen = 75 - 7 - strlen($this->CharSet); + // Try to select the encoding which should produce the shortest output + if (strlen($str)/3 < $x) { + $encoding = 'B'; + $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("=".$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Encode string to quoted-printable. + * @access private + * @return string + */ + function EncodeQP ($str) { + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) $encoded .= $this->LE; // Replace every high ascii, control and = characters - $encoded = preg_replace("/([\001-\010\013\014\016-\037\075\177-\377])/e", + $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e', "'='.sprintf('%02X', ord('\\1'))", $encoded); // Replace every spaces and tabs when it's the last character on a line $encoded = preg_replace("/([\011\040])".$this->LE."/e", "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded); // Maximum line length of 76 characters before CRLF (74 + space + '=') - $encoded = $this->word_wrap($encoded, 74, true); + $encoded = $this->WrapText($encoded, 74, true); + + return $encoded; + } + + /** + * Encode string to q encoding. + * @access private + * @return string + */ + function EncodeQ ($str, $position = "text") { + // There should not be any EOL in the string + $encoded = preg_replace("[\r\n]", "", $str); + + switch (strtolower($position)) { + case "phrase": + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case "comment": + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case "text": + default: + // Replace every high ascii, control =, ? and _ characters + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + // Replace every spaces to _ (more readable than =20) + $encoded = str_replace(" ", "_", $encoded); return $encoded; } @@ -1269,10 +1249,14 @@ class phpmailer * 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. - * @public - * @returns void - */ - function AddStringAttachment($string, $filename, $encoding = "base64", $type = "application/octet-stream") { + * @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 type. + * @return void + */ + function AddStringAttachment($string, $filename, $encoding = "base64", + $type = "application/octet-stream") { // Append to $attachment array $cur = count($this->attachment); $this->attachment[$cur][0] = $string; @@ -1287,17 +1271,21 @@ class phpmailer /** * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. - * @param cid this is the Content Id of the attachment. Use this to identify + * just about any other document. + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify * the Id for accessing the image in an HTML form. - * @public - * @returns bool + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension type. + * @return bool */ - function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", $type = "application/octet-stream") { + function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", + $type = "application/octet-stream") { if(!@is_file($path)) { - $this->error_handler(sprintf("Could not access [%s] file", $path)); + $this->SetError($this->Lang("file_access") . $path); return false; } @@ -1321,18 +1309,18 @@ class phpmailer /** * Returns the number of embedded images in an email. - * @private - * @returns int + * @access private + * @return int */ function EmbeddedImageCount() { - $ret = 0; + $result = 0; for($i = 0; $i < count($this->attachment); $i++) { if($this->attachment[$i][6] == "inline") - $ret++; + $result++; } - return $ret; + return $result; } ///////////////////////////////////////////////// @@ -1341,8 +1329,7 @@ class phpmailer /** * Clears all recipients assigned in the TO array. Returns void. - * @public - * @returns void + * @return void */ function ClearAddresses() { $this->to = array(); @@ -1350,8 +1337,7 @@ class phpmailer /** * Clears all recipients assigned in the CC array. Returns void. - * @public - * @returns void + * @return void */ function ClearCCs() { $this->cc = array(); @@ -1359,8 +1345,7 @@ class phpmailer /** * Clears all recipients assigned in the BCC array. Returns void. - * @public - * @returns void + * @return void */ function ClearBCCs() { $this->bcc = array(); @@ -1368,8 +1353,7 @@ class phpmailer /** * Clears all recipients assigned in the ReplyTo array. Returns void. - * @public - * @returns void + * @return void */ function ClearReplyTos() { $this->ReplyTo = array(); @@ -1378,8 +1362,7 @@ class phpmailer /** * Clears all recipients assigned in the TO, CC and BCC * array. Returns void. - * @public - * @returns void + * @return void */ function ClearAllRecipients() { $this->to = array(); @@ -1390,8 +1373,7 @@ class phpmailer /** * Clears all previously set filesystem, string, and binary * attachments. Returns void. - * @public - * @returns void + * @return void */ function ClearAttachments() { $this->attachment = array(); @@ -1399,8 +1381,7 @@ class phpmailer /** * Clears all custom headers. Returns void. - * @public - * @returns void + * @return void */ function ClearCustomHeaders() { $this->CustomHeader = array(); @@ -1414,55 +1395,67 @@ class phpmailer /** * Adds the error message to the error container. * Returns void. - * @private - * @returns void + * @access private + * @return void */ - function error_handler($msg) { + function SetError($msg) { + $this->error_count++; $this->ErrorInfo = $msg; } /** * Returns the proper RFC 822 formatted date. Returns string. - * @private - * @returns string + * @access private + * @return string */ - function rfc_date() { + function RFCDate() { $tz = date("Z"); $tzs = ($tz < 0) ? "-" : "+"; $tz = abs($tz); $tz = ($tz/3600)*100 + ($tz%3600)/60; - $date = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz); - return $date; + $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz); + + return $result; } /** - * Returns received header for message tracing. Returns string. - * @private - * @returns string + * Returns Received header for message tracing. Returns string. + * @access private + * @return string */ - function received() { - // Check for vars because they might not exist. Possibly - // write a small retrieval function (that mailer can use too!) + function Received() { + if ($this->ServerVar('SERVER_NAME') != '') + { + $protocol = ($this->ServerVar('HTTPS') == 'on') ? 'HTTPS' : 'HTTP'; + $remote = $this->ServerVar('REMOTE_HOST'); + if($remote == "") + $remote = 'phpmailer'; + $remote .= ' (['.$this->ServerVar('REMOTE_ADDR').'])'; + } + else + { + $protocol = 'local'; + $remote = $this->ServerVar('USER'); + if($remote == '') + $remote = 'phpmailer'; + } - $str = sprintf("Received: from phpmailer ([%s]) by %s " . - "with HTTP;%s\t %s%s", - $this->get_server_var("REMOTE_ADDR"), - $this->get_server_var("SERVER_NAME"), - $this->LE, - $this->rfc_date(), - $this->LE); + $result = sprintf("Received: from %s %s\tby %s " . + "with %s (PHPMailer);%s\t%s%s", $remote, $this->LE, + $this->ServerHostname(), $protocol, $this->LE, + $this->RFCDate(), $this->LE); - return $str; + return $result; } /** * Returns the appropriate server variable. Should work with both * PHP 4.1.0+ as well as older versions. Returns an empty string * if nothing is found. - * @private - * @returns mixed + * @access private + * @return mixed */ - function get_server_var($varName) { + function ServerVar($varName) { global $HTTP_SERVER_VARS; global $HTTP_ENV_VARS; @@ -1480,135 +1473,62 @@ class phpmailer } /** - * Changes every end of line from CR or LF to CRLF. Returns string. - * @private - * @returns string + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string */ - function fix_eol($str) { - $str = str_replace("\r\n", "\n", $str); - $str = str_replace("\r", "\n", $str); - $str = str_replace("\n", $this->LE, $str); - return $str; - } + function ServerHostname() { + if ($this->Hostname != "") + $result = $this->Hostname; + elseif ($this->ServerVar('SERVER_NAME') != "") + $result = $this->ServerVar('SERVER_NAME'); + else + $result = "localhost.localdomain"; - /** - * Adds a custom header. Returns void. - * @public - * @returns void - */ - function AddCustomHeader($custom_header) { - $this->CustomHeader[] = $custom_header; + return $result; } /** - * Adds all the Microsoft message headers. Returns string. - * @private - * @returns string + * Returns a message in the appropriate language. + * @access private + * @return string */ - function AddMSMailHeaders() { - $MSHeader = ""; - if($this->Priority == 1) - $MSPriority = "High"; - elseif($this->Priority == 5) - $MSPriority = "Low"; + function Lang($key) { + if(count($this->language) < 1) + $this->SetLanguage("en"); // set the default language + + if(isset($this->language[$key])) + return $this->language[$key]; else - $MSPriority = "Medium"; - - $MSHeader .= sprintf("X-MSMail-Priority: %s%s", $MSPriority, $this->LE); - $MSHeader .= sprintf("Importance: %s%s", $MSPriority, $this->LE); - - return($MSHeader); + return ""; } - -} - - -/** - * Boundary - MIME message boundary class - * @author Brent R. Matzelle - */ -class Boundary -{ - /** - * Sets the boundary ID. - * @private - * @type string - */ - var $ID = 0; - - /** - * Sets the boundary Content Type. - * @public - * @type string - */ - var $ContentType = "text/plain"; - + /** - * Sets the Encoding. - * @public - * @type string + * Returns true if an error occurred. + * @return bool */ - var $Encoding = ""; + function IsError() { + return ($this->error_count > 0); + } /** - * Sets an attachment disposition. - * @public - * @type string + * Changes every end of line from CR or LF to CRLF. Returns string. + * @access private + * @return string */ - var $Disposition = ""; + function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } /** - * Sets an attachment file name. - * @public - * @type string - */ - var $FileName = ""; - - /** - * Sets the Char set. - * @public - * @type string - */ - var $CharSet = ""; - - /** - * Sets the line endings of the message. Default is "\n"; - * @public - * @type string - */ - var $LE = "\n"; - - /** - * Main constructor. + * Adds a custom header. Returns void. + * @return void */ - function Boundary($boundary_id) { - $this->ID = $boundary_id; - } - - /** - * Returns the source of the boundary. - * @public - * @returns string - */ - function GetSource($bLineEnding = true) { - $ret = array(); - $mime[] = sprintf("--%s%s", $this->ID, $this->LE); - $mime[] = sprintf("Content-Type: %s; charset = \"%s\"%s", - $this->ContentType, $this->CharSet, $this->LE); - //$mime[] = sprintf("Content-Transfer-Encoding: %s%s", $this->Encoding, - // $this->LE); - - if(strlen($this->Disposition) > 0) - { - $mime[] = sprintf("Content-Disposition: %s;"); - if(strlen($this->FileName) > 0) - $mime[] = sprinf("filename=\"%s\"", $this->$this->FileName); - } - - if($bLineEnding) - $mime[] = $this->LE; - - return join("", $mime); + function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(":", $custom_header, 2); } } diff --git a/lib/phpmailer/class.smtp.php b/lib/phpmailer/class.smtp.php index c169be674d..a401374556 100644 --- a/lib/phpmailer/class.smtp.php +++ b/lib/phpmailer/class.smtp.php @@ -1,1008 +1,1039 @@ - * Created: 03/26/2001 - * - * TODO: - * - Move all the duplicate code to a utility function - * Most of the functions have the first lines of - * code do the same processing. If this can be moved - * into a utility function then it would reduce the - * overall size of the code significantly. +//////////////////////////////////////////////////// +// SMTP - PHP SMTP class +// +// Version 1.02 +// +// Define an SMTP class that can be used to connect +// and communicate with any SMTP server. It implements +// all the SMTP functions defined in RFC821 except TURN. +// +// Author: Chris Ryan +// +// License: LGPL, see LICENSE +//////////////////////////////////////////////////// + +/** + * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP + * commands except TURN which will always return a not implemented + * error. SMTP also provides some utility methods for sending mail + * to an SMTP server. + * @package PHPMailer + * @author Chris Ryan + */ +class SMTP +{ + /** + * SMTP server port + * @var int */ + var $SMTP_PORT = 25; + + /** + * SMTP reply line ending + * @var string + */ + var $CRLF = "\r\n"; + + /** + * Sets whether debugging is turned on + * @var bool + */ + var $do_debug; # the level of debug to perform - /* - * STMP is rfc 821 compliant and implements all the rfc 821 SMTP - * commands except TURN which will always return a not implemented - * error. SMTP also provides some utility methods for sending mail - * to an SMTP server. + /**#@+ + * @access private */ - class SMTP { - var $SMTP_PORT = 25; # the default SMTP PORT - var $CRLF = "\r\n"; # CRLF pair - - var $smtp_conn; # the socket to the server - var $error; # error if any on the last call - var $helo_rply; # the reply the server sent to us for HELO - - var $do_debug; # the level of debug to perform - - /* - * SMTP() - * - * Initialize the class so that the data is in a known state. - */ - function SMTP() { - $this->smtp_conn = 0; - $this->error = null; - $this->helo_rply = null; - - $this->do_debug = 0; - } - - /************************************************************ - * CONNECTION FUNCTIONS * - ***********************************************************/ - - /* - * Connect($host, $port=0, $tval=30) - * - * 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 - */ - function Connect($host,$port=0,$tval=30) { - # set the error val to null so there is no confusion - $this->error = null; - - # make sure we are __not__ connected - if($this->connected()) { - # ok we are connected! what should we do? - # for now we will just give an error saying we - # are already connected - $this->error = - array("error" => "Already connected to a server"); - return false; - } + var $smtp_conn; # the socket to the server + var $error; # error if any on the last call + var $helo_rply; # the reply the server sent to us for HELO + /**#@-*/ + + /** + * Initialize the class so that the data is in a known state. + * @access public + * @return void + */ + function SMTP() { + $this->smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; - if(empty($port)) { - $port = $this->SMTP_PORT; - } + $this->do_debug = 0; + } - #connect to the smtp server - $this->smtp_conn = fsockopen($host, # the host of the server - $port, # the port to use - $errno, # error number if any - $errstr, # error message if any - $tval); # give up after ? secs - # verify we connected properly - if(empty($this->smtp_conn)) { - $this->error = array("error" => "Failed to connect to server", - "errno" => $errno, - "errstr" => $errstr); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": $errstr ($errno)" . $this->CRLF; - } - return false; + /************************************************************* + * CONNECTION FUNCTIONS * + ***********************************************************/ + + /** + * 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 + * @return bool + */ + function Connect($host,$port=0,$tval=30) { + # set the error val to null so there is no confusion + $this->error = null; + + # make sure we are __not__ connected + if($this->connected()) { + # ok we are connected! what should we do? + # for now we will just give an error saying we + # are already connected + $this->error = + array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + #connect to the smtp server + $this->smtp_conn = fsockopen($host, # the host of the server + $port, # the port to use + $errno, # error number if any + $errstr, # error message if any + $tval); # give up after ? secs + # verify we connected properly + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": $errstr ($errno)" . $this->CRLF; } + return false; + } - # sometimes the SMTP server takes a little longer to respond - # so we will give it a longer timeout for the first read - // Windows still does not have support for this timeout function - if(substr(PHP_OS, 0, 3) != "WIN") - socket_set_timeout($this->smtp_conn, 1, 0); + # sometimes the SMTP server takes a little longer to respond + # so we will give it a longer timeout for the first read + // Windows still does not have support for this timeout function + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); - # get any announcement stuff - $announce = $this->get_lines(); + # get any announcement stuff + $announce = $this->get_lines(); - # set the timeout of any socket functions at 1/10 of a second - //if(function_exists("socket_set_timeout")) - // socket_set_timeout($this->smtp_conn, 0, 100000); + # set the timeout of any socket functions at 1/10 of a second + //if(function_exists("socket_set_timeout")) + // socket_set_timeout($this->smtp_conn, 0, 100000); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; + } - return true; + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; } - /* - * Authenticate() - * - * Performs SMTP authentication. Must be run after running the - * Hello() method. Returns true if successfully authenticated. - */ - function Authenticate($username, $password) { - // Start authentication - fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($code != 334) { - $this->error = - array("error" => "AUTH not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - // Send encoded username - fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($code != 334) { - $this->error = - array("error" => "Username not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - // Send encoded password - fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); - - $rply = $this->get_lines(); - $code = substr($rply,0,3); + return true; + } - if($code != 235) { - $this->error = - array("error" => "Password not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); + /** + * Returns true if connected to a server otherwise false + * @access private + * @return bool + */ + function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + # hmm this is an odd situation... the socket is + # valid but we aren't connected anymore if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; + echo "SMTP -> NOTICE:" . $this->CRLF . + "EOF caught while checking if connected"; } + $this->Close(); return false; } - - return true; - } - - /* - * Connected() - * - * Returns true if connected to a server otherwise false - */ - function Connected() { - if(!empty($this->smtp_conn)) { - $sock_status = socket_get_status($this->smtp_conn); - if($sock_status["eof"]) { - # hmm this is an odd situation... the socket is - # valid but we aren't connected anymore - if($this->do_debug >= 1) { - echo "SMTP -> NOTICE:" . $this->CRLF . - "EOF caught while checking if connected"; - } - $this->Close(); - return false; - } - return true; # everything looks good - } - return false; + return true; # everything looks good } + return false; + } - /* - * Close() - * - * 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. - */ - function Close() { - $this->error = null; # so there is no confusion - $this->helo_rply = null; - if(!empty($this->smtp_conn)) { - # close the connection and cleanup - fclose($this->smtp_conn); - $this->smtp_conn = 0; - } + /** + * 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 + * @return void + */ + function Close() { + $this->error = null; # so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + # close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; } + } - /************************************************************** - * SMTP COMMANDS * - *************************************************************/ - - /* - * Data($msg_data) - * - * 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 seperated by and additional . - * - * Implements rfc 821: DATA - * - * SMTP CODE INTERMEDIATE: 354 - * [data] - * . - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 552,554,451,452 - * SMTP CODE FAILURE: 451,554 - * SMTP CODE ERROR : 500,501,503,421 - */ - function Data($msg_data) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Data() without being connected"); - return false; - } + /*************************************************************** + * SMTP COMMANDS * + *************************************************************/ - fputs($this->smtp_conn,"DATA" . $this->CRLF); + /** + * 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 seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * 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 + * @return bool + */ + function Data($msg_data) { + $this->error = null; # so no confusion is caused - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + fputs($this->smtp_conn,"DATA" . $this->CRLF); - if($code != 354) { - $this->error = - array("error" => "DATA command not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - # the server is ready to accept data! - # according to rfc 821 we should not send more than 1000 - # including the CRLF - # characters on a single line 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. - # in addition we will be looking for lines that start with - # a period '.' and append and additional period '.' to that - # line. NOTE: this does not count towards are limit. - - # normalize the line breaks so we know the explode works - $msg_data = str_replace("\r\n","\n",$msg_data); - $msg_data = str_replace("\r","\n",$msg_data); - $lines = explode("\n",$msg_data); - - # we need to find a good way to determine is headers are - # in the msg_data or if it is a straight msg body - # currently I'm assuming rfc 822 definitions of msg headers - # and if the first field of the first line (':' sperated) - # does not contain a space then it _should_ be a header - # and we can process all lines before a blank "" line as - # headers. - $field = substr($lines[0],0,strpos($lines[0],":")); - $in_headers = false; - if(!empty($field) && !strstr($field," ")) { - $in_headers = true; + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - $max_line_length = 998; # used below; set here for ease in change + # the server is ready to accept data! + # according to rfc 821 we should not send more than 1000 + # including the CRLF + # characters on a single line 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. + # in addition we will be looking for lines that start with + # a period '.' and append and additional period '.' to that + # line. NOTE: this does not count towards are limit. + + # normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + # we need to find a good way to determine is headers are + # in the msg_data or if it is a straight msg body + # currently I'm assuming rfc 822 definitions of msg headers + # and if the first field of the first line (':' sperated) + # does not contain a space then it _should_ be a header + # and we can process all lines before a blank "" line as + # headers. + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } - while(list(,$line) = @each($lines)) { - $lines_out = null; - if($line == "" && $in_headers) { - $in_headers = false; - } - # ok we need to break this line up into several - # smaller lines - while(strlen($line) > $max_line_length) { - $pos = strrpos(substr($line,0,$max_line_length)," "); - $lines_out[] = substr($line,0,$pos); - $line = substr($line,$pos + 1); - # if we are processing headers we need to - # add a LWSP-char to the front of the new line - # rfc 822 on long msg headers - if($in_headers) { - $line = "\t" . $line; - } + $max_line_length = 998; # used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + # ok we need to break this line up into several + # smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + # if we are processing headers we need to + # add a LWSP-char to the front of the new line + # rfc 822 on long msg headers + if($in_headers) { + $line = "\t" . $line; } - $lines_out[] = $line; - - # now send the lines to the server - while(list(,$line_out) = @each($lines_out)) { - if(strlen($line_out) > 0) - { - if(substr($line_out, 0, 1) == ".") { - $line_out = "." . $line_out; - } + } + $lines_out[] = $line; + + # now send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; } - fputs($this->smtp_conn,$line_out . $this->CRLF); } + fputs($this->smtp_conn,$line_out . $this->CRLF); } + } - # ok all the message data has been sent so lets get this - # over with aleady - fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + # ok all the message data has been sent so lets get this + # over with aleady + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - if($code != 250) { - $this->error = - array("error" => "DATA not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * Expand($name) - * - * 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: - * [ ] - * The definition of is defined in rfc 821 - * - * Implements rfc 821: EXPN - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 550 - * SMTP CODE ERROR : 500,501,502,504,421 - */ - function Expand($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Expand() without being connected"); - return false; + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return true; + } - fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); + /** + * 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: + * [ ] + * The definition of is defined in rfc 821 + * + * Implements rfc 821: EXPN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 550 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string array + */ + function Expand($name) { + $this->error = null; # so no confusion is caused - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Expand() without being connected"); + return false; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); - if($code != 250) { - $this->error = - array("error" => "EXPN not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } + $rply = $this->get_lines(); + $code = substr($rply,0,3); - # parse the reply and place in our array to return to user - $entries = explode($this->CRLF,$rply); - while(list(,$l) = @each($entries)) { - $list[] = substr($l,4); - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - return $rval; - } - - /* - * Hello($host="") - * - * 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 - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 501, 504, 421 - */ - function Hello($host="") { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Hello() without being connected"); - return false; + if($code != 250) { + $this->error = + array("error" => "EXPN not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - # if a hostname for the HELO wasn't specified determine - # a suitable one to send - if(empty($host)) { - # we need to determine some sort of appopiate default - # to send to the server - $host = "localhost"; - } + # parse the reply and place in our array to return to user + $entries = explode($this->CRLF,$rply); + while(list(,$l) = @each($entries)) { + $list[] = substr($l,4); + } - fputs($this->smtp_conn,"HELO " . $host . $this->CRLF); + return $list; + } - $rply = $this->get_lines(); - $code = substr($rply,0,3); + /** + * 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 + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + function Hello($host="") { + $this->error = null; # so no confusion is caused - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; - } + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } - if($code != 250) { - $this->error = - array("error" => "HELO not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } + # if a hostname for the HELO wasn't specified determine + # a suitable one to send + if(empty($host)) { + # we need to determine some sort of appopiate default + # to send to the server + $host = "localhost"; + } - $this->helo_rply = $rply; - - return true; - } - - /* - * Help($keyword="") - * - * 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 [ ] - * - * SMTP CODE SUCCESS: 211,214 - * SMTP CODE ERROR : 500,501,502,504,421 - * - */ - function Help($keyword="") { - $this->error = null; # to avoid confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Help() without being connected"); + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) + { + if(!$this->SendHello("HELO", $host)) return false; - } + } - $extra = ""; - if(!empty($keyword)) { - $extra = " " . $keyword; - } + return true; + } - fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; + } - if($code != 211 && $code != 214) { - $this->error = - array("error" => "HELP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - return $rply; - } - - /* - * Mail($from) - * - * 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: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,421 - */ - function Mail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Mail() without being connected"); - return false; - } + $this->helo_rply = $rply; + + return true; + } - fputs($this->smtp_conn,"MAIL FROM:" . $from . $this->CRLF); + /** + * 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 [ ] + * + * SMTP CODE SUCCESS: 211,214 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string + */ + function Help($keyword="") { + $this->error = null; # to avoid confusion - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Help() without being connected"); + return false; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + $extra = ""; + if(!empty($keyword)) { + $extra = " " . $keyword; + } - if($code != 250) { - $this->error = - array("error" => "MAIL not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * Noop() - * - * Sends the command NOOP to the SMTP server. - * - * Implements from rfc 821: NOOP - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500, 421 - */ - function Noop() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Noop() without being connected"); - return false; - } + fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); - fputs($this->smtp_conn,"NOOP" . $this->CRLF); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + if($code != 211 && $code != 214) { + $this->error = + array("error" => "HELP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - if($code != 250) { - $this->error = - array("error" => "NOOP not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * Quit($close_on_error=true) - * - * 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 - * - * SMTP CODE SUCCESS: 221 - * SMTP CODE ERROR : 500 - */ - function Quit($close_on_error=true) { - $this->error = null; # so there is no confusion - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Quit() without being connected"); - return false; - } + return $rply; + } - # send the quit command to the server - fputs($this->smtp_conn,"quit" . $this->CRLF); + /** + * 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: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + function Mail($from) { + $this->error = null; # so no confusion is caused - # get any good-bye messages - $byemsg = $this->get_lines(); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; - } + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF); - $rval = true; - $e = null; + $rply = $this->get_lines(); + $code = substr($rply,0,3); - $code = substr($byemsg,0,3); - if($code != 221) { - # use e as a tmp var cause Close will overwrite $this->error - $e = array("error" => "SMTP server rejected quit command", - "smtp_code" => $code, - "smtp_rply" => substr($byemsg,4)); - $rval = false; - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $e["error"] . ": " . - $byemsg . $this->CRLF; - } - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - if(empty($e) || $close_on_error) { - $this->Close(); + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return true; + } - return $rval; - } - - /* - * Recipient($to) - * - * 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 TO: - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,552,553,450,451,452 - * SMTP CODE ERROR : 500,501,503,421 - */ - function Recipient($to) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Recipient() without being connected"); - return false; - } + /** + * Sends the command NOOP to the SMTP server. + * + * Implements from rfc 821: NOOP + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 421 + * @access public + * @return bool + */ + function Noop() { + $this->error = null; # so no confusion is caused - fputs($this->smtp_conn,"RCPT TO:" . $to . $this->CRLF); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Noop() without being connected"); + return false; + } - $rply = $this->get_lines(); - $code = substr($rply,0,3); + fputs($this->smtp_conn,"NOOP" . $this->CRLF); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($code != 250 && $code != 251) { - $this->error = - array("error" => "RCPT not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * Reset() - * - * Sends the RSET command to abort and transaction that is - * currently in progress. Returns true if successful false - * otherwise. - * - * Implements rfc 821: RSET - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE ERROR : 500,501,504,421 - */ - function Reset() { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Reset() without being connected"); - return false; + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "NOOP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return true; + } - fputs($this->smtp_conn,"RSET" . $this->CRLF); + /** + * 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 + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + function Quit($close_on_error=true) { + $this->error = null; # so there is no confusion - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + # send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); - if($code != 250) { - $this->error = - array("error" => "RSET failed", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } + # get any good-bye messages + $byemsg = $this->get_lines(); - return true; - } - - /* - * Send($from) - * - * 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 FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - */ - function Send($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Send() without being connected"); - return false; + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + # use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . + $byemsg . $this->CRLF; } + } - fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); + if(empty($e) || $close_on_error) { + $this->Close(); + } - $rply = $this->get_lines(); - $code = substr($rply,0,3); + return $rval; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + /** + * 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 TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + function Recipient($to) { + $this->error = null; # so no confusion is caused - if($code != 250) { - $this->error = - array("error" => "SEND not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * SendAndMail($from) - * - * 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: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - */ - function SendAndMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendAndMail() without being connected"); - return false; - } + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } - fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; - } + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - if($code != 250) { - $this->error = - array("error" => "SAML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; - } - return true; - } - - /* - * SendOrMail($from) - * - * 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 FROM: - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE SUCCESS: 552,451,452 - * SMTP CODE SUCCESS: 500,501,502,421 - */ - function SendOrMail($from) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called SendOrMail() without being connected"); - return false; + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + function Reset() { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } - fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); + fputs($this->smtp_conn,"RSET" . $this->CRLF); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } - if($code != 250) { - $this->error = - array("error" => "SOML not accepted from server", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; + return true; + } + + /** + * 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 FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function Send($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Send() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SEND not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } - return true; - } - - /* - * Turn() - * - * 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 - * - * SMTP CODE SUCCESS: 250 - * SMTP CODE FAILURE: 502 - * SMTP CODE ERROR : 500, 503 - */ - function Turn() { - $this->error = array("error" => "This method, TURN, of the SMTP ". - "is not implemented"); + return false; + } + return true; + } + + /** + * 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: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function SendAndMail($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); if($this->do_debug >= 1) { - echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } return false; } + return true; + } - /* - * Verify($name) - * - * 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 - * - * SMTP CODE SUCCESS: 250,251 - * SMTP CODE FAILURE: 550,551,553 - * SMTP CODE ERROR : 500,501,502,421 - */ - function Verify($name) { - $this->error = null; # so no confusion is caused - - if(!$this->connected()) { - $this->error = array( - "error" => "Called Verify() without being connected"); - return false; + /** + * 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 FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function SendOrMail($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendOrMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SOML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return true; + } + + /** + * 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 + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; + } + return false; + } + + /** + * 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 + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,553 + * SMTP CODE ERROR : 500,501,502,421 + * @access public + * @return int + */ + function Verify($name) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Verify() without being connected"); + return false; + } + + fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); - fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); + $rply = $this->get_lines(); + $code = substr($rply,0,3); - $rply = $this->get_lines(); - $code = substr($rply,0,3); + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } - if($this->do_debug >= 2) { - echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + if($code != 250 && $code != 251) { + $this->error = + array("error" => "VRFY failed on name '$name'", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; } + return false; + } + return $rply; + } - if($code != 250 && $code != 251) { - $this->error = - array("error" => "VRFY failed on name '$name'", - "smtp_code" => $code, - "smtp_msg" => substr($rply,4)); - if($this->do_debug >= 1) { - echo "SMTP -> ERROR: " . $this->error["error"] . - ": " . $rply . $this->CRLF; - } - return false; + /******************************************************************* + * INTERNAL FUNCTIONS * + ******************************************************************/ + + /** + * Read in as many lines as possible + * 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 private + * @return string + */ + function get_lines() { + $data = ""; + while($str = fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . + $this->CRLF; + echo "SMTP -> get_lines(): \$str is \"$str\"" . + $this->CRLF; } - return $rply; - } - - /****************************************************************** - * INTERNAL FUNCTIONS * - ******************************************************************/ - - /* - * get_lines() - * - * __internal_use_only__: read in as many lines as possible - * 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. - */ - function get_lines() { - $data = ""; - while($str = fgets($this->smtp_conn,515)) { - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data was \"$data\"" . - $this->CRLF; - echo "SMTP -> get_lines(): \$str is \"$str\"" . - $this->CRLF; - } - $data .= $str; - if($this->do_debug >= 4) { - echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; - } - # if the 4th character is a space then we are done reading - # so just break the loop - if(substr($str,3,1) == " ") { break; } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; } - return $data; + # if the 4th character is a space then we are done reading + # so just break the loop + if(substr($str,3,1) == " ") { break; } } - + return $data; } +} + ?> diff --git a/lib/phpmailer/docs/extending.html b/lib/phpmailer/docs/extending.html deleted file mode 100644 index 25002aafd6..0000000000 --- a/lib/phpmailer/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@mydomain.com";
-$mail->FromName = "List manager";
-$mail->Host     = "smtp1.site.com;smtp2.site.com";
-$mail->Mailer   = "smtp";
-
-@MYSQL_CONNECT("localhost","root","password");
-@mysql_select_db("my_company");
-$query  = "SELECT full_name, email, photo FROM employee WHERE id=$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@email.com";
-    var $FromName = "Mailer";
-    var $Host     = "smtp1.site.com;smtp2.site.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@site.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/lib/phpmailer/docs/faq.html b/lib/phpmailer/docs/faq.html deleted file mode 100644 index 18dfafda9c..0000000000 --- a/lib/phpmailer/docs/faq.html +++ /dev/null @@ -1,66 +0,0 @@ - - -phpmailer FAQ - - - - -

phpmailer FAQ

- -

-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? -
-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. -

- -

-I am concerned that using include files will take up too much -processing time on my computer. How can I make it run faster? -
-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. -

- - -

-What mailer gives me the best performance? -
-On a single machine the mail() or sendmail mailers give you the best -performance because they do not have the added 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. -

- -

-When I try to attach a file with on my server I get a -"Could not find {file} on filesystem error". Why is this? -
-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 ("/"). -

- - - \ No newline at end of file diff --git a/lib/phpmailer/docs/timeoutfix.diff b/lib/phpmailer/docs/timeoutfix.diff deleted file mode 100644 index 8821f001b3..0000000000 --- a/lib/phpmailer/docs/timeoutfix.diff +++ /dev/null @@ -1,23 +0,0 @@ -*** /usr/local/src/php-4.0.4pl1/ext/standard/fsock.c.old Mon Mar 26 13:07:40 2001 ---- /usr/local/src/php-4.0.4pl1/ext/standard/fsock.c Mon Mar 26 13:12:03 2001 -*************** -*** 559,564 **** ---- 559,565 ---- - - static void php_sockread_total(php_sockbuf *sock, size_t maxread) - { -+ sock->timeout_event = 0; - while(!sock->eof && TOREAD(sock) < maxread && !sock->timeout_event) { - php_sockread_internal(sock); - } -*************** -*** 619,624 **** ---- 620,627 ---- - } - - SEARCHCR(); -+ -+ sock->timeout_event = 0; - - if(!p) { - if(sock->is_blocked) { diff --git a/lib/phpmailer/language/phpmailer.lang-br.php b/lib/phpmailer/language/phpmailer.lang-br.php new file mode 100644 index 0000000000..b948c264f3 --- /dev/null +++ b/lib/phpmailer/language/phpmailer.lang-br.php @@ -0,0 +1,21 @@ + diff --git a/lib/phpmailer/language/phpmailer.lang-en.php b/lib/phpmailer/language/phpmailer.lang-en.php new file mode 100644 index 0000000000..c5a6da82c7 --- /dev/null +++ b/lib/phpmailer/language/phpmailer.lang-en.php @@ -0,0 +1,24 @@ + + diff --git a/lib/phpmailer/phpdoc/allclasses-frame.html b/lib/phpmailer/phpdoc/allclasses-frame.html deleted file mode 100644 index 75bd6e9863..0000000000 --- a/lib/phpmailer/phpdoc/allclasses-frame.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - -All Classes - - - - - -All Classes -
- - - - - -
phpmailer -
-
- - - diff --git a/lib/phpmailer/phpdoc/deprecated-list.html b/lib/phpmailer/phpdoc/deprecated-list.html deleted file mode 100644 index c3cede0f24..0000000000 --- a/lib/phpmailer/phpdoc/deprecated-list.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - -: Deprecated List - - - - - - - - - - - - - - - - - -
- -
- - -
-
-

-Deprecated API

-
-
- - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/help-doc.html b/lib/phpmailer/phpdoc/help-doc.html deleted file mode 100644 index 5529f786a8..0000000000 --- a/lib/phpmailer/phpdoc/help-doc.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - -: API Help - - - - - - - - - - - - - - - - - -
- -
- - -
-
-

-How This API Document Is Organized

-
-This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

-Package

-
- -

-Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

    -
  • Interfaces (italic)
  • Classes
  • Exceptions
  • Errors
-
-

-Class/Interface

-
- -

-Each class, interface, inner class and inner interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    -
  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description -

    -

  • Inner Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary -

    -

  • Field Detail
  • Constructor Detail
  • Method Detail
-Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
-

-Tree (Class Hierarchy)

-
-There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
    -
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
-
-

-Deprecated API

-
-The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
-

-Index

-
-The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
-

-Prev/Next

-These links take you to the next or previous class, interface, package, or related page.

-Frames/No Frames

-These links show and hide the HTML frames. All pages are available with or without frames. -

-

-Serialized Form

-Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. -

- - -This help file applies to API documentation generated using the standard doclet. - -
-


- - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/index-all.html b/lib/phpmailer/phpdoc/index-all.html deleted file mode 100644 index 5633608f8e..0000000000 --- a/lib/phpmailer/phpdoc/index-all.html +++ /dev/null @@ -1,293 +0,0 @@ - - - - - - -: Index - - - - - - - - - - - - - - - - - -
- -
- - -$ A B C G I P S
-

-$

-
-
$AltBody - -Variable in class phpmailer -
Sets the text-only body of the message. -
$Body - -Variable in class phpmailer -
Sets the Body of the message. -
$CharSet - -Variable in class phpmailer -
Sets the CharSet of the message. -
$CharSet - -Variable in class Boundary -
Sets the Char set. -
$ConfirmReadingTo - -Variable in class phpmailer -
Sets the email address that a reading confirmation will be sent. -
$ContentType - -Variable in class phpmailer -
Sets the Content-type of the message. -
$ContentType - -Variable in class Boundary -
Sets the boundary Content Type. -
$Disposition - -Variable in class Boundary -
Sets an attachment disposition. -
$Encoding - -Variable in class phpmailer -
Sets the Encoding of the message. -
$Encoding - -Variable in class Boundary -
Sets the Encoding. -
$ErrorInfo - -Variable in class phpmailer -
Holds the most recent mailer error message. -
$FileName - -Variable in class Boundary -
Sets an attachment file name. -
$From - -Variable in class phpmailer -
Sets the From email address for the message. -
$FromName - -Variable in class phpmailer -
Sets the From name of the message. -
$Helo - -Variable in class phpmailer -
Sets the SMTP HELO of the message. -
$Host - -Variable in class phpmailer -
Sets the SMTP hosts. -
$LE - -Variable in class phpmailer -
Sets the line endings of the message. -
$LE - -Variable in class Boundary -
Sets the line endings of the message. -
$Mailer - -Variable in class phpmailer -
Method to send mail: ("mail", "sendmail", or "smtp"). -
$Password - -Variable in class phpmailer -
Sets SMTP password. -
$PluginDir - -Variable in class phpmailer -
Path to phpmailer plugins. -
$Port - -Variable in class phpmailer -
Sets the default SMTP server port. -
$Priority - -Variable in class phpmailer -
Email priority (1 = High, 3 = Normal, 5 = low). -
$Sender - -Variable in class phpmailer -
Sets the Sender email of the message. -
$Sendmail - -Variable in class phpmailer -
Sets the path of the sendmail program. -
$SMTPAuth - -Variable in class phpmailer -
Sets SMTP authentication. -
$Subject - -Variable in class phpmailer -
Sets the Subject of the message. -
$UseMSMailHeaders - -Variable in class phpmailer -
Turns Microsoft mail client headers on and off. -
$Username - -Variable in class phpmailer -
Sets SMTP username. -
$Version - -Variable in class phpmailer -
Holds phpmailer version. -
$WordWrap - -Variable in class phpmailer -
Sets word wrapping on the body of the message to a given number of - characters. -
-
-

-A

-
-
AddAddress(var, var) - -Method in class phpmailer -
Adds a "To" address. -
AddAttachment(var, var, var, var) - -Method in class phpmailer -
Adds an attachment from a path on the filesystem. -
AddBCC(var, var) - -Method in class phpmailer -
Adds a "Bcc" address. -
AddCC(var, var) - -Method in class phpmailer -
Adds a "Cc" address. -
AddCustomHeader(var) - -Method in class phpmailer -
Adds a custom header. -
AddEmbeddedImage(var, var, var, var, var) - -Method in class phpmailer -
Adds an embedded attachment. -
AddReplyTo(var, var) - -Method in class phpmailer -
Adds a "Reply-to" address. -
AddStringAttachment(var, var, var, var) - -Method in class phpmailer -
Adds a string or binary attachment (non-filesystem) to the list. -
-
-

-B

-
-
Boundary - class Boundary.
Boundary - MIME message boundary class
Boundary(var) - -Constructor for class Boundary -
Main constructor. -
-
-

-C

-
-
ClearAddresses() - -Method in class phpmailer -
Clears all recipients assigned in the TO array. -
ClearAllRecipients() - -Method in class phpmailer -
Clears all recipients assigned in the TO, CC and BCC - array. -
ClearAttachments() - -Method in class phpmailer -
Clears all previously set filesystem, string, and binary - attachments. -
ClearBCCs() - -Method in class phpmailer -
Clears all recipients assigned in the BCC array. -
ClearCCs() - -Method in class phpmailer -
Clears all recipients assigned in the CC array. -
ClearCustomHeaders() - -Method in class phpmailer -
Clears all custom headers. -
ClearReplyTos() - -Method in class phpmailer -
Clears all recipients assigned in the ReplyTo array. -
-
-

-G

-
-
GetSource(var) - -Method in class Boundary -
Returns the source of the boundary. -
-
-

-I

-
-
IsHTML(var) - -Method in class phpmailer -
Sets message type to HTML. -
IsMail() - -Method in class phpmailer -
Sets Mailer to send message using PHP mail() function. -
IsQmail() - -Method in class phpmailer -
Sets Mailer to send message using the qmail MTA. -
IsSendmail() - -Method in class phpmailer -
Sets Mailer to send message using the $Sendmail program. -
IsSMTP() - -Method in class phpmailer -
Sets Mailer to send message using SMTP. -
-
-

-P

-
-
phpmailer - class phpmailer.
phpmailer - PHP email transport class
phpmailer() - -Constructor for class phpmailer -
  -
-
-

-S

-
-
Send() - -Method in class phpmailer -
Creates message and assigns Mailer. -
SendToQueue(var, var) - -Method in class phpmailer -
Sends mail message to an assigned queue directory. -
-
-$ A B C G I P S - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/index.html b/lib/phpmailer/phpdoc/index.html deleted file mode 100644 index 5d8db44aa5..0000000000 --- a/lib/phpmailer/phpdoc/index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -Generated Documentation (Untitled) - - - - - - - -<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. -<BR> -Link to <A HREF="phpmailer.html">Non-frame version.</A> - diff --git a/lib/phpmailer/phpdoc/overview-tree.html b/lib/phpmailer/phpdoc/overview-tree.html deleted file mode 100644 index 5ee7898d14..0000000000 --- a/lib/phpmailer/phpdoc/overview-tree.html +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - -: Class Hierarchy - - - - - - - - - - - - - - - - - -
- -
- - -
-
-

-Hierarchy For All Packages

-
-

-Class Hierarchy -

- -
- - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/packages.html b/lib/phpmailer/phpdoc/packages.html deleted file mode 100644 index b2e9a48d01..0000000000 --- a/lib/phpmailer/phpdoc/packages.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - -
- -
- -
-
-The front page has been relocated.Please see: -
-          Frame version -
-          Non-frame version.
- - - diff --git a/lib/phpmailer/phpdoc/phpmailer.html b/lib/phpmailer/phpdoc/phpmailer.html deleted file mode 100644 index ecf7e097ad..0000000000 --- a/lib/phpmailer/phpdoc/phpmailer.html +++ /dev/null @@ -1,1043 +0,0 @@ - - - - - - -: Class phpmailer - - - - - - - - - - - - - - - - - - - - - -
- -
- - -
- -

-Class phpmailer

-
-phpmailer
-
-
-
-
public class phpmailer
- -

-phpmailer - PHP email transport class -

-


- -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Field Summary
- string$AltBody - -
-          Sets the text-only body of the message.
- string$Body - -
-          Sets the Body of the message.
- string$CharSet - -
-          Sets the CharSet of the message.
- string$ConfirmReadingTo - -
-          Sets the email address that a reading confirmation will be sent.
- string$ContentType - -
-          Sets the Content-type of the message.
- string$Encoding - -
-          Sets the Encoding of the message.
- string$ErrorInfo - -
-          Holds the most recent mailer error message.
- string$From - -
-          Sets the From email address for the message.
- string$FromName - -
-          Sets the From name of the message.
- string$Helo - -
-          Sets the SMTP HELO of the message.
- string$Host - -
-          Sets the SMTP hosts.
- string$LE - -
-          Sets the line endings of the message.
- string$Mailer - -
-          Method to send mail: ("mail", "sendmail", or "smtp").
- string$Password - -
-          Sets SMTP password.
- string$PluginDir - -
-          Path to phpmailer plugins.
- int$Port - -
-          Sets the default SMTP server port.
- int$Priority - -
-          Email priority (1 = High, 3 = Normal, 5 = low).
- string$Sender - -
-          Sets the Sender email of the message.
- string$Sendmail - -
-          Sets the path of the sendmail program.
- bool$SMTPAuth - -
-          Sets SMTP authentication.
- string$Subject - -
-          Sets the Subject of the message.
- bool$UseMSMailHeaders - -
-          Turns Microsoft mail client headers on and off.
- string$Username - -
-          Sets SMTP username.
- string$Version - -
-          Holds phpmailer version.
- int$WordWrap - -
-          Sets word wrapping on the body of the message to a given number of - characters.
-  - - - - - - - - - - -
-Constructor Summary
phpmailer() - -
-           
-  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-Method Summary
- voidAddAddress(var $address, - var $name) - -
-          Adds a "To" address.
- boolAddAttachment(var $path, - var $name, - var $encoding, - var $type) - -
-          Adds an attachment from a path on the filesystem.
- voidAddBCC(var $address, - var $name) - -
-          Adds a "Bcc" address.
- voidAddCC(var $address, - var $name) - -
-          Adds a "Cc" address.
- voidAddCustomHeader(var $custom_header) - -
-          Adds a custom header.
- boolAddEmbeddedImage(var $path, - var $cid, - var $name, - var $encoding, - var $type) - -
-          Adds an embedded attachment.
- voidAddReplyTo(var $address, - var $name) - -
-          Adds a "Reply-to" address.
- voidAddStringAttachment(var $string, - var $filename, - var $encoding, - var $type) - -
-          Adds a string or binary attachment (non-filesystem) to the list.
- voidClearAddresses() - -
-          Clears all recipients assigned in the TO array.
- voidClearAllRecipients() - -
-          Clears all recipients assigned in the TO, CC and BCC - array.
- voidClearAttachments() - -
-          Clears all previously set filesystem, string, and binary - attachments.
- voidClearBCCs() - -
-          Clears all recipients assigned in the BCC array.
- voidClearCCs() - -
-          Clears all recipients assigned in the CC array.
- voidClearCustomHeaders() - -
-          Clears all custom headers.
- voidClearReplyTos() - -
-          Clears all recipients assigned in the ReplyTo array.
- voidIsHTML(var $bool) - -
-          Sets message type to HTML.
- voidIsMail() - -
-          Sets Mailer to send message using PHP mail() function.
- voidIsQmail() - -
-          Sets Mailer to send message using the qmail MTA.
- voidIsSendmail() - -
-          Sets Mailer to send message using the $Sendmail program.
- voidIsSMTP() - -
-          Sets Mailer to send message using SMTP.
- boolSend() - -
-          Creates message and assigns Mailer.
- stringSendToQueue(var $queue_path, - var $send_time) - -
-          Sends mail message to an assigned queue directory.
-  -

- - - - - - - - -
-Field Detail
- -

-$Priority

-
-public int $Priority
-
-
Email priority (1 = High, 3 = Normal, 5 = low). Default value is 3.
-
- -

-$CharSet

-
-public string $CharSet
-
-
Sets the CharSet of the message. Default value is "iso-8859-1".
-
- -

-$ContentType

-
-public string $ContentType
-
-
Sets the Content-type of the message. Default value is "text/plain".
-
- -

-$Encoding

-
-public string $Encoding
-
-
Sets the Encoding of the message. Options for this are "8bit" (default), - "7bit", "binary", "base64", and "quoted-printable".
-
- -

-$ErrorInfo

-
-public string $ErrorInfo
-
-
Holds the most recent mailer error message. Default value is "".
-
- -

-$From

-
-public string $From
-
-
Sets the From email address for the message. Default value is "root@localhost".
-
- -

-$FromName

-
-public string $FromName
-
-
Sets the From name of the message. Default value is "Root User".
-
- -

-$Sender

-
-public string $Sender
-
-
Sets the Sender email of the message. If not empty, will be sent via -f to sendmail - or as 'MAIL FROM' in smtp mode. Default value is "".
-
- -

-$Subject

-
-public string $Subject
-
-
Sets the Subject of the message. Default value is "".
-
- -

-$Body

-
-public string $Body
-
-
Sets the Body of the message. This can be either an HTML or text body. - If HTML then run IsHTML(true). Default value is "".
-
- -

-$AltBody

-
-public string $AltBody
-
-
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. - Default value is "".
-
- -

-$WordWrap

-
-public int $WordWrap
-
-
Sets word wrapping on the body of the message to a given number of - characters. Default value is 0 (off).
-
- -

-$Mailer

-
-public string $Mailer
-
-
Method to send mail: ("mail", "sendmail", or "smtp"). - Default value is "mail".
-
- -

-$Sendmail

-
-public string $Sendmail
-
-
Sets the path of the sendmail program. Default value is - "/usr/sbin/sendmail".
-
- -

-$UseMSMailHeaders

-
-public bool $UseMSMailHeaders
-
-
Turns Microsoft mail client headers on and off. Useful mostly - for older clients. Default value is false (off).
-
- -

-$PluginDir

-
-public string $PluginDir
-
-
Path to phpmailer plugins. This is now only useful if the SMTP class - is in a different directory than the PHP include path. - Default is empty ("").
-
- -

-$Version

-
-public string $Version
-
-
Holds phpmailer version.
-
- -

-$ConfirmReadingTo

-
-public string $ConfirmReadingTo
-
-
Sets the email address that a reading confirmation will be sent. Default value is "".
-
- -

-$LE

-
-public string $LE
-
-
Sets the line endings of the message. Default is "\n";
-
- -

-$Host

-
-public string $Host
-
-
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.domain.com:25;smtp2.domain.com"). - Hosts will be tried in order. - Default value is "localhost".
-
- -

-$Port

-
-public int $Port
-
-
Sets the default SMTP server port. Default value is 25.
-
- -

-$Helo

-
-public string $Helo
-
-
Sets the SMTP HELO of the message. - Default value is "localhost.localdomain".
-
- -

-$SMTPAuth

-
-public bool $SMTPAuth
-
-
Sets SMTP authentication. Utilizes the Username and Password variables. - Default value is false (off).
-
- -

-$Username

-
-public string $Username
-
-
Sets SMTP username. Default value is "".
-
- -

-$Password

-
-public string $Password
-
-
Sets SMTP password. Default value is "".
- - - - - - - - -
-Constructor Detail
- -

-phpmailer

-
-public phpmailer()
-
-
- - - - - - - - -
-Method Detail
- -

-IsHTML

-
-public void IsHTML(var $bool)
-
-
Sets message type to HTML. Returns void.
-
- -

-IsSMTP

-
-public void IsSMTP()
-
-
Sets Mailer to send message using SMTP. - Returns void.
-
- -

-IsMail

-
-public void IsMail()
-
-
Sets Mailer to send message using PHP mail() function. - Returns void.
-
- -

-IsSendmail

-
-public void IsSendmail()
-
-
Sets Mailer to send message using the $Sendmail program. - Returns void.
-
- -

-IsQmail

-
-public void IsQmail()
-
-
Sets Mailer to send message using the qmail MTA. Returns void.
-
- -

-AddAddress

-
-public void AddAddress(var $address,
-                       var $name)
-
-
Adds a "To" address. Returns void.
-
Parameters:
$name - Default Value: ""
-
-
-
- -

-AddCC

-
-public void AddCC(var $address,
-                  var $name)
-
-
Adds a "Cc" address. Note: this function works - with the SMTP mailer on win32, not with the "mail" - mailer. This is a PHP bug that has been submitted - on http: * functions correctly. Returns void.
-
Parameters:
$name - Default Value: ""
-
-
-
- -

-AddBCC

-
-public void AddBCC(var $address,
-                   var $name)
-
-
Adds a "Bcc" address. Note: this function works - with the SMTP mailer on win32, not with the "mail" - mailer. This is a PHP bug that has been submitted - on http: * functions correctly. - Returns void.
-
Parameters:
$name - Default Value: ""
-
-
-
- -

-AddReplyTo

-
-public void AddReplyTo(var $address,
-                       var $name)
-
-
Adds a "Reply-to" address. Returns void.
-
Parameters:
$name - Default Value: ""
-
-
-
- -

-Send

-
-public bool Send()
-
-
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. Returns bool.
-
- -

-SendToQueue

-
-public string SendToQueue(var $queue_path,
-                          var $send_time)
-
-
Sends mail message to an assigned queue directory. Has an optional - sendTime argument. This is used when the user wants the - message to be sent from the queue at a predetermined time. - The data must be a valid timestamp like that returned from - the time() or strtotime() functions. Returns false on failure - or the message file name if success.
-
Parameters:
$send_time - Default Value: 0
-
-
-
- -

-AddAttachment

-
-public bool AddAttachment(var $path,
-                          var $name,
-                          var $encoding,
-                          var $type)
-
-
Adds an attachment from a path on the filesystem. - Checks if attachment is valid and then adds - the attachment to the list. - Returns false if the file could not be found - or accessed.
-
Parameters:
$name - Default Value: ""
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
-
-
-
- -

-AddStringAttachment

-
-public void AddStringAttachment(var $string,
-                                var $filename,
-                                var $encoding,
-                                var $type)
-
-
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.
-
Parameters:
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
-
-
-
- -

-AddEmbeddedImage

-
-public bool AddEmbeddedImage(var $path,
-                             var $cid,
-                             var $name,
-                             var $encoding,
-                             var $type)
-
-
Adds an embedded attachment. This can include images, sounds, and - just about any other document.
-
Parameters:
cid - this is the Content Id of the attachment. Use this to identify - the Id for accessing the image in an HTML form.
$name - Default Value: ""
$encoding - Default Value: "base64"
$type - Default Value: "application/octet-stream"
-
-
-
- -

-ClearAddresses

-
-public void ClearAddresses()
-
-
Clears all recipients assigned in the TO array. Returns void.
-
- -

-ClearCCs

-
-public void ClearCCs()
-
-
Clears all recipients assigned in the CC array. Returns void.
-
- -

-ClearBCCs

-
-public void ClearBCCs()
-
-
Clears all recipients assigned in the BCC array. Returns void.
-
- -

-ClearReplyTos

-
-public void ClearReplyTos()
-
-
Clears all recipients assigned in the ReplyTo array. Returns void.
-
- -

-ClearAllRecipients

-
-public void ClearAllRecipients()
-
-
Clears all recipients assigned in the TO, CC and BCC - array. Returns void.
-
- -

-ClearAttachments

-
-public void ClearAttachments()
-
-
Clears all previously set filesystem, string, and binary - attachments. Returns void.
-
- -

-ClearCustomHeaders

-
-public void ClearCustomHeaders()
-
-
Clears all custom headers. Returns void.
-
- -

-AddCustomHeader

-
-public void AddCustomHeader(var $custom_header)
-
-
Adds a custom header. Returns void.
- -
- - - - - - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/serialized-form.html b/lib/phpmailer/phpdoc/serialized-form.html deleted file mode 100644 index b8b5b648d9..0000000000 --- a/lib/phpmailer/phpdoc/serialized-form.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - -Serialized Form - - - - - - - - - - - - - - - - - -
- -
- - -
-
-

-Serialized Form

-
-
- - - - - - - - - - - - - -
- -
- - -
- - - diff --git a/lib/phpmailer/phpdoc/stylesheet.css b/lib/phpmailer/phpdoc/stylesheet.css deleted file mode 100644 index 07dc9eaf38..0000000000 --- a/lib/phpmailer/phpdoc/stylesheet.css +++ /dev/null @@ -1,29 +0,0 @@ -/* Javadoc style sheet */ - -/* Define colors, fonts and other style attributes here to override the defaults */ - -/* Page background color */ -body { background-color: #FFFFFF } - -/* Table colors */ -.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ -.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ -.TableRowColor { background: #FFFFFF } /* White */ - -/* Font used in left-hand frame lists */ -.FrameTitleFont { font-size: normal; font-family: normal } -.FrameHeadingFont { font-size: normal; font-family: normal } -.FrameItemFont { font-size: normal; font-family: normal } - -/* Example of smaller, sans-serif font in frames */ -/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ - -/* Navigation bar fonts and colors */ -.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ -.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ -.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} -.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} - -.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} -.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} - diff --git a/lib/phpmailer/test/phpmailer_test.php b/lib/phpmailer/test/phpmailer_test.php deleted file mode 100644 index 545740cffb..0000000000 --- a/lib/phpmailer/test/phpmailer_test.php +++ /dev/null @@ -1,546 +0,0 @@ -TestCase( $name ); - } - - /** - * Run before each test is started. - */ - function setUp() { - global $global_vars; - global $INCLUDE_DIR; - - $this->Mail = new phpmailer(); - - $this->Mail->Priority = 3; - $this->Mail->Encoding = "8bit"; - $this->Mail->CharSet = "iso-8859-1"; - $this->Mail->From = "unit_test@phpmailer.sf.net"; - $this->Mail->FromName = "Unit Tester"; - $this->Mail->Sender = ""; - $this->Mail->Subject = "Unit Test"; - $this->Mail->Body = ""; - $this->Mail->AltBody = ""; - $this->Mail->WordWrap = 0; - $this->Mail->Host = $global_vars["mail_host"]; - $this->Mail->Port = 25; - $this->Mail->Helo = "localhost.localdomain"; - $this->Mail->SMTPAuth = false; - $this->Mail->Username = ""; - $this->Mail->Password = ""; - $this->Mail->PluginDir = $INCLUDE_DIR; - $this->Mail->AddReplyTo("no_reply@phpmailer.sf.net", "Reply Guy"); - - if(strlen($this->Mail->Host) > 0) - $this->Mail->Mailer = "smtp"; - else - { - $this->Mail->Mailer = "mail"; - $this->Sender = "unit_test@phpmailer.sf.net"; - } - - global $global_vars; - $this->SetAddress($global_vars["mail_to"]); - - // This is where you might place additional To, Bcc, etc addresses - } - - /** - * Run after each test is completed. - */ - function tearDown() { - // Clean global variables - $this->Mail = false; - $this->ChangeLog = array(); - $this->NoteLog = array(); - } - - - /** - * Build the body of the message in the appropriate format. - * @private - * @returns void - */ - function BuildBody() { - $this->CheckChanges(); - - // Determine line endings for message - if($this->Mail->ContentType == "text/html" || strlen($this->Mail->AltBody) > 0) - { - $eol = "
"; - $bullet = "
  • "; - $bullet_start = "
      "; - $bullet_end = "
    "; - } - else - { - $eol = "\n"; - $bullet = " - "; - $bullet_start = ""; - $bullet_end = ""; - } - - $ReportBody = ""; - - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "Unit Test Information" . $eol; - $ReportBody .= "---------------------" . $eol; - $ReportBody .= "phpmailer version: " . $this->Mail->Version . $eol; - $ReportBody .= "Content Type: " . $this->Mail->ContentType . $eol; - - if(strlen($this->Mail->Host) > 0) - $ReportBody .= "Host: " . $this->Mail->Host . $eol; - - // If attachments then create an attachment list - if(count($this->Mail->attachment) > 0) - { - $ReportBody .= "Attachments"; - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->Mail->attachment); $i++) - { - $ReportBody .= $bullet . "Name: " . $this->Mail->attachment[$i][1] . ", "; - $ReportBody .= "Encoding: " . $this->Mail->attachment[$i][3] . ", "; - $ReportBody .= "Type: " . $this->Mail->attachment[$i][4] . $eol; - } - $ReportBody .= $bullet_end . $eol; - } - - // If there are changes then list them - if(count($this->ChangeLog) > 0) - { - $ReportBody .= "Changes" . $eol; - $ReportBody .= "-------" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->ChangeLog); $i++) - { - $ReportBody .= $bullet . $this->ChangeLog[$i][0] . " was changed to [" . - $this->ChangeLog[$i][1] . "]" . $eol; - } - $ReportBody .= $bullet_end . $eol . $eol; - } - - // If there are notes then list them - if(count($this->NoteLog) > 0) - { - $ReportBody .= "Notes" . $eol; - $ReportBody .= "-----" . $eol; - - $ReportBody .= $bullet_start; - for($i = 0; $i < count($this->NoteLog); $i++) - { - $ReportBody .= $bullet . $this->NoteLog[$i] . $eol; - } - $ReportBody .= $bullet_end; - } - - // Re-attach the original body - $this->Mail->Body .= $eol . $eol . $ReportBody; - } - - /** - * Check which default settings have been changed for the report. - * @private - * @returns void - */ - function CheckChanges() { - if($this->Mail->Priority != 3) - $this->AddChange("Priority", $this->Mail->Priority); - if($this->Mail->Encoding != "8bit") - $this->AddChange("Encoding", $this->Mail->Encoding); - if($this->Mail->CharSet != "iso-8859-1") - $this->AddChange("CharSet", $this->Mail->CharSet); - if($this->Mail->Sender != "") - $this->AddChange("Sender", $this->Mail->Sender); - if($this->Mail->WordWrap != 0) - $this->AddChange("WordWrap", $this->Mail->WordWrap); - if($this->Mail->Mailer != "mail") - $this->AddChange("Mailer", $this->Mail->Mailer); - if($this->Mail->Port != 25) - $this->AddChange("Port", $this->Mail->Port); - if($this->Mail->Helo != "localhost.localdomain") - $this->AddChange("Helo", $this->Mail->Helo); - if($this->Mail->SMTPAuth) - $this->AddChange("SMTPAuth", "true"); - } - - /** - * Adds a change entry. - * @private - * @returns void - */ - function AddChange($sName, $sNewValue) { - $cur = count($this->ChangeLog); - $this->ChangeLog[$cur][0] = $sName; - $this->ChangeLog[$cur][1] = $sNewValue; - } - - /** - * Adds a simple note to the message. - * @public - * @returns void - */ - function AddNote($sValue) { - $this->NoteLog[] = $sValue; - } - - /** - * Adds all of the addresses - * @public - * @returns void - */ - function SetAddress($sAddress, $sName = "", $sType = "to") { - switch($sType) - { - case "to": - $this->Mail->AddAddress($sAddress, $sName); - break; - case "cc": - $this->Mail->AddCC($sAddress, $sName); - break; - case "bcc": - $this->Mail->AddBCC($sAddress, $sName); - break; - } - } - - ///////////////////////////////////////////////// - // UNIT TESTS - ///////////////////////////////////////////////// - - /** - * Try a plain message. - */ - function test_WordWrap() { - - $this->Mail->WordWrap = 40; - $my_body = "Here is the main body of this message. It should " . - "be quite a few lines. It should be wrapped at the " . - "40 characters. Make sure that it is."; - $nBodyLen = strlen($my_body); - $my_body .= "\n\nThis is the above body length: " . $nBodyLen; - - $this->Mail->Body = $my_body; - $this->Mail->Subject .= ": Wordwrap"; - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Try a plain message. - */ - function test_Low_Priority() { - - $this->Mail->Priority = 5; - $this->Mail->Body = "Here is the main body. There should be " . - "a reply to address in this message."; - $this->Mail->Subject .= ": Low Priority"; - $this->Mail->AddReplyTo("nobody@nobody.com", "Nobody (Unit Test)"); - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Simple plain file attachment test. - */ - function test_Plain_FileAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain and FileAttachment"; - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Simple plain string attachment test. - */ - function test_Plain_StringAttachment() { - - $this->Mail->Body = "Here is the text body"; - $this->Mail->Subject .= ": Plain and StringAttachment"; - - $sAttachment = "These characters are the content of the " . - "string attachment.\nThis might be taken from a ". - "database or some other such thing. "; - - $this->Mail->AddStringAttachment($sAttachment, "string_attach.txt"); - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Plain quoted-printable message. - */ - function test_Quoted_Printable() { - - $this->Mail->Body = "Here is the main body"; - $this->Mail->Subject .= ": Plain and Quoted-printable"; - $this->Mail->Encoding = "quoted-printable"; - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Try a plain message. - */ - function test_Html() { - - $this->Mail->IsHTML(true); - $this->Mail->Subject .= ": HTML only"; - - $this->Mail->Body = "This is a test message written in HTML.
    " . - "Go to " . - "http://phpmailer.sourceforge.net/ for new versions of " . - "phpmailer.

    Thank you!"; - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Simple HTML and attachment test - */ - function test_HTML_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->Subject .= ": HTML and Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * An embedded attachment test. - */ - function test_Embedded_Image() { - - $this->Mail->Body = "Embedded Image: \"phpmailer\"" . - "Here is an image!"; - $this->Mail->Subject .= ": Embedded Image"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - if($this->Mail->EmbeddedImageCount() < 0) - { - $this->assert(false, "Embedded image count below 1"); - return; - } - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Simple multipart/alternative test. - */ - function test_AltBody() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "This is the text part of the email."; - $this->AddNote("This is a mulipart alternative email"); - $this->Mail->Subject .= ": AltBody"; - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - - /** - * Simple HTML and attachment test - */ - function test_AltBody_Attachment() { - - $this->Mail->Body = "This is the HTML part of the email."; - $this->Mail->AltBody = "This is the text part of the email."; - $this->Mail->Subject .= ": AltBody and Attachment"; - $this->Mail->IsHTML(true); - - if(!$this->Mail->AddAttachment("phpmailer_test.php", "test_attach.txt")) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->BuildBody(); - if(!$this->Mail->Send()) - { - $this->assert(false, $this->Mail->ErrorInfo); - return; - } - - $this->assert(true); - } - -} - -/** - * Create and run test instance. - */ - -if(isset($HTTP_GET_VARS)) - $global_vars = $HTTP_GET_VARS; -else - $global_vars = $_REQUEST; - -if(isset($global_vars["submitted"])) -{ - echo "Test results:
    "; - $suite = new TestSuite( "phpmailerTest" ); - - $testRunner = new TestRunner; - $testRunner->run($suite); - echo "


    "; -} - -function get($sName) { - global $global_vars; - if(isset($global_vars[$sName])) - return $global_vars[$sName]; - else - return ""; -} - -?> - - - -

    phpmailer Unit Test

    -By entering a SMTP hostname it will automatically perform tests with SMTP. - -
    - -To Address: "/> -
    -Bcc Address: "/> -
    -SMTP Hostname: "/> -

    - - -

    - - diff --git a/lib/phpmailer/test/phpunit.php b/lib/phpmailer/test/phpunit.php deleted file mode 100644 index 1ce4cb9ed5..0000000000 --- a/lib/phpmailer/test/phpunit.php +++ /dev/null @@ -1,376 +0,0 @@ - -// OntoSys, Inc -// -// $Id$ - -// Copyright (c) 2000 Fred Yankowski - -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, copy, -// modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS -// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE | - E_CORE_ERROR | E_CORE_WARNING); - -/* -interface Test { - function run(&$aTestResult); - function countTestCases(); -} -*/ - -function trace($msg) { - return; - print($msg); - flush(); -} - - -class Exception { - /* Emulate a Java exception, sort of... */ - var $message; - function Exception($message) { - $this->message = $message; - } - function getMessage() { - return $this->message; - } -} - -class Assert { - function assert($boolean, $message=0) { - if (! $boolean) - $this->fail($message); - } - - function assertEquals($expected, $actual, $message=0) { - if ($expected != $actual) { - $this->failNotEquals($expected, $actual, "expected", $message); - } - } - - function assertRegexp($regexp, $actual, $message=false) { - if (! preg_match($regexp, $actual)) { - $this->failNotEquals($regexp, $actual, "pattern", $message); - } - } - - function failNotEquals($expected, $actual, $expected_label, $message=0) { - // Private function for reporting failure to match. - $str = $message ? ($message . ' ') : ''; - $str .= "($expected_label/actual)
    "; - $htmlExpected = htmlspecialchars($expected); - $htmlActual = htmlspecialchars($actual); - $str .= sprintf("
    %s\n--------\n%s
    ", - $htmlExpected, $htmlActual); - $this->fail($str); - } -} - -class TestCase extends Assert /* implements Test */ { - /* Defines context for running tests. Specific context -- such as - instance variables, global variables, global state -- is defined - by creating a subclass that specializes the setUp() and - tearDown() methods. A specific test is defined by a subclass - that specializes the runTest() method. */ - var $fName; - var $fResult; - var $fExceptions = array(); - - function TestCase($name) { - $this->fName = $name; - } - - function run($testResult=0) { - /* Run this single test, by calling the run() method of the - TestResult object which will in turn call the runBare() method - of this object. That complication allows the TestResult object - to do various kinds of progress reporting as it invokes each - test. Create/obtain a TestResult object if none was passed in. - Note that if a TestResult object was passed in, it must be by - reference. */ - if (! $testResult) - $testResult = $this->_createResult(); - $this->fResult = $testResult; - $testResult->run(&$this); - $this->fResult = 0; - return $testResult; - } - - function countTestCases() { - return 1; - } - - function runTest() { - $name = $this->name(); - // Since isset($this->$name) is false, no way to run defensive checks - $this->$name(); - } - - function setUp() /* expect override */ { - //print("TestCase::setUp()
    \n"); - } - - function tearDown() /* possible override */ { - //print("TestCase::tearDown()
    \n"); - } - - //////////////////////////////////////////////////////////////// - - - function _createResult() /* protected */ { - /* override this to use specialized subclass of TestResult */ - return new TestResult; - } - - function fail($message=0) { - //printf("TestCase::fail(%s)
    \n", ($message) ? $message : ''); - /* JUnit throws AssertionFailedError here. We just record the - failure and carry on */ - $this->fExceptions[] = new Exception(&$message); - } - - function error($message) { - /* report error that requires correction in the test script - itself, or (heaven forbid) in this testing infrastructure */ - printf('ERROR: ' . $message . '
    '); - $this->fResult->stop(); - } - - function failed() { - return count($this->fExceptions); - } - - function getExceptions() { - return $this->fExceptions; - } - - function name() { - return $this->fName; - } - - function runBare() { - $this->setup(); - $this->runTest(); - $this->tearDown(); - } -} - - -class TestSuite /* implements Test */ { - /* Compose a set of Tests (instances of TestCase or TestSuite), and - run them all. */ - var $fTests = array(); - - function TestSuite($classname=false) { - if ($classname) { - // Find all methods of the given class whose name starts with - // "test" and add them to the test suite. We are just _barely_ - // able to do this with PHP's limited introspection... Note - // that PHP seems to store method names in lower case, and we - // have to avoid the constructor function for the TestCase class - // superclass. This will fail when $classname starts with - // "Test" since that will have a constructor method that will - // get matched below and then treated (incorrectly) as a test - // method. So don't name any TestCase subclasses as "Test..."! - if (floor(phpversion()) >= 4) { - // PHP4 introspection, submitted by Dylan Kuhn - $names = get_class_methods($classname); - while (list($key, $method) = each($names)) { - if (preg_match('/^test/', $method) && $method != "testcase") { - $this->addTest(new $classname($method)); - } - } - } - else { - $dummy = new $classname("dummy"); - $names = (array) $dummy; - while (list($key, $value) = each($names)) { - $type = gettype($value); - if ($type == "user function" && preg_match('/^test/', $key) - && $key != "testcase") { - $this->addTest(new $classname($key)); - } - } - } - } - } - - function addTest($test) { - /* Add TestCase or TestSuite to this TestSuite */ - $this->fTests[] = $test; - } - - function run(&$testResult) { - /* Run all TestCases and TestSuites comprising this TestSuite, - accumulating results in the given TestResult object. */ - reset($this->fTests); - while (list($na, $test) = each($this->fTests)) { - if ($testResult->shouldStop()) - break; - $test->run(&$testResult); - } - } - - function countTestCases() { - /* Number of TestCases comprising this TestSuite (including those - in any constituent TestSuites) */ - $count = 0; - reset($fTests); - while (list($na, $test_case) = each($this->fTests)) { - $count += $test_case->countTestCases(); - } - return $count; - } -} - - -class TestFailure { - /* Record failure of a single TestCase, associating it with the - exception(s) that occurred */ - var $fFailedTestName; - var $fExceptions; - - function TestFailure(&$test, &$exceptions) { - $this->fFailedTestName = $test->name(); - $this->fExceptions = $exceptions; - } - - function getExceptions() { - return $this->fExceptions; - } - function getTestName() { - return $this->fFailedTestName; - } -} - - -class TestResult { - /* Collect the results of running a set of TestCases. */ - var $fFailures = array(); - var $fRunTests = 0; - var $fStop = false; - - function TestResult() { } - - function _endTest($test) /* protected */ { - /* specialize this for end-of-test action, such as progress - reports */ - } - - function getFailures() { - return $this->fFailures; - } - - function run($test) { - /* Run a single TestCase in the context of this TestResult */ - $this->_startTest($test); - $this->fRunTests++; - - $test->runBare(); - - /* this is where JUnit would catch AssertionFailedError */ - $exceptions = $test->getExceptions(); - if ($exceptions) - $this->fFailures[] = new TestFailure(&$test, &$exceptions); - $this->_endTest($test); - } - - function countTests() { - return $this->fRunTests; - } - - function shouldStop() { - return $this->fStop; - } - - function _startTest($test) /* protected */ { - /* specialize this for start-of-test actions */ - } - - function stop() { - /* set indication that the test sequence should halt */ - $fStop = true; - } - - function countFailures() { - return count($this->fFailures); - } -} - - -class TextTestResult extends TestResult { - /* Specialize TestResult to produce text/html report */ - function TextTestResult() { - $this->TestResult(); // call superclass constructor - } - - function report() { - /* report result of test run */ - $nRun = $this->countTests(); - $nFailures = $this->countFailures(); - printf("

    %s test%s run
    ", $nRun, ($nRun == 1) ? '' : 's'); - printf("%s failure%s.
    \n", $nFailures, ($nFailures == 1) ? '' : 's'); - if ($nFailures == 0) - return; - - print("

      \n"); - $failures = $this->getFailures(); - while (list($i, $failure) = each($failures)) { - $failedTestName = $failure->getTestName(); - printf("
    1. %s\n", $failedTestName); - - $exceptions = $failure->getExceptions(); - print("
        "); - while (list($na, $exception) = each($exceptions)) - printf("
      • %s\n", $exception->getMessage()); - print("
      "); - } - print("
    \n"); - } - - function _startTest($test) { - printf("%s ", $test->name()); - flush(); - } - - function _endTest($test) { - $outcome = $test->failed() - ? "FAIL" - : "ok"; - printf("$outcome
    \n"); - flush(); - } -} - - -class TestRunner { - /* Run a suite of tests and report results. */ - function run($suite) { - $result = new TextTestResult; - $suite->run($result); - $result->report(); - } -} - -?> diff --git a/lib/phpmailer/test/rocks.png b/lib/phpmailer/test/rocks.png deleted file mode 100644 index 02de5a7aa3507dcec1e4349520ba3e8d8f7da4d6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1280 zcmeAS@N?(olHy`uVBq!ia0vp^tw5~K!2~4N<;e5_DVB6cUq=Rpjs4tz5?O(Kwj^(N z7lt)J7K6`}lP`c2XMsm#F#`j)5C}6~x?A@LD9B#o>FdgViCLDPN5AUi^*W$IwVp1H zAr*7p&f1@M+e+k^|GQka$^gd77pzXAva3|tw#@qU#D{GY+ZFCDwG1cEE579X#FX@$ z>FgwH&r=2B{84unZkVCiZ2N-g>I8;;hdm>XmCd=c^yvZlCI_MawKnqnCmAdw)?ZJ! z(AIo@e{`ec)BgLq2R?8-ZjY0&|8nTZLh)n#dkyMdw0?Bf?~$)c{BwaDo7B9IhZmN_ zh%E0uYH;3Pyt^=vfg$lt&fag6k0_-)7M*|G)$q*c&0lYID|HLld!D2e%F$=%SRuTY%I{2>Z{`vAZ>PV)}|}nN;w+U!QCIM z%dF3Q&h>n}=zwNb};ib(x>mdBz9tFM3#&2Z?-_RqK4ZYm+e055CrlA)a-UVpFR%v^PFVTssrYu_S`qZP4zZaccRhpt_9sylhjwpf+< z?Unnqytf|Oq_caOTOat-{V}jySM+ZLcry9!jFnfUInkZcQYhKM%L?N z&;!?rRVNa)m=6Fgxg2tDuEA9ET|#r_i?D{h*tzce28%w4!-tRgPZEBrw|%nx;k`%s zmfAYKyY+2b?$bqXn&r8-ISa3Ed-Xbga%WV_rQePT^77kD|K`Wu-}?6KQP#RWxwn}c zwyiVVWYOa4alSPF_O^E6V7L1351I46v}`n=eDeF}VulLinF~}7&9IfYQ}efLn#`@T z=<5}~4|Vgtn(q9aBQi8J`g;4eTzYtu=Z+lD zh7)#nVsqqgZL{jmKBw#CAyMYrd^hQ7_PL8!4qsoNfBW0BM@jw%&i;>o+4}Q$48E+4 clFJ|2pD+7py#+`y85}Sb4q9e08zkVlmGw# -- 2.39.5