<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23522] trunk/wp-includes: Update to PHPMailer 5.2.4.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23522">23522</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2013-02-28 18:33:13 +0000 (Thu, 28 Feb 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update to PHPMailer 5.2.4. props bpetty. fixes <a href="http://core.trac.wordpress.org/ticket/21074">#21074</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclassphpmailerphp">trunk/wp-includes/class-phpmailer.php</a></li>
<li><a href="#trunkwpincludesclasssmtpphp">trunk/wp-includes/class-smtp.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclassphpmailerphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-phpmailer.php (23521 => 23522)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-phpmailer.php        2013-02-28 18:27:13 UTC (rev 23521)
+++ trunk/wp-includes/class-phpmailer.php        2013-02-28 18:33:13 UTC (rev 23522)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /*~ class.phpmailer.php
</span><span class="cx"> .---------------------------------------------------------------------------.
</span><span class="cx"> | Software: PHPMailer - PHP email class |
</span><del>-| Version: 5.2.1 |
</del><ins>+| Version: 5.2.4 |
</ins><span class="cx"> | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ |
</span><span class="cx"> | ------------------------------------------------------------------------- |
</span><span class="cx"> | Admin: Jim Jagielski (project admininistrator) |
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * PHPMailer - PHP email transport class
</del><ins>+ * PHPMailer - PHP email creation and transport class
</ins><span class="cx"> * NOTE: Requires PHP version 5 or later
</span><span class="cx"> * @package PHPMailer
</span><span class="cx"> * @author Andy Prevost
</span><span class="lines">@@ -31,12 +31,15 @@
</span><span class="cx"> * @author Jim Jagielski
</span><span class="cx"> * @copyright 2010 - 2012 Jim Jagielski
</span><span class="cx"> * @copyright 2004 - 2009 Andy Prevost
</span><del>- * @version $Id: class.phpmailer.php 450 2010-06-23 16:46:33Z coolbru $
</del><span class="cx"> * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> if (version_compare(PHP_VERSION, '5.0.0', '<') ) exit("Sorry, this version of PHPMailer will only run on PHP version 5 or greater!\n");
</span><span class="cx">
</span><ins>+/**
+ * PHP email creation and transport class
+ * @package PHPMailer
+ */
</ins><span class="cx"> class PHPMailer {
</span><span class="cx">
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="lines">@@ -94,6 +97,13 @@
</span><span class="cx"> public $Sender = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Sets the Return-Path of the message. If empty, it will
+ * be set to either From or Sender.
+ * @var string
+ */
+ public $ReturnPath = '';
+
+ /**
</ins><span class="cx"> * Sets the Subject of the message.
</span><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="lines">@@ -130,11 +140,11 @@
</span><span class="cx"> protected $MIMEHeader = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Stores the complete sent MIME message (Body and Headers)
</del><ins>+ * Stores the extra header list which CreateHeader() doesn't fold in
</ins><span class="cx"> * @var string
</span><span class="cx"> * @access protected
</span><span class="cx"> */
</span><del>- protected $SentMIMEMessage = '';
</del><ins>+ protected $mailHeader = '';
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Sets word wrapping on the body of the message to a given number of
</span><span class="lines">@@ -156,6 +166,13 @@
</span><span class="cx"> public $Sendmail = '/usr/sbin/sendmail';
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Determine if mail() uses a fully sendmail compatible MTA that
+ * supports sendmail's "-oi -f" options
+ * @var boolean
+ */
+ public $UseSendmailOptions        = true;
+
+ /**
</ins><span class="cx"> * Path to PHPMailer plugins. Useful if the SMTP class
</span><span class="cx"> * is in a different directory than the PHP include path.
</span><span class="cx"> * @var string
</span><span class="lines">@@ -183,12 +200,21 @@
</span><span class="cx"> */
</span><span class="cx"> public $MessageID = '';
</span><span class="cx">
</span><ins>+ /**
+ * Sets the message Date to be used in the Date header.
+ * If empty, the current date will be added.
+ * @var string
+ */
+ public $MessageDate = '';
+
</ins><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx"> // PROPERTIES FOR SMTP
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Sets the SMTP hosts. All hosts must be separated by a
</del><ins>+ * Sets the SMTP hosts.
+ *
+ * All hosts must be separated by a
</ins><span class="cx"> * semicolon. You can also specify a different port
</span><span class="cx"> * for each host by using this format: [hostname:port]
</span><span class="cx"> * (e.g. "smtp1.example.com:25;smtp2.example.com").
</span><span class="lines">@@ -210,8 +236,7 @@
</span><span class="cx"> public $Helo = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Sets connection prefix.
- * Options are "", "ssl" or "tls"
</del><ins>+ * Sets connection prefix. Options are "", "ssl" or "tls"
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $SMTPSecure = '';
</span><span class="lines">@@ -235,6 +260,24 @@
</span><span class="cx"> public $Password = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Sets SMTP auth type. Options are LOGIN | PLAIN | NTLM (default LOGIN)
+ * @var string
+ */
+ public $AuthType = '';
+
+ /**
+ * Sets SMTP realm.
+ * @var string
+ */
+ public $Realm = '';
+
+ /**
+ * Sets SMTP workstation.
+ * @var string
+ */
+ public $Workstation = '';
+
+ /**
</ins><span class="cx"> * Sets the SMTP server timeout in seconds.
</span><span class="cx"> * This function will not work with the win32 version.
</span><span class="cx"> * @var int
</span><span class="lines">@@ -248,6 +291,13 @@
</span><span class="cx"> public $SMTPDebug = false;
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Sets the function/method to use for debugging output.
+ * Right now we only honor "echo" or "error_log"
+ * @var string
+ */
+ public $Debugoutput = "echo";
+
+ /**
</ins><span class="cx"> * Prevents the SMTP connection from being closed after each mail
</span><span class="cx"> * sending. If this is set to true then to close the connection
</span><span class="cx"> * requires an explicit call to SmtpClose().
</span><span class="lines">@@ -269,53 +319,69 @@
</span><span class="cx"> public $SingleToArray = array();
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Provides the ability to change the line ending
</del><ins>+ * Provides the ability to change the generic line ending
+ * NOTE: The default remains '\n'. We force CRLF where we KNOW
+ * it must be used via self::CRLF
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $LE = "\n";
</span><span class="cx">
</span><del>- /**
- * Used with DKIM DNS Resource Record
</del><ins>+ /**
+ * Used with DKIM Signing
+ * required parameter if DKIM is enabled
+ *
+ * domain selector example domainkey
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><del>- public $DKIM_selector = 'phpmailer';
</del><ins>+ public $DKIM_selector = '';
</ins><span class="cx">
</span><span class="cx"> /**
</span><del>- * Used with DKIM DNS Resource Record
- * optional, in format of email address 'you@yourdomain.com'
</del><ins>+ * Used with DKIM Signing
+ * required if DKIM is enabled, in format of email address 'you@yourdomain.com' typically used as the source of the email
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $DKIM_identity = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Used with DKIM DNS Resource Record
</del><ins>+ * Used with DKIM Signing
+ * optional parameter if your private key requires a passphras
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $DKIM_passphrase = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Used with DKIM DNS Resource Record
- * optional, in format of email address 'you@yourdomain.com'
</del><ins>+ * Used with DKIM Singing
+ * required if DKIM is enabled, in format of email address 'domain.com'
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $DKIM_domain = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Used with DKIM DNS Resource Record
- * optional, in format of email address 'you@yourdomain.com'
</del><ins>+ * Used with DKIM Signing
+ * required if DKIM is enabled, path to private key file
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $DKIM_private = '';
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Callback Action function name
- * the function that handles the result of the send email action. Parameters:
</del><ins>+ * Callback Action function name.
+ * The function that handles the result of the send email action.
+ * It is called out by Send() for each email sent.
+ *
+ * Value can be:
+ * - 'function_name' for function names
+ * - 'Class::Method' for static method calls
+ * - array($object, 'Method') for calling methods on $object
+ * See http://php.net/is_callable manual page for more details.
+ *
+ * Parameters:
</ins><span class="cx"> * bool $result result of the send action
</span><span class="cx"> * string $to email address of the recipient
</span><span class="cx"> * string $cc cc email addresses
</span><span class="cx"> * string $bcc bcc email addresses
</span><span class="cx"> * string $subject the subject
</span><span class="cx"> * string $body the email body
</span><ins>+ * string $from email address of sender
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $action_function = ''; //'callbackAction';
</span><span class="lines">@@ -324,11 +390,11 @@
</span><span class="cx"> * Sets the PHPMailer Version number
</span><span class="cx"> * @var string
</span><span class="cx"> */
</span><del>- public $Version = '5.2.1';
</del><ins>+ public $Version = '5.2.4';
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * What to use in the X-Mailer header
</span><del>- * @var string
</del><ins>+ * @var string NULL for default, whitespace for None, or actual string to use
</ins><span class="cx"> */
</span><span class="cx"> public $XMailer = '';
</span><span class="cx">
</span><span class="lines">@@ -336,21 +402,85 @@
</span><span class="cx"> // PROPERTIES, PRIVATE AND PROTECTED
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx">
</span><del>- protected $smtp = NULL;
</del><ins>+ /**
+ * @var SMTP An instance of the SMTP sender class
+ * @access protected
+ */
+ protected $smtp = null;
+ /**
+ * @var array An array of 'to' addresses
+ * @access protected
+ */
</ins><span class="cx"> protected $to = array();
</span><ins>+ /**
+ * @var array An array of 'cc' addresses
+ * @access protected
+ */
</ins><span class="cx"> protected $cc = array();
</span><ins>+ /**
+ * @var array An array of 'bcc' addresses
+ * @access protected
+ */
</ins><span class="cx"> protected $bcc = array();
</span><ins>+ /**
+ * @var array An array of reply-to name and address
+ * @access protected
+ */
</ins><span class="cx"> protected $ReplyTo = array();
</span><ins>+ /**
+ * @var array An array of all kinds of addresses: to, cc, bcc, replyto
+ * @access protected
+ */
</ins><span class="cx"> protected $all_recipients = array();
</span><ins>+ /**
+ * @var array An array of attachments
+ * @access protected
+ */
</ins><span class="cx"> protected $attachment = array();
</span><ins>+ /**
+ * @var array An array of custom headers
+ * @access protected
+ */
</ins><span class="cx"> protected $CustomHeader = array();
</span><ins>+ /**
+ * @var string The message's MIME type
+ * @access protected
+ */
</ins><span class="cx"> protected $message_type = '';
</span><ins>+ /**
+ * @var array An array of MIME boundary strings
+ * @access protected
+ */
</ins><span class="cx"> protected $boundary = array();
</span><ins>+ /**
+ * @var array An array of available languages
+ * @access protected
+ */
</ins><span class="cx"> protected $language = array();
</span><ins>+ /**
+ * @var integer The number of errors encountered
+ * @access protected
+ */
</ins><span class="cx"> protected $error_count = 0;
</span><ins>+ /**
+ * @var string The filename of a DKIM certificate file
+ * @access protected
+ */
</ins><span class="cx"> protected $sign_cert_file = '';
</span><ins>+ /**
+ * @var string The filename of a DKIM key file
+ * @access protected
+ */
</ins><span class="cx"> protected $sign_key_file = '';
</span><ins>+ /**
+ * @var string The password of a DKIM key
+ * @access protected
+ */
</ins><span class="cx"> protected $sign_key_pass = '';
</span><ins>+ /**
+ * @var boolean Whether to throw exceptions for errors
+ * @access protected
+ */
</ins><span class="cx"> protected $exceptions = false;
</span><span class="cx">
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="lines">@@ -360,12 +490,47 @@
</span><span class="cx"> const STOP_MESSAGE = 0; // message only, continue processing
</span><span class="cx"> const STOP_CONTINUE = 1; // message?, likely ok to continue processing
</span><span class="cx"> const STOP_CRITICAL = 2; // message, plus full stop, critical error reached
</span><del>-
</del><ins>+ const CRLF = "\r\n"; // SMTP RFC specified EOL
+
</ins><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx"> // METHODS, VARIABLES
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Calls actual mail() function, but in a safe_mode aware fashion
+ * Also, unless sendmail_path points to sendmail (or something that
+ * claims to be sendmail), don't pass params (not a perfect fix,
+ * but it will do)
+ * @param string $to To
+ * @param string $subject Subject
+ * @param string $body Message Body
+ * @param string $header Additional Header(s)
+ * @param string $params Params
+ * @access private
+ * @return bool
+ */
+ private function mail_passthru($to, $subject, $body, $header, $params) {
+ if ( ini_get('safe_mode') || !($this->UseSendmailOptions) ) {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header);
+ } else {
+ $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($subject)), $body, $header, $params);
+ }
+ return $rt;
+ }
+
+ /**
+ * Outputs debugging info via user-defined method
+ * @param string $str
+ */
+ private function edebug($str) {
+ if ($this->Debugoutput == "error_log") {
+ error_log($str);
+ } else {
+ echo $str;
+ }
+ }
+
+ /**
</ins><span class="cx"> * Constructor
</span><span class="cx"> * @param boolean $exceptions Should we throw external exceptions?
</span><span class="cx"> */
</span><span class="lines">@@ -476,6 +641,7 @@
</span><span class="cx"> * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
</span><span class="cx"> * @param string $address The email address to send to
</span><span class="cx"> * @param string $name
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @return boolean true on success, false if address already used or invalid in some way
</span><span class="cx"> * @access protected
</span><span class="cx"> */
</span><span class="lines">@@ -485,20 +651,20 @@
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw new phpmailerException('Invalid recipient array: ' . $kind);
</span><span class="cx"> }
</span><del>-         if ($this->SMTPDebug) {
- echo $this->Lang('Invalid recipient array').': '.$kind;
</del><ins>+ if ($this->SMTPDebug) {
+ $this->edebug($this->Lang('Invalid recipient array').': '.$kind);
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx"> $address = trim($address);
</span><span class="cx"> $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
</span><del>- if (!self::ValidateAddress($address)) {
</del><ins>+ if (!$this->ValidateAddress($address)) {
</ins><span class="cx"> $this->SetError($this->Lang('invalid_address').': '. $address);
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw new phpmailerException($this->Lang('invalid_address').': '.$address);
</span><span class="cx"> }
</span><del>-         if ($this->SMTPDebug) {
- echo $this->Lang('invalid_address').': '.$address;
</del><ins>+ if ($this->SMTPDebug) {
+ $this->edebug($this->Lang('invalid_address').': '.$address);
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -521,18 +687,20 @@
</span><span class="cx"> * Set the From and FromName properties
</span><span class="cx"> * @param string $address
</span><span class="cx"> * @param string $name
</span><ins>+ * @param int $auto Also set Reply-To and Sender
+ * @throws phpmailerException
</ins><span class="cx"> * @return boolean
</span><span class="cx"> */
</span><span class="cx"> public function SetFrom($address, $name = '', $auto = 1) {
</span><span class="cx"> $address = trim($address);
</span><span class="cx"> $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
</span><del>- if (!self::ValidateAddress($address)) {
</del><ins>+ if (!$this->ValidateAddress($address)) {
</ins><span class="cx"> $this->SetError($this->Lang('invalid_address').': '. $address);
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw new phpmailerException($this->Lang('invalid_address').': '.$address);
</span><span class="cx"> }
</span><del>-         if ($this->SMTPDebug) {
- echo $this->Lang('invalid_address').': '.$address;
</del><ins>+ if ($this->SMTPDebug) {
+ $this->edebug($this->Lang('invalid_address').': '.$address);
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -551,25 +719,31 @@
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Check that a string looks roughly like an email address should
</span><del>- * Static so it can be used without instantiation
- * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator
- * Conforms approximately to RFC2822
- * @link http://www.hexillion.com/samples/#Regex Original pattern found here
</del><ins>+ * Static so it can be used without instantiation, public so people can overload
+ * Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is
+ * based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to
+ * not allow a@b type valid addresses :(
+ * Some Versions of PHP break on the regex though, likely due to PCRE, so use
+ * the older validation method for those users. (http://php.net/manual/en/pcre.installation.php)
+ * @link http://squiloople.com/2009/12/20/email-address-validation/
+ * @copyright regex Copyright Michael Rushton 2009-10 | http://squiloople.com/ | Feel free to use and redistribute this code. But please keep this copyright notice.
</ins><span class="cx"> * @param string $address The email address to check
</span><span class="cx"> * @return boolean
</span><span class="cx"> * @static
</span><span class="cx"> * @access public
</span><span class="cx"> */
</span><span class="cx"> public static function ValidateAddress($address) {
</span><del>- if (function_exists('filter_var')) { //Introduced in PHP 5.2
- if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
- return false;
- } else {
- return true;
- }
</del><ins>+        if ((defined('PCRE_VERSION')) && (version_compare(PCRE_VERSION, '8.0') >= 0)) {
+         return preg_match('/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)((?>(?>(?>((?>(?>(?>\x0D\x0A)?[         ])+|(?>[         ]*\x0D\x0A)?[         ]+)?)(\((?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}|(?!(?:.*[a-f0-9][:\]]){7,})((?6)(?>:(?6)){0,5})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:|(?!(?:.*[a-f0-9]:){5,})(?8)?::(?>((?6)(?>:(?6)){0,3}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', $address);
+        } elseif (function_exists('filter_var')) { //Introduced in PHP 5.2
+ if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
+ return false;
+ } else {
+ return true;
+ }
</ins><span class="cx"> } else {
</span><del>- return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
- }
</del><ins>+ return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="lines">@@ -580,6 +754,7 @@
</span><span class="cx"> * Creates message and assigns Mailer. If the message is
</span><span class="cx"> * not sent successfully then it returns false. Use the ErrorInfo
</span><span class="cx"> * variable to view description of the error.
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Send() {
</span><span class="lines">@@ -587,7 +762,7 @@
</span><span class="cx"> if(!$this->PreSend()) return false;
</span><span class="cx"> return $this->PostSend();
</span><span class="cx"> } catch (phpmailerException $e) {
</span><del>-         $this->SentMIMEMessage = '';
</del><ins>+ $this->mailHeader = '';
</ins><span class="cx"> $this->SetError($e->getMessage());
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw $e;
</span><span class="lines">@@ -596,9 +771,14 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- protected function PreSend() {
</del><ins>+ /**
+ * Prep mail by constructing all message entities
+ * @throws phpmailerException
+ * @return bool
+ */
+ public function PreSend() {
</ins><span class="cx"> try {
</span><del>-         $mailHeader = "";
</del><ins>+ $this->mailHeader = "";
</ins><span class="cx"> if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
</span><span class="cx"> throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL);
</span><span class="cx"> }
</span><span class="lines">@@ -619,26 +799,25 @@
</span><span class="cx"> $this->MIMEBody = $this->CreateBody();
</span><span class="cx">
</span><span class="cx"> // To capture the complete message when using mail(), create
</span><del>-         // an extra header list which CreateHeader() doesn't fold in
</del><ins>+ // an extra header list which CreateHeader() doesn't fold in
</ins><span class="cx"> if ($this->Mailer == 'mail') {
</span><span class="cx"> if (count($this->to) > 0) {
</span><del>- $mailHeader .= $this->AddrAppend("To", $this->to);
</del><ins>+ $this->mailHeader .= $this->AddrAppend("To", $this->to);
</ins><span class="cx"> } else {
</span><del>- $mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");
</del><ins>+ $this->mailHeader .= $this->HeaderLine("To", "undisclosed-recipients:;");
</ins><span class="cx"> }
</span><del>- $mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));
</del><ins>+ $this->mailHeader .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader(trim($this->Subject))));
</ins><span class="cx"> // if(count($this->cc) > 0) {
</span><del>- // $mailHeader .= $this->AddrAppend("Cc", $this->cc);
</del><ins>+ // $this->mailHeader .= $this->AddrAppend("Cc", $this->cc);
</ins><span class="cx"> // }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // digitally sign with DKIM if enabled
</span><del>- if ($this->DKIM_domain && $this->DKIM_private) {
</del><ins>+ if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) {
</ins><span class="cx"> $header_dkim = $this->DKIM_Add($this->MIMEHeader, $this->EncodeHeader($this->SecureHeader($this->Subject)), $this->MIMEBody);
</span><span class="cx"> $this->MIMEHeader = str_replace("\r\n", "\n", $header_dkim) . $this->MIMEHeader;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- $this->SentMIMEMessage = sprintf("%s%s\r\n\r\n%s",$this->MIMEHeader,$mailHeader,$this->MIMEBody);
</del><span class="cx"> return true;
</span><span class="cx">
</span><span class="cx"> } catch (phpmailerException $e) {
</span><span class="lines">@@ -650,7 +829,13 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- protected function PostSend() {
</del><ins>+ /**
+ * Actual Email transport function
+ * Send the email via the selected mechanism
+ * @throws phpmailerException
+ * @return bool
+ */
+ public function PostSend() {
</ins><span class="cx"> try {
</span><span class="cx"> // Choose the mailer and send through it
</span><span class="cx"> switch($this->Mailer) {
</span><span class="lines">@@ -663,34 +848,34 @@
</span><span class="cx"> default:
</span><span class="cx"> return $this->MailSend($this->MIMEHeader, $this->MIMEBody);
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> } catch (phpmailerException $e) {
</span><span class="cx"> $this->SetError($e->getMessage());
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw $e;
</span><span class="cx"> }
</span><del>-         if ($this->SMTPDebug) {
- echo $e->getMessage()."\n";
</del><ins>+ if ($this->SMTPDebug) {
+ $this->edebug($e->getMessage()."\n");
</ins><span class="cx"> }
</span><del>- return false;
</del><span class="cx"> }
</span><ins>+ return false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Sends mail using the $Sendmail program.
</span><span class="cx"> * @param string $header The message headers
</span><span class="cx"> * @param string $body The message body
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @access protected
</span><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> protected function SendmailSend($header, $body) {
</span><span class="cx"> if ($this->Sender != '') {
</span><del>- $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
</del><ins>+ $sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
</ins><span class="cx"> } else {
</span><span class="cx"> $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
</span><span class="cx"> }
</span><span class="cx"> if ($this->SingleTo === true) {
</span><del>- foreach ($this->SingleToArray as $key => $val) {
</del><ins>+ foreach ($this->SingleToArray as $val) {
</ins><span class="cx"> if(!@$mail = popen($sendmail, 'w')) {
</span><span class="cx"> throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
</span><span class="cx"> }
</span><span class="lines">@@ -726,6 +911,7 @@
</span><span class="cx"> * Sends mail using the PHP mail() function.
</span><span class="cx"> * @param string $header The message headers
</span><span class="cx"> * @param string $body The message body
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @access protected
</span><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="lines">@@ -739,38 +925,25 @@
</span><span class="cx"> if (empty($this->Sender)) {
</span><span class="cx"> $params = "-oi ";
</span><span class="cx"> } else {
</span><del>- $params = sprintf("-oi -f %s", $this->Sender);
</del><ins>+ $params = sprintf("-oi -f%s", $this->Sender);
</ins><span class="cx"> }
</span><span class="cx"> if ($this->Sender != '' and !ini_get('safe_mode')) {
</span><span class="cx"> $old_from = ini_get('sendmail_from');
</span><span class="cx"> ini_set('sendmail_from', $this->Sender);
</span><del>- if ($this->SingleTo === true && count($toArr) > 1) {
- foreach ($toArr as $key => $val) {
- $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
- // implement call back function if it exists
- $isSent = ($rt == 1) ? 1 : 0;
- $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
- }
- } else {
- $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
</del><ins>+ }
+ $rt = false;
+ if ($this->SingleTo === true && count($toArr) > 1) {
+ foreach ($toArr as $val) {
+ $rt = $this->mail_passthru($val, $this->Subject, $body, $header, $params);
</ins><span class="cx"> // implement call back function if it exists
</span><span class="cx"> $isSent = ($rt == 1) ? 1 : 0;
</span><del>- $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
</del><ins>+ $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
</ins><span class="cx"> }
</span><span class="cx"> } else {
</span><del>- if ($this->SingleTo === true && count($toArr) > 1) {
- foreach ($toArr as $key => $val) {
- $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
- // implement call back function if it exists
- $isSent = ($rt == 1) ? 1 : 0;
- $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
- }
- } else {
- $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
- // implement call back function if it exists
- $isSent = ($rt == 1) ? 1 : 0;
- $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
- }
</del><ins>+ $rt = $this->mail_passthru($to, $this->Subject, $body, $header, $params);
+ // implement call back function if it exists
+ $isSent = ($rt == 1) ? 1 : 0;
+ $this->doCallback($isSent, $to, $this->cc, $this->bcc, $this->Subject, $body);
</ins><span class="cx"> }
</span><span class="cx"> if (isset($old_from)) {
</span><span class="cx"> ini_set('sendmail_from', $old_from);
</span><span class="lines">@@ -786,6 +959,7 @@
</span><span class="cx"> * Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
</span><span class="cx"> * @param string $header The message headers
</span><span class="cx"> * @param string $body The message body
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @uses SMTP
</span><span class="cx"> * @access protected
</span><span class="cx"> * @return bool
</span><span class="lines">@@ -799,7 +973,8 @@
</span><span class="cx"> }
</span><span class="cx"> $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
</span><span class="cx"> if(!$this->smtp->Mail($smtp_from)) {
</span><del>- throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
</del><ins>+ $this->SetError($this->Lang('from_failed') . $smtp_from . " : " . implode(",",$this->smtp->getError())) ;
+ throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Attempt to send attach all recipients
</span><span class="lines">@@ -850,6 +1025,9 @@
</span><span class="cx"> }
</span><span class="cx"> if($this->SMTPKeepAlive == true) {
</span><span class="cx"> $this->smtp->Reset();
</span><ins>+ } else {
+ $this->smtp->Quit();
+ $this->smtp->Close();
</ins><span class="cx"> }
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -859,13 +1037,15 @@
</span><span class="cx"> * Returns false if the operation failed.
</span><span class="cx"> * @uses SMTP
</span><span class="cx"> * @access public
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function SmtpConnect() {
</span><span class="cx"> if(is_null($this->smtp)) {
</span><del>- $this->smtp = new SMTP();
</del><ins>+ $this->smtp = new SMTP;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+ $this->smtp->Timeout = $this->Timeout;
</ins><span class="cx"> $this->smtp->do_debug = $this->SMTPDebug;
</span><span class="cx"> $hosts = explode(';', $this->Host);
</span><span class="cx"> $index = 0;
</span><span class="lines">@@ -893,7 +1073,7 @@
</span><span class="cx">
</span><span class="cx"> if ($tls) {
</span><span class="cx"> if (!$this->smtp->StartTLS()) {
</span><del>- throw new phpmailerException($this->Lang('tls'));
</del><ins>+ throw new phpmailerException($this->Lang('connect_host'));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> //We must resend HELO after tls negotiation
</span><span class="lines">@@ -902,19 +1082,20 @@
</span><span class="cx">
</span><span class="cx"> $connection = true;
</span><span class="cx"> if ($this->SMTPAuth) {
</span><del>- if (!$this->smtp->Authenticate($this->Username, $this->Password)) {
</del><ins>+ if (!$this->smtp->Authenticate($this->Username, $this->Password, $this->AuthType,
+ $this->Realm, $this->Workstation)) {
</ins><span class="cx"> throw new phpmailerException($this->Lang('authenticate'));
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> $index++;
</span><del>- if (!$connection) {
- throw new phpmailerException($this->Lang('connect_host'));
- }
</del><ins>+ if (!$connection) {
+ throw new phpmailerException($this->Lang('connect_host'));
</ins><span class="cx"> }
</span><ins>+ }
</ins><span class="cx"> } catch (phpmailerException $e) {
</span><span class="cx"> $this->smtp->Reset();
</span><del>-         if ($this->exceptions) {
</del><ins>+ if ($this->exceptions) {
</ins><span class="cx"> throw $e;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -926,7 +1107,7 @@
</span><span class="cx"> * @return void
</span><span class="cx"> */
</span><span class="cx"> public function SmtpClose() {
</span><del>- if(!is_null($this->smtp)) {
</del><ins>+ if ($this->smtp !== null) {
</ins><span class="cx"> if($this->smtp->Connected()) {
</span><span class="cx"> $this->smtp->Quit();
</span><span class="cx"> $this->smtp->Close();
</span><span class="lines">@@ -939,28 +1120,30 @@
</span><span class="cx"> * Returns false if it cannot load the language file. The default language is English.
</span><span class="cx"> * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
</span><span class="cx"> * @param string $lang_path Path to the language file directory
</span><ins>+ * @return bool
</ins><span class="cx"> * @access public
</span><span class="cx"> */
</span><span class="cx"> function SetLanguage($langcode = 'en', $lang_path = 'language/') {
</span><span class="cx"> //Define full set of translatable strings
</span><span class="cx"> $PHPMAILER_LANG = array(
</span><del>- 'provide_address' => 'You must provide at least one recipient email address.',
</del><ins>+ 'authenticate' => 'SMTP Error: Could not authenticate.',
+ 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
+ 'data_not_accepted' => 'SMTP Error: Data not accepted.',
+ 'empty_message' => 'Message body empty',
+ 'encoding' => 'Unknown encoding: ',
+ 'execute' => 'Could not execute: ',
+ 'file_access' => 'Could not access file: ',
+ 'file_open' => 'File Error: Could not open file: ',
+ 'from_failed' => 'The following From address failed: ',
+ 'instantiate' => 'Could not instantiate mail function.',
+ 'invalid_address' => 'Invalid address',
</ins><span class="cx"> 'mailer_not_supported' => ' mailer is not supported.',
</span><del>- 'execute' => 'Could not execute: ',
- 'instantiate' => 'Could not instantiate mail function.',
- 'authenticate' => 'SMTP Error: Could not authenticate.',
- 'from_failed' => 'The following From address failed: ',
- 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
- 'data_not_accepted' => 'SMTP Error: Data not accepted.',
- 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
- 'file_access' => 'Could not access file: ',
- 'file_open' => 'File Error: Could not open file: ',
- 'encoding' => 'Unknown encoding: ',
- 'signing' => 'Signing Error: ',
- 'smtp_error' => 'SMTP server error: ',
- 'empty_message' => 'Message body empty',
- 'invalid_address' => 'Invalid address',
- 'variable_set' => 'Cannot set or reset variable: '
</del><ins>+ 'provide_address' => 'You must provide at least one recipient email address.',
+ 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
+ 'signing' => 'Signing Error: ',
+ 'smtp_connect_failed' => 'SMTP Connect() failed.',
+ 'smtp_error' => 'SMTP server error: ',
+ 'variable_set' => 'Cannot set or reset variable: '
</ins><span class="cx"> );
</span><span class="cx"> //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"!
</span><span class="cx"> $l = true;
</span><span class="lines">@@ -986,6 +1169,8 @@
</span><span class="cx"> /**
</span><span class="cx"> * Creates recipient headers.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $type
+ * @param array $addr
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function AddrAppend($type, $addr) {
</span><span class="lines">@@ -1003,6 +1188,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Formats an address correctly.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $addr
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function AddrFormat($addr) {
</span><span class="lines">@@ -1028,13 +1214,15 @@
</span><span class="cx"> // If utf-8 encoding is used, we will need to make sure we don't
</span><span class="cx"> // split multibyte characters when we wrap
</span><span class="cx"> $is_utf8 = (strtolower($this->CharSet) == "utf-8");
</span><ins>+ $lelen = strlen($this->LE);
+ $crlflen = strlen(self::CRLF);
</ins><span class="cx">
</span><span class="cx"> $message = $this->FixEOL($message);
</span><del>- if (substr($message, -1) == $this->LE) {
- $message = substr($message, 0, -1);
</del><ins>+ if (substr($message, -$lelen) == $this->LE) {
+ $message = substr($message, 0, -$lelen);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- $line = explode($this->LE, $message);
</del><ins>+ $line = explode($this->LE, $message); // Magic. We know FixEOL uses $LE
</ins><span class="cx"> $message = '';
</span><span class="cx"> for ($i = 0 ;$i < count($line); $i++) {
</span><span class="cx"> $line_part = explode(' ', $line[$i]);
</span><span class="lines">@@ -1042,7 +1230,7 @@
</span><span class="cx"> for ($e = 0; $e<count($line_part); $e++) {
</span><span class="cx"> $word = $line_part[$e];
</span><span class="cx"> if ($qp_mode and (strlen($word) > $length)) {
</span><del>- $space_left = $length - strlen($buf) - 1;
</del><ins>+ $space_left = $length - strlen($buf) - $crlflen;
</ins><span class="cx"> if ($e != 0) {
</span><span class="cx"> if ($space_left > 20) {
</span><span class="cx"> $len = $space_left;
</span><span class="lines">@@ -1056,7 +1244,7 @@
</span><span class="cx"> $part = substr($word, 0, $len);
</span><span class="cx"> $word = substr($word, $len);
</span><span class="cx"> $buf .= ' ' . $part;
</span><del>- $message .= $buf . sprintf("=%s", $this->LE);
</del><ins>+ $message .= $buf . sprintf("=%s", self::CRLF);
</ins><span class="cx"> } else {
</span><span class="cx"> $message .= $buf . $soft_break;
</span><span class="cx"> }
</span><span class="lines">@@ -1075,7 +1263,7 @@
</span><span class="cx"> $word = substr($word, $len);
</span><span class="cx">
</span><span class="cx"> if (strlen($word) > 0) {
</span><del>- $message .= $part . sprintf("=%s", $this->LE);
</del><ins>+ $message .= $part . sprintf("=%s", self::CRLF);
</ins><span class="cx"> } else {
</span><span class="cx"> $buf = $part;
</span><span class="cx"> }
</span><span class="lines">@@ -1090,7 +1278,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- $message .= $buf . $this->LE;
</del><ins>+ $message .= $buf . self::CRLF;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return $message;
</span><span class="lines">@@ -1175,8 +1363,15 @@
</span><span class="cx"> $this->boundary[2] = 'b2_' . $uniq_id;
</span><span class="cx"> $this->boundary[3] = 'b3_' . $uniq_id;
</span><span class="cx">
</span><del>- $result .= $this->HeaderLine('Date', self::RFCDate());
- if($this->Sender == '') {
</del><ins>+ if ($this->MessageDate == '') {
+ $result .= $this->HeaderLine('Date', self::RFCDate());
+ } else {
+ $result .= $this->HeaderLine('Date', $this->MessageDate);
+ }
+
+ if ($this->ReturnPath) {
+ $result .= $this->HeaderLine('Return-Path', trim($this->ReturnPath));
+ } elseif ($this->Sender == '') {
</ins><span class="cx"> $result .= $this->HeaderLine('Return-Path', trim($this->From));
</span><span class="cx"> } else {
</span><span class="cx"> $result .= $this->HeaderLine('Return-Path', trim($this->Sender));
</span><span class="lines">@@ -1195,7 +1390,7 @@
</span><span class="cx"> $result .= $this->HeaderLine('To', 'undisclosed-recipients:;');
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-        }
</del><ins>+ }
</ins><span class="cx">
</span><span class="cx"> $from = array();
</span><span class="cx"> $from[0][0] = trim($this->From);
</span><span class="lines">@@ -1227,10 +1422,13 @@
</span><span class="cx"> $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
</span><span class="cx"> }
</span><span class="cx"> $result .= $this->HeaderLine('X-Priority', $this->Priority);
</span><del>- if($this->XMailer) {
- $result .= $this->HeaderLine('X-Mailer', $this->XMailer);
</del><ins>+ if ($this->XMailer == '') {
+ $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)');
</ins><span class="cx"> } else {
</span><del>- $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (http://code.google.com/a/apache-extras.org/p/phpmailer/)');
</del><ins>+ $myXmailer = trim($this->XMailer);
+ if ($myXmailer) {
+ $result .= $this->HeaderLine('X-Mailer', $myXmailer);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($this->ConfirmReadingTo != '') {
</span><span class="lines">@@ -1257,10 +1455,6 @@
</span><span class="cx"> public function GetMailMIME() {
</span><span class="cx"> $result = '';
</span><span class="cx"> switch($this->message_type) {
</span><del>- case 'plain':
- $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
- $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset="'.$this->CharSet.'"');
- break;
</del><span class="cx"> case 'inline':
</span><span class="cx"> $result .= $this->HeaderLine('Content-Type', 'multipart/related;');
</span><span class="cx"> $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
</span><span class="lines">@@ -1277,10 +1471,15 @@
</span><span class="cx"> $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;');
</span><span class="cx"> $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
</span><span class="cx"> break;
</span><ins>+ default:
+ // Catches case 'plain': and case '':
+ $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding);
+ $result .= $this->TextLine('Content-Type: '.$this->ContentType.'; charset='.$this->CharSet);
+ break;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($this->Mailer != 'mail') {
</span><del>- $result .= $this->LE.$this->LE;
</del><ins>+ $result .= $this->LE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return $result;
</span><span class="lines">@@ -1292,28 +1491,26 @@
</span><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function GetSentMIMEMessage() {
</span><del>- return $this->SentMIMEMessage;
</del><ins>+ return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Assembles the message body. Returns an empty string on failure.
</span><span class="cx"> * @access public
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @return string The assembled message body
</span><span class="cx"> */
</span><span class="cx"> public function CreateBody() {
</span><span class="cx"> $body = '';
</span><span class="cx">
</span><span class="cx"> if ($this->sign_key_file) {
</span><del>- $body .= $this->GetMailMIME();
</del><ins>+ $body .= $this->GetMailMIME().$this->LE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $this->SetWordWrap();
</span><span class="cx">
</span><span class="cx"> switch($this->message_type) {
</span><del>- case 'plain':
- $body .= $this->EncodeString($this->Body, $this->Encoding);
- break;
</del><span class="cx"> case 'inline':
</span><span class="cx"> $body .= $this->GetBoundary($this->boundary[1], '', '', '');
</span><span class="cx"> $body .= $this->EncodeString($this->Body, $this->Encoding);
</span><span class="lines">@@ -1398,6 +1595,10 @@
</span><span class="cx"> $body .= $this->LE;
</span><span class="cx"> $body .= $this->AttachAll("attachment", $this->boundary[1]);
</span><span class="cx"> break;
</span><ins>+ default:
+ // catch case 'plain' and case ''
+ $body .= $this->EncodeString($this->Body, $this->Encoding);
+ break;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ($this->IsError()) {
</span><span class="lines">@@ -1430,6 +1631,10 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns the start of a message boundary.
</span><span class="cx"> * @access protected
</span><ins>+ * @param string $boundary
+ * @param string $charSet
+ * @param string $contentType
+ * @param string $encoding
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> protected function GetBoundary($boundary, $charSet, $contentType, $encoding) {
</span><span class="lines">@@ -1444,7 +1649,7 @@
</span><span class="cx"> $encoding = $this->Encoding;
</span><span class="cx"> }
</span><span class="cx"> $result .= $this->TextLine('--' . $boundary);
</span><del>- $result .= sprintf("Content-Type: %s; charset=\"%s\"", $contentType, $charSet);
</del><ins>+ $result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet);
</ins><span class="cx"> $result .= $this->LE;
</span><span class="cx"> $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding);
</span><span class="cx"> $result .= $this->LE;
</span><span class="lines">@@ -1455,6 +1660,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns the end of a message boundary.
</span><span class="cx"> * @access protected
</span><ins>+ * @param string $boundary
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> protected function EndBoundary($boundary) {
</span><span class="lines">@@ -1478,6 +1684,8 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns a formatted header line.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $name
+ * @param string $value
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function HeaderLine($name, $value) {
</span><span class="lines">@@ -1487,6 +1695,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns a formatted mail line.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $value
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function TextLine($value) {
</span><span class="lines">@@ -1505,6 +1714,7 @@
</span><span class="cx"> * @param string $name Overrides the attachment name.
</span><span class="cx"> * @param string $encoding File encoding (see $Encoding).
</span><span class="cx"> * @param string $type File extension (MIME) type.
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
</span><span class="lines">@@ -1533,8 +1743,8 @@
</span><span class="cx"> if ($this->exceptions) {
</span><span class="cx"> throw $e;
</span><span class="cx"> }
</span><del>-         if ($this->SMTPDebug) {
- echo $e->getMessage()."\n";
</del><ins>+ if ($this->SMTPDebug) {
+ $this->edebug($e->getMessage()."\n");
</ins><span class="cx"> }
</span><span class="cx"> if ( $e->getCode() == self::STOP_CRITICAL ) {
</span><span class="cx"> return false;
</span><span class="lines">@@ -1555,6 +1765,8 @@
</span><span class="cx"> * Attaches all fs, string, and binary attachments to the message.
</span><span class="cx"> * Returns an empty string on failure.
</span><span class="cx"> * @access protected
</span><ins>+ * @param string $disposition_type
+ * @param string $boundary
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> protected function AttachAll($disposition_type, $boundary) {
</span><span class="lines">@@ -1568,6 +1780,8 @@
</span><span class="cx"> // CHECK IF IT IS A VALID DISPOSITION_FILTER
</span><span class="cx"> if($attachment[6] == $disposition_type) {
</span><span class="cx"> // Check for string attachment
</span><ins>+ $string = '';
+ $path = '';
</ins><span class="cx"> $bString = $attachment[5];
</span><span class="cx"> if ($bString) {
</span><span class="cx"> $string = $attachment[0];
</span><span class="lines">@@ -1624,6 +1838,7 @@
</span><span class="cx"> * Returns an empty string on failure.
</span><span class="cx"> * @param string $path The full path to the file
</span><span class="cx"> * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
</span><ins>+ * @throws phpmailerException
</ins><span class="cx"> * @see EncodeFile()
</span><span class="cx"> * @access protected
</span><span class="cx"> * @return string
</span><span class="lines">@@ -1633,28 +1848,28 @@
</span><span class="cx"> if (!is_readable($path)) {
</span><span class="cx"> throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
</span><span class="cx"> }
</span><del>- if (function_exists('get_magic_quotes')) {
- function get_magic_quotes() {
- return false;
- }
- }
-         $magic_quotes = get_magic_quotes_runtime();
-         if ($magic_quotes) {
</del><ins>+ // if (!function_exists('get_magic_quotes')) {
+ // function get_magic_quotes() {
+ // return false;
+ // }
+ // }
+ $magic_quotes = get_magic_quotes_runtime();
+ if ($magic_quotes) {
</ins><span class="cx"> if (version_compare(PHP_VERSION, '5.3.0', '<')) {
</span><span class="cx"> set_magic_quotes_runtime(0);
</span><span class="cx"> } else {
</span><del>-                 ini_set('magic_quotes_runtime', 0);
-                }
-         }
</del><ins>+ ini_set('magic_quotes_runtime', 0);
+ }
+ }
</ins><span class="cx"> $file_buffer = file_get_contents($path);
</span><span class="cx"> $file_buffer = $this->EncodeString($file_buffer, $encoding);
</span><del>-         if ($magic_quotes) {
</del><ins>+ if ($magic_quotes) {
</ins><span class="cx"> if (version_compare(PHP_VERSION, '5.3.0', '<')) {
</span><span class="cx"> set_magic_quotes_runtime($magic_quotes);
</span><span class="cx"> } else {
</span><del>-                 ini_set('magic_quotes_runtime', $magic_quotes);
-         }
-         }
</del><ins>+ ini_set('magic_quotes_runtime', $magic_quotes);
+ }
+ }
</ins><span class="cx"> return $file_buffer;
</span><span class="cx"> } catch (Exception $e) {
</span><span class="cx"> $this->SetError($e->getMessage());
</span><span class="lines">@@ -1699,6 +1914,8 @@
</span><span class="cx"> /**
</span><span class="cx"> * Encode a header string to best (shortest) of Q, B, quoted or none.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $str
+ * @param string $position
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function EncodeHeader($str, $position = 'text') {
</span><span class="lines">@@ -1737,7 +1954,7 @@
</span><span class="cx"> if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) {
</span><span class="cx"> // Use a custom function which correctly encodes and wraps long
</span><span class="cx"> // multibyte strings without breaking lines within a character
</span><del>- $encoded = $this->Base64EncodeWrapMB($str);
</del><ins>+ $encoded = $this->Base64EncodeWrapMB($str, "\n");
</ins><span class="cx"> } else {
</span><span class="cx"> $encoded = base64_encode($str);
</span><span class="cx"> $maxlen -= $maxlen % 4;
</span><span class="lines">@@ -1747,7 +1964,7 @@
</span><span class="cx"> $encoding = 'Q';
</span><span class="cx"> $encoded = $this->EncodeQ($str, $position);
</span><span class="cx"> $encoded = $this->WrapText($encoded, $maxlen, true);
</span><del>- $encoded = str_replace('='.$this->LE, "\n", trim($encoded));
</del><ins>+ $encoded = str_replace('='.self::CRLF, "\n", trim($encoded));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
</span><span class="lines">@@ -1776,12 +1993,16 @@
</span><span class="cx"> * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
</span><span class="cx"> * @access public
</span><span class="cx"> * @param string $str multi-byte text to wrap encode
</span><ins>+ * @param string $lf string to use as linefeed/end-of-line
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><del>- public function Base64EncodeWrapMB($str) {
</del><ins>+ public function Base64EncodeWrapMB($str, $lf=null) {
</ins><span class="cx"> $start = "=?".$this->CharSet."?B?";
</span><span class="cx"> $end = "?=";
</span><span class="cx"> $encoded = "";
</span><ins>+ if ($lf === null) {
+ $lf = $this->LE;
+ }
</ins><span class="cx">
</span><span class="cx"> $mb_length = mb_strlen($str, $this->CharSet);
</span><span class="cx"> // Each line must have length <= 75, including $start and $end
</span><span class="lines">@@ -1802,11 +2023,11 @@
</span><span class="cx"> }
</span><span class="cx"> while (strlen($chunk) > $length);
</span><span class="cx">
</span><del>- $encoded .= $chunk . $this->LE;
</del><ins>+ $encoded .= $chunk . $lf;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Chomp the last linefeed
</span><del>- $encoded = substr($encoded, 0, -strlen($this->LE));
</del><ins>+ $encoded = substr($encoded, 0, -strlen($lf));
</ins><span class="cx"> return $encoded;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1814,8 +2035,10 @@
</span><span class="cx"> * Encode string to quoted-printable.
</span><span class="cx"> * Only uses standard PHP, slow, but will always work
</span><span class="cx"> * @access public
</span><del>- * @param string $string the text to encode
</del><ins>+ * @param string $input
</ins><span class="cx"> * @param integer $line_max Number of chars allowed on a line before wrapping
</span><ins>+ * @param bool $space_conv
+ * @internal param string $string the text to encode
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) {
</span><span class="lines">@@ -1840,8 +2063,8 @@
</span><span class="cx"> $c = '=20';
</span><span class="cx"> }
</span><span class="cx"> } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
</span><del>- $h2 = floor($dec/16);
- $h1 = floor($dec%16);
</del><ins>+ $h2 = (integer)floor($dec/16);
+ $h1 = (integer)floor($dec%16);
</ins><span class="cx"> $c = $escape.$hex[$h2].$hex[$h1];
</span><span class="cx"> }
</span><span class="cx"> if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
</span><span class="lines">@@ -1901,30 +2124,38 @@
</span><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function EncodeQ($str, $position = 'text') {
</span><del>- // There should not be any EOL in the string
- $encoded = preg_replace('/[\r\n]*/', '', $str);
-
</del><ins>+ //There should not be any EOL in the string
+        $pattern="";
+ $encoded = str_replace(array("\r", "\n"), '', $str);
</ins><span class="cx"> switch (strtolower($position)) {
</span><span class="cx"> case 'phrase':
</span><del>- $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
</del><ins>+ $pattern = '^A-Za-z0-9!*+\/ -';
</ins><span class="cx"> break;
</span><ins>+
</ins><span class="cx"> case 'comment':
</span><del>- $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
</del><ins>+ $pattern = '\(\)"';
+ //note that we dont break here!
+ //for this reason we build the $pattern withoud including delimiters and []
+
</ins><span class="cx"> case 'text':
</span><span class="cx"> default:
</span><del>- // Replace every high ascii, control =, ? and _ characters
- //TODO using /e (equivalent to eval()) is probably not a good idea
- $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
- "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);
</del><ins>+ //Replace every high ascii, control =, ? and _ characters
+ //We put \075 (=) as first value to make sure it's the first one in being converted, preventing double encode
+ $pattern = '\075\000-\011\013\014\016-\037\077\137\177-\377' . $pattern;
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+
+ if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
+ foreach (array_unique($matches[0]) as $char) {
+ $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
+ }
+ }
+
+ //Replace every spaces to _ (more readable than =20)
+ return str_replace(' ', '_', $encoded);
+}
</ins><span class="cx">
</span><del>- // Replace every spaces to _ (more readable than =20)
- $encoded = str_replace(' ', '_', $encoded);
</del><span class="cx">
</span><del>- return $encoded;
- }
-
</del><span class="cx"> /**
</span><span class="cx"> * Adds a string or binary attachment (non-filesystem) to the list.
</span><span class="cx"> * This method can be used to attach ascii or binary data,
</span><span class="lines">@@ -1989,12 +2220,25 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- public function AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream') {
</del><ins>+ /**
+ * Adds an embedded stringified attachment. This can include images, sounds, and
+ * just about any other document. Make sure to set the $type to an
+ * image type. For JPEG images use "image/jpeg" and for GIF images
+ * use "image/gif".
+ * @param string $string The attachment.
+ * @param string $cid Content ID of the attachment. Use this to identify
+ * the Id for accessing the image in an HTML form.
+ * @param string $name Overrides the attachment name.
+ * @param string $encoding File encoding (see $Encoding).
+ * @param string $type File extension (MIME) type.
+ * @return bool
+ */
+ public function AddStringEmbeddedImage($string, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
</ins><span class="cx"> // Append to $attachment array
</span><span class="cx"> $this->attachment[] = array(
</span><span class="cx"> 0 => $string,
</span><del>- 1 => $filename,
- 2 => basename($filename),
</del><ins>+ 1 => $name,
+ 2 => $name,
</ins><span class="cx"> 3 => $encoding,
</span><span class="cx"> 4 => $type,
</span><span class="cx"> 5 => true, // isStringAttachment
</span><span class="lines">@@ -2017,6 +2261,10 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Returns true if an attachment (non-inline) is present.
+ * @return bool
+ */
</ins><span class="cx"> public function AttachmentExists() {
</span><span class="cx"> foreach($this->attachment as $attachment) {
</span><span class="cx"> if ($attachment[6] == 'attachment') {
</span><span class="lines">@@ -2026,8 +2274,12 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ /**
+ * Does this message have an alternative body set?
+ * @return bool
+ */
</ins><span class="cx"> public function AlternativeExists() {
</span><del>- return strlen($this->AltBody)>0;
</del><ins>+ return !empty($this->AltBody);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="lines">@@ -2111,6 +2363,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Adds the error message to the error container.
</span><span class="cx"> * @access protected
</span><ins>+ * @param string $msg
</ins><span class="cx"> * @return void
</span><span class="cx"> */
</span><span class="cx"> protected function SetError($msg) {
</span><span class="lines">@@ -2160,6 +2413,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Returns a message in the appropriate language.
</span><span class="cx"> * @access protected
</span><ins>+ * @param string $key
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> protected function Lang($key) {
</span><span class="lines">@@ -2184,30 +2438,44 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Changes every end of line from CR or LF to CRLF.
</del><ins>+ * Changes every end of line from CRLF, CR or LF to $this->LE.
</ins><span class="cx"> * @access public
</span><ins>+ * @param string $str String to FixEOL
</ins><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function FixEOL($str) {
</span><del>- $str = str_replace("\r\n", "\n", $str);
- $str = str_replace("\r", "\n", $str);
- $str = str_replace("\n", $this->LE, $str);
- return $str;
</del><ins>+        // condense down to \n
+        $nstr = str_replace(array("\r\n", "\r"), "\n", $str);
+        // Now convert LE as needed
+        if ($this->LE !== "\n") {
+                $nstr = str_replace("\n", $this->LE, $nstr);
+        }
+ return $nstr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Adds a custom header.
</del><ins>+ * Adds a custom header. $name value can be overloaded to contain
+ * both header name and value (name:value)
</ins><span class="cx"> * @access public
</span><ins>+ * @param string $name custom header name
+ * @param string $value header value
</ins><span class="cx"> * @return void
</span><span class="cx"> */
</span><del>- public function AddCustomHeader($custom_header) {
- $this->CustomHeader[] = explode(':', $custom_header, 2);
</del><ins>+ public function AddCustomHeader($name, $value=null) {
+        if ($value === null) {
+                // Value passed in as name:value
+                $this->CustomHeader[] = explode(':', $name, 2);
+        } else {
+                $this->CustomHeader[] = array($name, $value);
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Evaluates the message and returns modifications for inline images and backgrounds
</span><span class="cx"> * @access public
</span><del>- * @return $message
</del><ins>+ * @param string $message Text to be HTML modified
+ * @param string $basedir baseline directory for path
+ * @return string $message
</ins><span class="cx"> */
</span><span class="cx"> public function MsgHTML($message, $basedir = '') {
</span><span class="cx"> preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images);
</span><span class="lines">@@ -2217,13 +2485,15 @@
</span><span class="cx"> if (!preg_match('#^[A-z]+://#', $url)) {
</span><span class="cx"> $filename = basename($url);
</span><span class="cx"> $directory = dirname($url);
</span><del>- ($directory == '.') ? $directory='': '';
- $cid = 'cid:' . md5($filename);
</del><ins>+ if ($directory == '.') {
+ $directory = '';
+ }
+ $cid = 'cid:' . md5($url);
</ins><span class="cx"> $ext = pathinfo($filename, PATHINFO_EXTENSION);
</span><span class="cx"> $mimeType = self::_mime_types($ext);
</span><span class="cx"> if ( strlen($basedir) > 1 && substr($basedir, -1) != '/') { $basedir .= '/'; }
</span><span class="cx"> if ( strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; }
</span><del>- if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType) ) {
</del><ins>+ if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($url), $filename, 'base64', $mimeType) ) {
</ins><span class="cx"> $message = preg_replace("/".$images[1][$i]."=[\"']".preg_quote($url, '/')."[\"']/Ui", $images[1][$i]."=\"".$cid."\"", $message);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -2231,40 +2501,42 @@
</span><span class="cx"> }
</span><span class="cx"> $this->IsHTML(true);
</span><span class="cx"> $this->Body = $message;
</span><del>-        if (empty($this->AltBody)) {
-                $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
-                if (!empty($textMsg)) {
-                        $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet);
-                }
-        }
</del><span class="cx"> if (empty($this->AltBody)) {
</span><ins>+ $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s', '', $message)));
+ if (!empty($textMsg)) {
+ $this->AltBody = html_entity_decode($textMsg, ENT_QUOTES, $this->CharSet);
+ }
+ }
+ if (empty($this->AltBody)) {
</ins><span class="cx"> $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
</span><span class="cx"> }
</span><del>-        return $message;
</del><ins>+ return $message;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Gets the MIME type of the embedded or inline image
</span><del>- * @param string File extension
</del><ins>+ * @param string $ext File extension
</ins><span class="cx"> * @access public
</span><span class="cx"> * @return string MIME type of ext
</span><span class="cx"> * @static
</span><span class="cx"> */
</span><span class="cx"> public static function _mime_types($ext = '') {
</span><span class="cx"> $mimes = array(
</span><ins>+ 'xl' => 'application/excel',
</ins><span class="cx"> 'hqx' => 'application/mac-binhex40',
</span><span class="cx"> 'cpt' => 'application/mac-compactpro',
</span><ins>+ 'bin' => 'application/macbinary',
</ins><span class="cx"> 'doc' => 'application/msword',
</span><del>- 'bin' => 'application/macbinary',
</del><ins>+ 'word' => 'application/msword',
+ 'class' => 'application/octet-stream',
+ 'dll' => 'application/octet-stream',
</ins><span class="cx"> 'dms' => 'application/octet-stream',
</span><ins>+ 'exe' => 'application/octet-stream',
</ins><span class="cx"> 'lha' => 'application/octet-stream',
</span><span class="cx"> 'lzh' => 'application/octet-stream',
</span><del>- 'exe' => 'application/octet-stream',
- 'class' => 'application/octet-stream',
</del><span class="cx"> 'psd' => 'application/octet-stream',
</span><ins>+ 'sea' => 'application/octet-stream',
</ins><span class="cx"> 'so' => 'application/octet-stream',
</span><del>- 'sea' => 'application/octet-stream',
- 'dll' => 'application/octet-stream',
</del><span class="cx"> 'oda' => 'application/oda',
</span><span class="cx"> 'pdf' => 'application/pdf',
</span><span class="cx"> 'ai' => 'application/postscript',
</span><span class="lines">@@ -2282,9 +2554,9 @@
</span><span class="cx"> 'dxr' => 'application/x-director',
</span><span class="cx"> 'dvi' => 'application/x-dvi',
</span><span class="cx"> 'gtar' => 'application/x-gtar',
</span><ins>+ 'php3' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
</ins><span class="cx"> 'php' => 'application/x-httpd-php',
</span><del>- 'php4' => 'application/x-httpd-php',
- 'php3' => 'application/x-httpd-php',
</del><span class="cx"> 'phtml' => 'application/x-httpd-php',
</span><span class="cx"> 'phps' => 'application/x-httpd-php-source',
</span><span class="cx"> 'js' => 'application/x-javascript',
</span><span class="lines">@@ -2292,53 +2564,50 @@
</span><span class="cx"> 'sit' => 'application/x-stuffit',
</span><span class="cx"> 'tar' => 'application/x-tar',
</span><span class="cx"> 'tgz' => 'application/x-tar',
</span><ins>+ 'xht' => 'application/xhtml+xml',
</ins><span class="cx"> 'xhtml' => 'application/xhtml+xml',
</span><del>- 'xht' => 'application/xhtml+xml',
</del><span class="cx"> 'zip' => 'application/zip',
</span><span class="cx"> 'mid' => 'audio/midi',
</span><span class="cx"> 'midi' => 'audio/midi',
</span><del>- 'mpga' => 'audio/mpeg',
</del><span class="cx"> 'mp2' => 'audio/mpeg',
</span><span class="cx"> 'mp3' => 'audio/mpeg',
</span><ins>+ 'mpga' => 'audio/mpeg',
</ins><span class="cx"> 'aif' => 'audio/x-aiff',
</span><ins>+ 'aifc' => 'audio/x-aiff',
</ins><span class="cx"> 'aiff' => 'audio/x-aiff',
</span><del>- 'aifc' => 'audio/x-aiff',
</del><span class="cx"> 'ram' => 'audio/x-pn-realaudio',
</span><span class="cx"> 'rm' => 'audio/x-pn-realaudio',
</span><span class="cx"> 'rpm' => 'audio/x-pn-realaudio-plugin',
</span><span class="cx"> 'ra' => 'audio/x-realaudio',
</span><del>- 'rv' => 'video/vnd.rn-realvideo',
</del><span class="cx"> 'wav' => 'audio/x-wav',
</span><span class="cx"> 'bmp' => 'image/bmp',
</span><span class="cx"> 'gif' => 'image/gif',
</span><span class="cx"> 'jpeg' => 'image/jpeg',
</span><ins>+ 'jpe' => 'image/jpeg',
</ins><span class="cx"> 'jpg' => 'image/jpeg',
</span><del>- 'jpe' => 'image/jpeg',
</del><span class="cx"> 'png' => 'image/png',
</span><span class="cx"> 'tiff' => 'image/tiff',
</span><span class="cx"> 'tif' => 'image/tiff',
</span><ins>+ 'eml' => 'message/rfc822',
</ins><span class="cx"> 'css' => 'text/css',
</span><span class="cx"> 'html' => 'text/html',
</span><span class="cx"> 'htm' => 'text/html',
</span><span class="cx"> 'shtml' => 'text/html',
</span><ins>+ 'log' => 'text/plain',
+ 'text' => 'text/plain',
</ins><span class="cx"> 'txt' => 'text/plain',
</span><del>- 'text' => 'text/plain',
- 'log' => 'text/plain',
</del><span class="cx"> 'rtx' => 'text/richtext',
</span><span class="cx"> 'rtf' => 'text/rtf',
</span><span class="cx"> 'xml' => 'text/xml',
</span><span class="cx"> 'xsl' => 'text/xml',
</span><span class="cx"> 'mpeg' => 'video/mpeg',
</span><ins>+ 'mpe' => 'video/mpeg',
</ins><span class="cx"> 'mpg' => 'video/mpeg',
</span><del>- 'mpe' => 'video/mpeg',
</del><ins>+ 'mov' => 'video/quicktime',
</ins><span class="cx"> 'qt' => 'video/quicktime',
</span><del>- 'mov' => 'video/quicktime',
</del><ins>+ 'rv' => 'video/vnd.rn-realvideo',
</ins><span class="cx"> 'avi' => 'video/x-msvideo',
</span><del>- 'movie' => 'video/x-sgi-movie',
- 'doc' => 'application/msword',
- 'word' => 'application/msword',
- 'xl' => 'application/excel',
- 'eml' => 'message/rfc822'
</del><ins>+ 'movie' => 'video/x-sgi-movie'
</ins><span class="cx"> );
</span><span class="cx"> return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)];
</span><span class="cx"> }
</span><span class="lines">@@ -2353,6 +2622,8 @@
</span><span class="cx"> * @param string $name Parameter Name
</span><span class="cx"> * @param mixed $value Parameter Value
</span><span class="cx"> * NOTE: will not work with arrays, there are no arrays to set/reset
</span><ins>+ * @throws phpmailerException
+ * @return bool
</ins><span class="cx"> * @todo Should this not be using __set() magic function?
</span><span class="cx"> */
</span><span class="cx"> public function set($name, $value = '') {
</span><span class="lines">@@ -2378,15 +2649,14 @@
</span><span class="cx"> * @return string
</span><span class="cx"> */
</span><span class="cx"> public function SecureHeader($str) {
</span><del>- $str = str_replace("\r", '', $str);
- $str = str_replace("\n", '', $str);
- return trim($str);
</del><ins>+ return trim(str_replace(array("\r", "\n"), '', $str));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Set the private key file and password to sign the message.
</span><span class="cx"> *
</span><span class="cx"> * @access public
</span><ins>+ * @param $cert_filename
</ins><span class="cx"> * @param string $key_filename Parameter File Name
</span><span class="cx"> * @param string $key_pass Password for private key
</span><span class="cx"> */
</span><span class="lines">@@ -2400,11 +2670,10 @@
</span><span class="cx"> * Set the private key file and password to sign the message.
</span><span class="cx"> *
</span><span class="cx"> * @access public
</span><del>- * @param string $key_filename Parameter File Name
- * @param string $key_pass Password for private key
</del><ins>+ * @param string $txt
+ * @return string
</ins><span class="cx"> */
</span><span class="cx"> public function DKIM_QP($txt) {
</span><del>- $tmp = '';
</del><span class="cx"> $line = '';
</span><span class="cx"> for ($i = 0; $i < strlen($txt); $i++) {
</span><span class="cx"> $ord = ord($txt[$i]);
</span><span class="lines">@@ -2422,6 +2691,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @access public
</span><span class="cx"> * @param string $s Header
</span><ins>+ * @return string
</ins><span class="cx"> */
</span><span class="cx"> public function DKIM_Sign($s) {
</span><span class="cx"> $privKeyStr = file_get_contents($this->DKIM_private);
</span><span class="lines">@@ -2433,6 +2703,7 @@
</span><span class="cx"> if (openssl_sign($s, $signature, $privKey)) {
</span><span class="cx"> return base64_encode($signature);
</span><span class="cx"> }
</span><ins>+ return '';
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -2440,6 +2711,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @access public
</span><span class="cx"> * @param string $s Header
</span><ins>+ * @return string
</ins><span class="cx"> */
</span><span class="cx"> public function DKIM_HeaderC($s) {
</span><span class="cx"> $s = preg_replace("/\r\n\s+/", " ", $s);
</span><span class="lines">@@ -2459,6 +2731,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @access public
</span><span class="cx"> * @param string $body Message Body
</span><ins>+ * @return string
</ins><span class="cx"> */
</span><span class="cx"> public function DKIM_BodyC($body) {
</span><span class="cx"> if ($body == '') return "\r\n";
</span><span class="lines">@@ -2479,6 +2752,7 @@
</span><span class="cx"> * @param string $headers_line Header lines
</span><span class="cx"> * @param string $subject Subject
</span><span class="cx"> * @param string $body Body
</span><ins>+ * @return string
</ins><span class="cx"> */
</span><span class="cx"> public function DKIM_Add($headers_line, $subject, $body) {
</span><span class="cx"> $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
</span><span class="lines">@@ -2487,6 +2761,8 @@
</span><span class="cx"> $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
</span><span class="cx"> $subject_header = "Subject: $subject";
</span><span class="cx"> $headers = explode($this->LE, $headers_line);
</span><ins>+        $from_header = "";
+        $to_header = "";
</ins><span class="cx"> foreach($headers as $header) {
</span><span class="cx"> if (strpos($header, 'From:') === 0) {
</span><span class="cx"> $from_header = $header;
</span><span class="lines">@@ -2512,18 +2788,36 @@
</span><span class="cx"> "\tb=";
</span><span class="cx"> $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs);
</span><span class="cx"> $signed = $this->DKIM_Sign($toSign);
</span><del>- return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n";
</del><ins>+ return "X-PHPMAILER-DKIM: code.google.com/a/apache-extras.org/p/phpmailer/\r\n".$dkimhdrs.$signed."\r\n";
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body) {
- if (!empty($this->action_function) && function_exists($this->action_function)) {
- $params = array($isSent, $to, $cc, $bcc, $subject, $body);
</del><ins>+ /**
+ * Perform callback
+ * @param boolean $isSent
+ * @param string $to
+ * @param string $cc
+ * @param string $bcc
+ * @param string $subject
+ * @param string $body
+ * @param string $from
+ */
+ protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from=null) {
+ if (!empty($this->action_function) && is_callable($this->action_function)) {
+ $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
</ins><span class="cx"> call_user_func_array($this->action_function, $params);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/**
+ * Exception handler for PHPMailer
+ * @package PHPMailer
+ */
</ins><span class="cx"> class phpmailerException extends Exception {
</span><ins>+ /**
+ * Prettify error message output
+ * @return string
+ */
</ins><span class="cx"> public function errorMessage() {
</span><span class="cx"> $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
</span><span class="cx"> return $errorMsg;
</span></span></pre></div>
<a id="trunkwpincludesclasssmtpphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-smtp.php (23521 => 23522)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-smtp.php        2013-02-28 18:27:13 UTC (rev 23521)
+++ trunk/wp-includes/class-smtp.php        2013-02-28 18:33:13 UTC (rev 23522)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /*~ class.smtp.php
</span><span class="cx"> .---------------------------------------------------------------------------.
</span><span class="cx"> | Software: PHPMailer - PHP email class |
</span><del>-| Version: 5.2.1 |
</del><ins>+| Version: 5.2.4 |
</ins><span class="cx"> | Site: https://code.google.com/a/apache-extras.org/p/phpmailer/ |
</span><span class="cx"> | ------------------------------------------------------------------------- |
</span><span class="cx"> | Admin: Jim Jagielski (project admininistrator) |
</span><span class="lines">@@ -32,15 +32,15 @@
</span><span class="cx"> * @author Jim Jagielski
</span><span class="cx"> * @copyright 2010 - 2012 Jim Jagielski
</span><span class="cx"> * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
</span><del>- * @version $Id: class.smtp.php 450 2010-06-23 16:46:33Z coolbru $
</del><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * 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.
- * original author: Chris Ryan
</del><ins>+ * PHP RFC821 SMTP client
+ *
+ * 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.
+ * @author Chris Ryan
+ * @package PHPMailer
</ins><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> class SMTP {
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> public $SMTP_PORT = 25;
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * SMTP reply line ending
</del><ins>+ * SMTP reply line ending (don't change)
</ins><span class="cx"> * @var string
</span><span class="cx"> */
</span><span class="cx"> public $CRLF = "\r\n";
</span><span class="lines">@@ -63,29 +63,69 @@
</span><span class="cx"> public $do_debug; // the level of debug to perform
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Sets the function/method to use for debugging output.
+ * Right now we only honor "echo" or "error_log"
+ * @var string
+ */
+ public $Debugoutput = "echo";
+
+ /**
</ins><span class="cx"> * Sets VERP use on/off (default is off)
</span><span class="cx"> * @var bool
</span><span class="cx"> */
</span><span class="cx"> public $do_verp = false;
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Sets the SMTP timeout value for reads, in seconds
+ * @var int
+ */
+ public $Timeout = 15;
+
+ /**
+ * Sets the SMTP timelimit value for reads, in seconds
+ * @var int
+ */
+ public $Timelimit = 30;
+
+ /**
</ins><span class="cx"> * Sets the SMTP PHPMailer Version number
</span><span class="cx"> * @var string
</span><span class="cx"> */
</span><del>- public $Version = '5.2.1';
</del><ins>+ public $Version = '5.2.4';
</ins><span class="cx">
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx"> // PROPERTIES, PRIVATE AND PROTECTED
</span><span class="cx"> /////////////////////////////////////////////////
</span><span class="cx">
</span><del>- private $smtp_conn; // the socket to the server
- private $error; // error if any on the last call
- private $helo_rply; // the reply the server sent to us for HELO
</del><ins>+ /**
+ * @var resource The socket to the server
+ */
+ private $smtp_conn;
+ /**
+ * @var string Error message, if any, for the last call
+ */
+ private $error;
+ /**
+ * @var string The reply the server sent to us for HELO
+ */
+ private $helo_rply;
</ins><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Outputs debugging info via user-defined method
+ * @param string $str
+ */
+ private function edebug($str) {
+ if ($this->Debugoutput == "error_log") {
+ error_log($str);
+ } else {
+ echo $str;
+ }
+ }
+
+ /**
</ins><span class="cx"> * Initialize the class so that the data is in a known state.
</span><span class="cx"> * @access public
</span><del>- * @return void
</del><ins>+ * @return SMTP
</ins><span class="cx"> */
</span><span class="cx"> public function __construct() {
</span><span class="cx"> $this->smtp_conn = 0;
</span><span class="lines">@@ -110,6 +150,9 @@
</span><span class="cx"> * SMTP CODE SUCCESS: 220
</span><span class="cx"> * SMTP CODE FAILURE: 421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $host
+ * @param int $port
+ * @param int $tval
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Connect($host, $port = 0, $tval = 30) {
</span><span class="lines">@@ -139,21 +182,26 @@
</span><span class="cx"> "errno" => $errno,
</span><span class="cx"> "errstr" => $errstr);
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // SMTP server can take longer to respond, give longer timeout for first read
</span><span class="cx"> // Windows does not have support for this timeout function
</span><del>- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
</del><ins>+ if(substr(PHP_OS, 0, 3) != "WIN") {
+ $max = ini_get('max_execution_time');
+ if ($max != 0 && $tval > $max) { // don't bother if unlimited
+ @set_time_limit($tval);
+ }
+ stream_set_timeout($this->smtp_conn, $tval, 0);
+ }
</ins><span class="cx">
</span><span class="cx"> // get any announcement
</span><span class="cx"> $announce = $this->get_lines();
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="lines">@@ -182,7 +230,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 220) {
</span><span class="lines">@@ -191,7 +239,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -208,60 +256,164 @@
</span><span class="cx"> * Performs SMTP authentication. Must be run after running the
</span><span class="cx"> * Hello() method. Returns true if successfully authenticated.
</span><span class="cx"> * @access public
</span><ins>+ * @param string $username
+ * @param string $password
+ * @param string $authtype
+ * @param string $realm
+ * @param string $workstation
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><del>- public 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 . '<br />';
- }
- return false;
</del><ins>+ public function Authenticate($username, $password, $authtype='LOGIN', $realm='', $workstation='') {
+ if (empty($authtype)) {
+ $authtype = 'LOGIN';
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- // Send encoded username
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
</del><ins>+ switch ($authtype) {
+ case 'PLAIN':
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH PLAIN" . $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) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
+ }
+ return false;
+ }
+ // Send encoded username and password
+ fputs($this->smtp_conn, base64_encode("\0".$username."\0".$password) . $this->CRLF);
</ins><span class="cx">
</span><del>- $rply = $this->get_lines();
- $code = substr($rply,0,3);
</del><ins>+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 235) {
+ $this->error =
+ array("error" => "Authentication not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
+ }
+ return false;
+ }
+ break;
+ case 'LOGIN':
+ // 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) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
+ }
+ return false;
+ }
+
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+ $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) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
+ }
+ return false;
+ }
+
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ 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) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
+ }
+ return false;
+ }
+ break;
+ case 'NTLM':
+ /*
+ * ntlm_sasl_client.php
+ ** Bundled with Permission
+ **
+ ** How to telnet in windows: http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
+ ** PROTOCOL Documentation http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
+ */
+ require_once('ntlm_sasl_client.php');
+ $temp = new stdClass();
+ $ntlm_client = new ntlm_sasl_client_class;
+ if(! $ntlm_client->Initialize($temp)){//let's test if every function its available
+ $this->error = array("error" => $temp->error);
+ if($this->do_debug >= 1) {
+ $this->edebug("You need to enable some modules in your php.ini file: " . $this->error["error"] . $this->CRLF);
+ }
+ return false;
+ }
+ $msg1 = $ntlm_client->TypeMsg1($realm, $workstation);//msg1
+
+ fputs($this->smtp_conn,"AUTH NTLM " . base64_encode($msg1) . $this->CRLF);
</ins><span class="cx">
</span><del>- 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 . '<br />';
- }
- return false;
- }
</del><ins>+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
</ins><span class="cx">
</span><del>- // Send encoded password
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
</del><ins>+ 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) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
+ }
+ return false;
+ }
+
+ $challange = substr($rply,3);//though 0 based, there is a white space after the 3 digit number....//msg2
+ $challange = base64_decode($challange);
+ $ntlm_res = $ntlm_client->NTLMResponse(substr($challange,24,8),$password);
+ $msg3 = $ntlm_client->TypeMsg3($ntlm_res,$username,$realm,$workstation);//msg3
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($msg3) . $this->CRLF);
</ins><span class="cx">
</span><del>- $rply = $this->get_lines();
- $code = substr($rply,0,3);
</del><ins>+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
</ins><span class="cx">
</span><del>- 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 . '<br />';
- }
- return false;
</del><ins>+ if($code != 235) {
+ $this->error =
+ array("error" => "Could not authenticate",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF);
+ }
+ return false;
+ }
+ break;
</ins><span class="cx"> }
</span><del>-
</del><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -276,7 +428,7 @@
</span><span class="cx"> if($sock_status["eof"]) {
</span><span class="cx"> // the socket is valid but we are not connected
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
</del><ins>+ $this->edebug("SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected");
</ins><span class="cx"> }
</span><span class="cx"> $this->Close();
</span><span class="cx"> return false;
</span><span class="lines">@@ -324,6 +476,7 @@
</span><span class="cx"> * SMTP CODE FAILURE: 451,554
</span><span class="cx"> * SMTP CODE ERROR : 500,501,503,421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $msg_data
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Data($msg_data) {
</span><span class="lines">@@ -341,7 +494,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 354) {
</span><span class="lines">@@ -350,7 +503,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -435,7 +588,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250) {
</span><span class="lines">@@ -444,7 +597,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -461,6 +614,7 @@
</span><span class="cx"> * SMTP CODE SUCCESS: 250
</span><span class="cx"> * SMTP CODE ERROR : 500, 501, 504, 421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $host
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Hello($host = '') {
</span><span class="lines">@@ -491,6 +645,8 @@
</span><span class="cx"> /**
</span><span class="cx"> * Sends a HELO/EHLO command.
</span><span class="cx"> * @access private
</span><ins>+ * @param string $hello
+ * @param string $host
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> private function SendHello($hello, $host) {
</span><span class="lines">@@ -500,7 +656,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250) {
</span><span class="lines">@@ -509,7 +665,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -531,6 +687,7 @@
</span><span class="cx"> * SMTP CODE SUCCESS: 552,451,452
</span><span class="cx"> * SMTP CODE SUCCESS: 500,501,421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $from
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Mail($from) {
</span><span class="lines">@@ -542,14 +699,14 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- $useVerp = ($this->do_verp ? "XVERP" : "");
</del><ins>+ $useVerp = ($this->do_verp ? " XVERP" : "");
</ins><span class="cx"> fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
</span><span class="cx">
</span><span class="cx"> $rply = $this->get_lines();
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250) {
</span><span class="lines">@@ -558,7 +715,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -574,6 +731,7 @@
</span><span class="cx"> * SMTP CODE SUCCESS: 221
</span><span class="cx"> * SMTP CODE ERROR : 500
</span><span class="cx"> * @access public
</span><ins>+ * @param bool $close_on_error
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Quit($close_on_error = true) {
</span><span class="lines">@@ -592,7 +750,7 @@
</span><span class="cx"> $byemsg = $this->get_lines();
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $rval = true;
</span><span class="lines">@@ -606,7 +764,7 @@
</span><span class="cx"> "smtp_rply" => substr($byemsg,4));
</span><span class="cx"> $rval = false;
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -627,6 +785,7 @@
</span><span class="cx"> * SMTP CODE FAILURE: 550,551,552,553,450,451,452
</span><span class="cx"> * SMTP CODE ERROR : 500,501,503,421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $to
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function Recipient($to) {
</span><span class="lines">@@ -644,7 +803,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250 && $code != 251) {
</span><span class="lines">@@ -653,7 +812,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -687,7 +846,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250) {
</span><span class="lines">@@ -696,7 +855,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -718,6 +877,7 @@
</span><span class="cx"> * SMTP CODE SUCCESS: 552,451,452
</span><span class="cx"> * SMTP CODE SUCCESS: 500,501,502,421
</span><span class="cx"> * @access public
</span><ins>+ * @param string $from
</ins><span class="cx"> * @return bool
</span><span class="cx"> */
</span><span class="cx"> public function SendAndMail($from) {
</span><span class="lines">@@ -735,7 +895,7 @@
</span><span class="cx"> $code = substr($rply,0,3);
</span><span class="cx">
</span><span class="cx"> if($this->do_debug >= 2) {
</span><del>- echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if($code != 250) {
</span><span class="lines">@@ -744,7 +904,7 @@
</span><span class="cx"> "smtp_code" => $code,
</span><span class="cx"> "smtp_msg" => substr($rply,4));
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -768,7 +928,7 @@
</span><span class="cx"> $this->error = array("error" => "This method, TURN, of the SMTP ".
</span><span class="cx"> "is not implemented");
</span><span class="cx"> if($this->do_debug >= 1) {
</span><del>- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -797,22 +957,47 @@
</span><span class="cx"> */
</span><span class="cx"> private function get_lines() {
</span><span class="cx"> $data = "";
</span><del>- while(!feof($this->smtp_conn)) {
</del><ins>+ $endtime = 0;
+ /* If for some reason the fp is bad, don't inf loop */
+ if (!is_resource($this->smtp_conn)) {
+ return $data;
+ }
+ stream_set_timeout($this->smtp_conn, $this->Timeout);
+ if ($this->Timelimit > 0) {
+ $endtime = time() + $this->Timelimit;
+ }
+ while(is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
</ins><span class="cx"> $str = @fgets($this->smtp_conn,515);
</span><span class="cx"> if($this->do_debug >= 4) {
</span><del>- echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
- echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />');
+ $this->edebug("SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> $data .= $str;
</span><span class="cx"> if($this->do_debug >= 4) {
</span><del>- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
</del><ins>+ $this->edebug("SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />');
</ins><span class="cx"> }
</span><span class="cx"> // if 4th character is a space, we are done reading, break the loop
</span><span class="cx"> if(substr($str,3,1) == " ") { break; }
</span><ins>+ // Timed-out? Log and break
+ $info = stream_get_meta_data($this->smtp_conn);
+ if ($info['timed_out']) {
+ if($this->do_debug >= 4) {
+ $this->edebug("SMTP -> get_lines(): timed-out (" . $this->Timeout . " seconds) <br />");
+ }
+ break;
+ }
+ // Now check if reads took too long
+ if ($endtime) {
+ if (time() > $endtime) {
+ if($this->do_debug >= 4) {
+ $this->edebug("SMTP -> get_lines(): timelimit reached (" . $this->Timelimit . " seconds) <br />");
+ }
+ break;
+ }
+ }
</ins><span class="cx"> }
</span><span class="cx"> return $data;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>