<!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>[39729] branches/3.9: Mail: Upgrade PHPMailer to 5.2.21.</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/39729">39729</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/39729","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-01-06 06:03:31 +0000 (Fri, 06 Jan 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Mail: Upgrade PHPMailer to 5.2.21.
Merges <a href="https://core.trac.wordpress.org/changeset/39645">[39645]</a>, <a href="https://core.trac.wordpress.org/changeset/36083">[36083]</a>, <a href="https://core.trac.wordpress.org/changeset/33142">[33142]</a>, <a href="https://core.trac.wordpress.org/changeset/33124">[33124]</a>, <a href="https://core.trac.wordpress.org/changeset/29783">[29783]</a> to the 3.9 branch.
See <a href="https://core.trac.wordpress.org/ticket/37210">#37210</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches39srcwpincludesclassphpmailerphp">branches/3.9/src/wp-includes/class-phpmailer.php</a></li>
<li><a href="#branches39srcwpincludesclasssmtpphp">branches/3.9/src/wp-includes/class-smtp.php</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches39">branches/3.9/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/3.9
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/3.9 2017-01-06 05:56:45 UTC (rev 39728)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/3.9 2017-01-06 06:03:31 UTC (rev 39729)
</ins><a id="branches39"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/3.9</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/4.2:33499
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/4.6:38615
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:18512,28158,28161,28163,28165-28166,28168-28169,28171-28174,28176-28187,28189-28191,28193-28195,28203,28219,28223,28266,28269,28275-28276,28280,28284,29327,29377-29378,29381-29382,29397,29404,29631,30412,30417,30422,30425,30430,30435,30438,30443,30458,30466,36435,37651,38524,39659
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:18512,28158,28161,28163,28165-28166,28168-28169,28171-28174,28176-28187,28189-28191,28193-28195,28203,28219,28223,28266,28269,28275-28276,28280,28284,29327,29377-29378,29381-29382,29397,29404,29631,29783,30412,30417,30422,30425,30430,30435,30438,30443,30458,30466,33124,33142,36083,36435,37651,38524,39645,39659
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches39srcwpincludesclassphpmailerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/3.9/src/wp-includes/class-phpmailer.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/3.9/src/wp-includes/class-phpmailer.php 2017-01-06 05:56:45 UTC (rev 39728)
+++ branches/3.9/src/wp-includes/class-phpmailer.php 2017-01-06 06:03:31 UTC (rev 39729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,15 +1,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * PHPMailer - PHP email creation and transport class.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * PHP Version 5.0.0
- * Version 5.2.7
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * PHP Version 5
</ins><span class="cx" style="display: block; padding: 0 10px"> * @package PHPMailer
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @link https://github.com/PHPMailer/PHPMailer/
- * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
</ins><span class="cx" style="display: block; padding: 0 10px"> * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
</span><span class="cx" style="display: block; padding: 0 10px"> * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
</span><span class="cx" style="display: block; padding: 0 10px"> * @author Brent R. Matzelle (original founder)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @copyright 2013 Marcus Bointon
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @copyright 2012 - 2014 Marcus Bointon
</ins><span class="cx" style="display: block; padding: 0 10px"> * @copyright 2010 - 2012 Jim Jagielski
</span><span class="cx" style="display: block; padding: 0 10px"> * @copyright 2004 - 2009 Andy Prevost
</span><span class="cx" style="display: block; padding: 0 10px"> * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,98 +17,94 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-if (version_compare(PHP_VERSION, '5.0.0', '<')) {
- exit("Sorry, PHPMailer will only run on PHP version 5 or greater!\n");
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * PHPMailer - PHP email creation and transport class.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * PHP Version 5.0.0
</del><span class="cx" style="display: block; padding: 0 10px"> * @package PHPMailer
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
</ins><span class="cx" style="display: block; padding: 0 10px"> * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
</span><span class="cx" style="display: block; padding: 0 10px"> * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
</span><span class="cx" style="display: block; padding: 0 10px"> * @author Brent R. Matzelle (original founder)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @copyright 2013 Marcus Bointon
- * @copyright 2010 - 2012 Jim Jagielski
- * @copyright 2004 - 2009 Andy Prevost
</del><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class PHPMailer
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The PHPMailer Version number.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Version = '5.2.7';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Version = '5.2.21';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Email priority.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Options: 1 = High, 3 = Normal, 5 = low.
- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Options: null (default), 1 = High, 3 = Normal, 5 = low.
+ * When null, the header is not set at all.
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Priority = 3;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Priority = null;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The character set of the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $CharSet = 'iso-8859-1';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The MIME Content-type of the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $ContentType = 'text/plain';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The message encoding.
</span><span class="cx" style="display: block; padding: 0 10px"> * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Encoding = '8bit';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Holds the most recent mailer error message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $ErrorInfo = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The From email address for the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $From = 'root@localhost';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The From name of the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $FromName = 'Root User';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The Sender email (Return-Path) of the message.
</span><span class="cx" style="display: block; padding: 0 10px"> * If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Sender = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The Return-Path of the message.
</span><span class="cx" style="display: block; padding: 0 10px"> * If empty, it will be set to either From or Sender.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
+ * @deprecated Email senders should never set a return-path header;
+ * it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
+ * @link https://tools.ietf.org/html/rfc5321#section-4.4 RFC5321 reference
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $ReturnPath = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The Subject of the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Subject = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * An HTML or plain text message body.
</span><span class="cx" style="display: block; padding: 0 10px"> * If HTML then call isHTML(true).
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Body = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,7 +113,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * This body can be read by mail clients that do not have HTML email
</span><span class="cx" style="display: block; padding: 0 10px"> * capability such as mutt & Eudora.
</span><span class="cx" style="display: block; padding: 0 10px"> * Clients that can read HTML will view the normal Body.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $AltBody = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,91 +123,95 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
</span><span class="cx" style="display: block; padding: 0 10px"> * @link http://sprain.ch/blog/downloads/php-class-easypeasyics-create-ical-files-with-php/
</span><span class="cx" style="display: block; padding: 0 10px"> * @link http://kigkonsult.se/iCalcreator/
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Ical = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The complete compiled MIME message body.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $MIMEBody = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The complete compiled MIME message headers.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $MIMEHeader = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Extra headers that createHeader() doesn't fold in.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $mailHeader = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Word-wrap the message body to this number of chars.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $WordWrap = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Which method to use to send mail.
</span><span class="cx" style="display: block; padding: 0 10px"> * Options: "mail", "sendmail", or "smtp".
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Mailer = 'mail';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The path to the sendmail program.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Sendmail = '/usr/sbin/sendmail';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether mail() uses a fully sendmail-compatible MTA.
</span><span class="cx" style="display: block; padding: 0 10px"> * One which supports sendmail's "-oi -f" options.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $UseSendmailOptions = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Path to PHPMailer plugins.
</span><span class="cx" style="display: block; padding: 0 10px"> * Useful if the SMTP class is not in the PHP include path.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @deprecated Should not be needed now there is an autoloader.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $PluginDir = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The email address that a reading confirmation should be sent to.
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The email address that a reading confirmation should be sent to, also known as read receipt.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $ConfirmReadingTo = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The hostname to use in Message-Id and Received headers
- * and as default HELO string.
- * If empty, the value returned
- * by SERVER_NAME is used or 'localhost.localdomain'.
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The hostname to use in the Message-ID header and as default HELO string.
+ * If empty, PHPMailer attempts to find one with, in order,
+ * $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
+ * 'localhost.localdomain'.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Hostname = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * An ID to be used in the Message-Id header.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * An ID to be used in the Message-ID header.
</ins><span class="cx" style="display: block; padding: 0 10px"> * If empty, a unique id will be generated.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * You can set your own, but it must be in the format "<id@domain>",
+ * as defined in RFC5322 section 3.6.4 or it will be ignored.
+ * @see https://tools.ietf.org/html/rfc5322#section-3.6.4
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $MessageID = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The message Date to be used in the Date header.
</span><span class="cx" style="display: block; padding: 0 10px"> * If empty, the current date will be added.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $MessageDate = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,130 +221,164 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * You can also specify a different port
</span><span class="cx" style="display: block; padding: 0 10px"> * for each host by using this format: [hostname:port]
</span><span class="cx" style="display: block; padding: 0 10px"> * (e.g. "smtp1.example.com:25;smtp2.example.com").
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * You can also specify encryption type, for example:
+ * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
</ins><span class="cx" style="display: block; padding: 0 10px"> * Hosts will be tried in order.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Host = 'localhost';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The default SMTP server port.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type int
- * @Todo Why is this needed when the SMTP class takes care of it?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var integer
+ * @TODO Why is this needed when the SMTP class takes care of it?
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Port = 25;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The SMTP HELO of the message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Default is $Hostname.
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
+ * one with the same method described above for $Hostname.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$Hostname
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Helo = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The secure connection prefix.
- * Options: "", "ssl" or "tls"
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * What kind of encryption to use on the SMTP connection.
+ * Options: '', 'ssl' or 'tls'
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SMTPSecure = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Whether to enable TLS encryption automatically if a server supports it,
+ * even if `SMTPSecure` is not set to 'tls'.
+ * Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
+ * @var boolean
+ */
+ public $SMTPAutoTLS = true;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Whether to use SMTP authentication.
</span><span class="cx" style="display: block; padding: 0 10px"> * Uses the Username and Password properties.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$Username
</span><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$Password
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SMTPAuth = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Options array passed to stream_context_create when connecting via SMTP.
+ * @var array
+ */
+ public $SMTPOptions = array();
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * SMTP username.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Username = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP password.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Password = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP auth type.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Options are CRAM-MD5, LOGIN, PLAIN, attempted in that order if not specified
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $AuthType = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP realm.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used for NTLM auth
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Realm = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP workstation.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used for NTLM auth
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Workstation = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The SMTP server timeout in seconds.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Timeout = 10;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Timeout = 300;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP class debug output mode.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Options: 0 = off, 1 = commands, 2 = commands and data
- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Debug output level.
+ * Options:
+ * * `0` No output
+ * * `1` Commands
+ * * `2` Data and commands
+ * * `3` As 2 plus connection status
+ * * `4` Low-level data output
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see SMTP::$do_debug
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SMTPDebug = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The function/method to use for debugging output.
- * Options: "echo" or "error_log"
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * How to handle debug output.
+ * Options:
+ * * `echo` Output plain-text as-is, appropriate for CLI
+ * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
+ * * `error_log` Output to error log as configured in php.ini
+ *
+ * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
+ * <code>
+ * $mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
+ * </code>
+ * @var string|callable
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see SMTP::$Debugoutput
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Debugoutput = "echo";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Debugoutput = 'echo';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to keep SMTP connection open after each message.
</span><span class="cx" style="display: block; padding: 0 10px"> * If this is set to true then to close the connection
</span><span class="cx" style="display: block; padding: 0 10px"> * requires an explicit call to smtpClose().
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SMTPKeepAlive = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to split multiple to addresses into multiple messages
</span><span class="cx" style="display: block; padding: 0 10px"> * or send them all in one message.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Only supported in `mail` and `sendmail` transports, not in SMTP.
+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SingleTo = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Storage for addresses when SingleTo is enabled.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
- * @todo This should really not be public
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
+ * @TODO This should really not be public
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SingleToArray = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to generate VERP addresses on send.
</span><span class="cx" style="display: block; padding: 0 10px"> * Only applicable when sending via SMTP.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @link https://en.wikipedia.org/wiki/Variable_envelope_return_path
+ * @link http://www.postfix.org/VERP_README.html Postfix VERP info
+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $do_verp = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to allow sending messages with an empty body.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $AllowEmpty = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -353,223 +386,279 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * The default line ending.
</span><span class="cx" style="display: block; padding: 0 10px"> * @note The default remains "\n". We force CRLF where we know
</span><span class="cx" style="display: block; padding: 0 10px"> * it must be used via self::CRLF.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $LE = "\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * DKIM selector.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $DKIM_selector = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * DKIM Identity.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Usually the email address used as the source of the email
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Usually the email address used as the source of the email.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $DKIM_identity = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * DKIM passphrase.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used if your key is encrypted.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $DKIM_passphrase = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * DKIM signing domain name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @example 'example.com'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $DKIM_domain = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * DKIM private key file path.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $DKIM_private = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * DKIM private key string.
+ * If set, takes precedence over `$DKIM_private`.
+ * @var string
+ */
+ public $DKIM_private_string = '';
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Callback Action function name.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The function that handles the result of the send email action.
</span><span class="cx" style="display: block; padding: 0 10px"> * It is called out by send() for each email sent.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * 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.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Value can be any php callable: http://www.php.net/is_callable
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Parameters:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * bool $result result of the send action
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * boolean $result result of the send action
</ins><span class="cx" style="display: block; padding: 0 10px"> * string $to email address of the recipient
</span><span class="cx" style="display: block; padding: 0 10px"> * string $cc cc email addresses
</span><span class="cx" style="display: block; padding: 0 10px"> * string $bcc bcc email addresses
</span><span class="cx" style="display: block; padding: 0 10px"> * string $subject the subject
</span><span class="cx" style="display: block; padding: 0 10px"> * string $body the email body
</span><span class="cx" style="display: block; padding: 0 10px"> * string $from email address of sender
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $action_function = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * What to use in the X-Mailer header.
- * Options: null for default, whitespace for none, or a string to use
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * What to put in the X-Mailer header.
+ * Options: An empty string for PHPMailer default, whitespace for none, or a string to use
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $XMailer = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Which validator to use by default when validating email addresses.
+ * May be a callable to inject your own validator, but there are several built-in validators.
+ * @see PHPMailer::validateAddress()
+ * @var string|callable
+ * @static
+ */
+ public static $validator = 'auto';
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * An instance of the SMTP sender class.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type SMTP
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var SMTP
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $smtp = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The array of 'to' addresses.
- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The array of 'to' names and addresses.
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $to = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The array of 'cc' addresses.
- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The array of 'cc' names and addresses.
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $cc = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The array of 'bcc' addresses.
- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The array of 'bcc' names and addresses.
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $bcc = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The array of reply-to names and addresses.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $ReplyTo = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * An array of all kinds of addresses.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Includes all of $to, $cc, $bcc, $replyto
- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Includes all of $to, $cc, $bcc
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $all_recipients = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * An array of names and addresses queued for validation.
+ * In send(), valid and non duplicate entries are moved to $all_recipients
+ * and one of $to, $cc, or $bcc.
+ * This array is used only for addresses with IDN.
+ * @var array
+ * @access protected
+ * @see PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
+ * @see PHPMailer::$all_recipients
+ */
+ protected $RecipientsQueue = array();
+
+ /**
+ * An array of reply-to names and addresses queued for validation.
+ * In send(), valid and non duplicate entries are moved to $ReplyTo.
+ * This array is used only for addresses with IDN.
+ * @var array
+ * @access protected
+ * @see PHPMailer::$ReplyTo
+ */
+ protected $ReplyToQueue = array();
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The array of attachments.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $attachment = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The array of custom headers.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $CustomHeader = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The most recent Message-ID (including angular brackets).
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $lastMessageID = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The message's MIME type.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $message_type = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The array of MIME boundary strings.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $boundary = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The array of available languages.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $language = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The number of errors encountered.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type integer
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $error_count = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The S/MIME certificate file path.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $sign_cert_file = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The S/MIME key file path.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $sign_key_file = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The optional S/MIME extra certificates ("CA Chain") file path.
+ * @var string
+ * @access protected
+ */
+ protected $sign_extracerts_file = '';
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The S/MIME password for the key.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used only if the key is encrypted.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $sign_key_pass = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to throw exceptions for errors.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $exceptions = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Error severity: message only, continue processing
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Unique ID used for message ID and boundaries.
+ * @var string
+ * @access protected
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $uniqueid = '';
+
+ /**
+ * Error severity: message only, continue processing.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> const STOP_MESSAGE = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Error severity: message, likely ok to continue processing
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Error severity: message, likely ok to continue processing.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> const STOP_CONTINUE = 1;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Error severity: message, plus full stop, critical error reached
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Error severity: message, plus full stop, critical error reached.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> const STOP_CRITICAL = 2;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * SMTP RFC standard line ending
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * SMTP RFC standard line ending.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> const CRLF = "\r\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Constructor
- * @param bool $exceptions Should we throw external exceptions?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The maximum line length allowed by RFC 2822 section 2.1.1
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function __construct($exceptions = false)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const MAX_LINE_LENGTH = 998;
+
+ /**
+ * Constructor.
+ * @param boolean $exceptions Should we throw external exceptions?
+ */
+ public function __construct($exceptions = null)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->exceptions = ($exceptions == true);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($exceptions !== null) {
+ $this->exceptions = (boolean)$exceptions;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -577,9 +666,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __destruct()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->Mailer == 'smtp') { //close any open SMTP connection nicely
- $this->smtpClose();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Close any open SMTP connection nicely
+ $this->smtpClose();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -593,53 +681,77 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $header Additional Header(s)
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $params Params
</span><span class="cx" style="display: block; padding: 0 10px"> * @access private
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private function mailPassthru($to, $subject, $body, $header, $params)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (ini_get('safe_mode') || !($this->UseSendmailOptions)) {
- $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Check overloading of mail function to avoid double-encoding
+ if (ini_get('mbstring.func_overload') & 1) {
+ $subject = $this->secureHeader($subject);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $rt = @mail($to, $this->encodeHeader($this->secureHeader($subject)), $body, $header, $params);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $subject = $this->encodeHeader($this->secureHeader($subject));
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $rt;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ //Can't use additional_parameters in safe_mode, calling mail() with null params breaks
+ //@link http://php.net/manual/en/function.mail.php
+ if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) {
+ $result = @mail($to, $subject, $body, $header);
+ } else {
+ $result = @mail($to, $subject, $body, $header, $params);
+ }
+ return $result;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Output debugging info via user-defined method.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Only if debug output is enabled.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$Debugoutput
</span><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$SMTPDebug
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $str
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function edebug($str)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!$this->SMTPDebug) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->SMTPDebug <= 0) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Avoid clash with built-in function names
+ if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
+ call_user_func($this->Debugoutput, $str, $this->SMTPDebug);
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> switch ($this->Debugoutput) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'error_log':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Don't output, just log
</ins><span class="cx" style="display: block; padding: 0 10px"> error_log($str);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'html':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Cleans up output a bit for a better looking display that's HTML-safe
- echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Cleans up output a bit for a better looking, HTML-safe output
+ echo htmlentities(
+ preg_replace('/[\r\n]+/', '', $str),
+ ENT_QUOTES,
+ 'UTF-8'
+ )
+ . "<br>\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'echo':
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Just echoes exactly what was received
- echo $str;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Normalize line breaks
+ $str = preg_replace('/\r\n?/ms', "\n", $str);
+ echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
+ "\n",
+ "\n \t ",
+ trim($str)
+ ) . "\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Sets message type to HTML or plain.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $ishtml True for HTML mode.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $isHtml True for HTML mode.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function isHTML($ishtml = true)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function isHTML($isHtml = true)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($ishtml) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($isHtml) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->ContentType = 'text/html';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ContentType = 'text/plain';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -670,8 +782,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function isSendmail()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
- $this->Sendmail = '/var/qmail/bin/sendmail';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ini_sendmail_path = ini_get('sendmail_path');
+
+ if (!stristr($ini_sendmail_path, 'sendmail')) {
+ $this->Sendmail = '/usr/sbin/sendmail';
+ } else {
+ $this->Sendmail = $ini_sendmail_path;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->Mailer = 'sendmail';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -682,90 +798,140 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function isQmail()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (stristr(ini_get('sendmail_path'), 'qmail')) {
- $this->Sendmail = '/var/qmail/bin/sendmail';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ini_sendmail_path = ini_get('sendmail_path');
+
+ if (!stristr($ini_sendmail_path, 'qmail')) {
+ $this->Sendmail = '/var/qmail/bin/qmail-inject';
+ } else {
+ $this->Sendmail = $ini_sendmail_path;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->Mailer = 'sendmail';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->Mailer = 'qmail';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a "To" address.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $address
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $address The email address to send to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true on success, false if address already used
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean true on success, false if address already used or invalid in some way
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addAddress($address, $name = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->addAnAddress('to', $address, $name);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->addOrEnqueueAnAddress('to', $address, $name);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a "CC" address.
</span><span class="cx" style="display: block; padding: 0 10px"> * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $address
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $address The email address to send to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true on success, false if address already used
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean true on success, false if address already used or invalid in some way
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addCC($address, $name = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->addAnAddress('cc', $address, $name);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->addOrEnqueueAnAddress('cc', $address, $name);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a "BCC" address.
</span><span class="cx" style="display: block; padding: 0 10px"> * @note: This function works with the SMTP mailer on win32, not with the "mail" mailer.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $address
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $address The email address to send to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true on success, false if address already used
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean true on success, false if address already used or invalid in some way
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addBCC($address, $name = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->addAnAddress('bcc', $address, $name);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->addOrEnqueueAnAddress('bcc', $address, $name);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Add a "Reply-to" address.
- * @param string $address
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Add a "Reply-To" address.
+ * @param string $address The email address to reply to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean true on success, false if address already used or invalid in some way
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addReplyTo($address, $name = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->addAnAddress('Reply-To', $address, $name);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->addOrEnqueueAnAddress('Reply-To', $address, $name);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Add an address to one of the recipient arrays.
- * Addresses that have been added already return false, but do not throw exceptions
- * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
- * @param string $address The email address to send to
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Add an address to one of the recipient arrays or to the ReplyTo array. Because PHPMailer
+ * can't validate addresses with an IDN without knowing the PHPMailer::$CharSet (that can still
+ * be modified after calling this function), addition of such addresses is delayed until send().
+ * Addresses that have been added already return false, but do not throw exceptions.
+ * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
+ * @param string $address The email address to send, resp. to reply to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true on success, false if address already used or invalid in some way
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean true on success, false if address already used or invalid in some way
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function addOrEnqueueAnAddress($kind, $address, $name)
+ {
+ $address = trim($address);
+ $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
+ if (($pos = strrpos($address, '@')) === false) {
+ // At-sign is misssing.
+ $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
+ $this->setError($error_message);
+ $this->edebug($error_message);
+ if ($this->exceptions) {
+ throw new phpmailerException($error_message);
+ }
+ return false;
+ }
+ $params = array($kind, $address, $name);
+ // Enqueue addresses with IDN until we know the PHPMailer::$CharSet.
+ if ($this->has8bitChars(substr($address, ++$pos)) and $this->idnSupported()) {
+ if ($kind != 'Reply-To') {
+ if (!array_key_exists($address, $this->RecipientsQueue)) {
+ $this->RecipientsQueue[$address] = $params;
+ return true;
+ }
+ } else {
+ if (!array_key_exists($address, $this->ReplyToQueue)) {
+ $this->ReplyToQueue[$address] = $params;
+ return true;
+ }
+ }
+ return false;
+ }
+ // Immediately add standard addresses without IDN.
+ return call_user_func_array(array($this, 'addAnAddress'), $params);
+ }
+
+ /**
+ * Add an address to one of the recipient arrays or to the ReplyTo array.
+ * Addresses that have been added already return false, but do not throw exceptions.
+ * @param string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
+ * @param string $address The email address to send, resp. to reply to
+ * @param string $name
+ * @throws phpmailerException
+ * @return boolean true on success, false if address already used or invalid in some way
+ * @access protected
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> protected function addAnAddress($kind, $address, $name = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
- $this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!in_array($kind, array('to', 'cc', 'bcc', 'Reply-To'))) {
+ $error_message = $this->lang('Invalid recipient kind: ') . $kind;
+ $this->setError($error_message);
+ $this->edebug($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new phpmailerException('Invalid recipient array: ' . $kind);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new phpmailerException($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
</del><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $address = trim($address);
- $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
</del><span class="cx" style="display: block; padding: 0 10px"> if (!$this->validateAddress($address)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->setError($this->lang('invalid_address') . ': ' . $address);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $error_message = $this->lang('invalid_address') . " (addAnAddress $kind): $address";
+ $this->setError($error_message);
+ $this->edebug($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new phpmailerException($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->edebug($this->lang('invalid_address') . ': ' . $address);
</del><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ($kind != 'Reply-To') {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!isset($this->all_recipients[strtolower($address)])) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!array_key_exists(strtolower($address), $this->all_recipients)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> array_push($this->$kind, array($address, $name));
</span><span class="cx" style="display: block; padding: 0 10px"> $this->all_recipients[strtolower($address)] = true;
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -780,23 +946,82 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Parse and validate a string containing one or more RFC822-style comma-separated email addresses
+ * of the form "display name <address>" into an array of name/address pairs.
+ * Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available.
+ * Note that quotes in the name part are removed.
+ * @param string $addrstr The address list string
+ * @param bool $useimap Whether to use the IMAP extension to parse the list
+ * @return array
+ * @link http://www.andrew.cmu.edu/user/agreen1/testing/mrbs/web/Mail/RFC822.php A more careful implementation
+ */
+ public function parseAddresses($addrstr, $useimap = true)
+ {
+ $addresses = array();
+ if ($useimap and function_exists('imap_rfc822_parse_adrlist')) {
+ //Use this built-in parser if it's available
+ $list = imap_rfc822_parse_adrlist($addrstr, '');
+ foreach ($list as $address) {
+ if ($address->host != '.SYNTAX-ERROR.') {
+ if ($this->validateAddress($address->mailbox . '@' . $address->host)) {
+ $addresses[] = array(
+ 'name' => (property_exists($address, 'personal') ? $address->personal : ''),
+ 'address' => $address->mailbox . '@' . $address->host
+ );
+ }
+ }
+ }
+ } else {
+ //Use this simpler parser
+ $list = explode(',', $addrstr);
+ foreach ($list as $address) {
+ $address = trim($address);
+ //Is there a separate name part?
+ if (strpos($address, '<') === false) {
+ //No separate name, just use the whole thing
+ if ($this->validateAddress($address)) {
+ $addresses[] = array(
+ 'name' => '',
+ 'address' => $address
+ );
+ }
+ } else {
+ list($name, $email) = explode('<', $address);
+ $email = trim(str_replace('>', '', $email));
+ if ($this->validateAddress($email)) {
+ $addresses[] = array(
+ 'name' => trim(str_replace(array('"', "'"), '', $name)),
+ 'address' => $email
+ );
+ }
+ }
+ }
+ }
+ return $addresses;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Set the From and FromName properties.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $address
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $name
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $auto Whether to also set the Sender address, defaults to true
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $auto Whether to also set the Sender address, defaults to true
</ins><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function setFrom($address, $name = '', $auto = true)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $address = trim($address);
</span><span class="cx" style="display: block; padding: 0 10px"> $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!$this->validateAddress($address)) {
- $this->setError($this->lang('invalid_address') . ': ' . $address);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Don't validate now addresses with IDN. Will be done in send().
+ if (($pos = strrpos($address, '@')) === false or
+ (!$this->has8bitChars(substr($address, ++$pos)) or !$this->idnSupported()) and
+ !$this->validateAddress($address)) {
+ $error_message = $this->lang('invalid_address') . " (setFrom) $address";
+ $this->setError($error_message);
+ $this->edebug($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new phpmailerException($error_message);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->edebug($this->lang('invalid_address') . ': ' . $address);
</del><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->From = $address;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -824,28 +1049,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check that a string looks like an email address.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $address The email address to check
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $patternselect A selector for the validation pattern to use :
- * 'auto' - pick best one automatically;
- * 'pcre8' - use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
- * 'pcre' - use old PCRE implementation;
- * 'php' - use PHP built-in FILTER_VALIDATE_EMAIL; faster, less thorough;
- * 'noregex' - super fast, really dumb.
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|callable $patternselect A selector for the validation pattern to use :
+ * * `auto` Pick best pattern automatically;
+ * * `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
+ * * `pcre` Use old PCRE implementation;
+ * * `php` Use PHP built-in FILTER_VALIDATE_EMAIL;
+ * * `html5` Use the pattern given by the HTML5 spec for 'email' type form input elements.
+ * * `noregex` Don't use a regex: super fast, really dumb.
+ * Alternatively you may pass in a callable to inject your own validator, for example:
+ * PHPMailer::validateAddress('user@example.com', function($address) {
+ * return (strpos($address, '@') !== false);
+ * });
+ * You can also set the PHPMailer::$validator static to a callable, allowing built-in methods to use your validator.
+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> * @static
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public static function validateAddress($address, $patternselect = 'auto')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function validateAddress($address, $patternselect = null)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($patternselect == 'auto') {
- if (defined(
- 'PCRE_VERSION'
- )
- ) { //Check this instead of extension_loaded so it works when that function is disabled
- if (version_compare(PCRE_VERSION, '8.0') >= 0) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_null($patternselect)) {
+ $patternselect = self::$validator;
+ }
+ if (is_callable($patternselect)) {
+ return call_user_func($patternselect, $address);
+ }
+ //Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
+ if (strpos($address, "\n") !== false or strpos($address, "\r") !== false) {
+ return false;
+ }
+ if (!$patternselect or $patternselect == 'auto') {
+ //Check this constant first so it works when extension_loaded() is disabled by safe mode
+ //Constant was added in PHP 5.2.4
+ if (defined('PCRE_VERSION')) {
+ //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2
+ if (version_compare(PCRE_VERSION, '8.0.3') >= 0) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $patternselect = 'pcre8';
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $patternselect = 'pcre';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) {
+ //Fall back to older PCRE
+ $patternselect = 'pcre';
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension
</span><span class="cx" style="display: block; padding: 0 10px"> if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -858,14 +1102,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> switch ($patternselect) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'pcre8':
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * 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 :(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Uses the same RFC5322 regex on which FILTER_VALIDATE_EMAIL is based, but allows dotless domains.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @link http://squiloople.com/2009/12/20/email-address-validation/
</span><span class="cx" style="display: block; padding: 0 10px"> * @copyright 2009-2010 Michael Rushton
</span><span class="cx" style="display: block; padding: 0 10px"> * Feel free to use and redistribute this code. But please keep this copyright notice.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (bool)preg_match(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (boolean)preg_match(
</ins><span class="cx" style="display: block; padding: 0 10px"> '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)' .
</span><span class="cx" style="display: block; padding: 0 10px"> '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)' .
</span><span class="cx" style="display: block; padding: 0 10px"> '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -877,10 +1119,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD',
</span><span class="cx" style="display: block; padding: 0 10px"> $address
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case 'pcre':
</span><span class="cx" style="display: block; padding: 0 10px"> //An older regex that doesn't need a recent PCRE
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (bool)preg_match(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (boolean)preg_match(
</ins><span class="cx" style="display: block; padding: 0 10px"> '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>' .
</span><span class="cx" style="display: block; padding: 0 10px"> '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")' .
</span><span class="cx" style="display: block; padding: 0 10px"> '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -893,27 +1134,75 @@
</span><span class="cx" style="display: block; padding: 0 10px"> '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD',
</span><span class="cx" style="display: block; padding: 0 10px"> $address
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
- case 'php':
- default:
- return (bool)filter_var($address, FILTER_VALIDATE_EMAIL);
- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'html5':
+ /**
+ * This is the pattern used in the HTML5 spec for validation of 'email' type form input elements.
+ * @link http://www.whatwg.org/specs/web-apps/current-work/#e-mail-state-(type=email)
+ */
+ return (boolean)preg_match(
+ '/^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}' .
+ '[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/sD',
+ $address
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'noregex':
</span><span class="cx" style="display: block; padding: 0 10px"> //No PCRE! Do something _very_ approximate!
</span><span class="cx" style="display: block; padding: 0 10px"> //Check the address is 3 chars or longer and contains an @ that's not the first or last char
</span><span class="cx" style="display: block; padding: 0 10px"> return (strlen($address) >= 3
</span><span class="cx" style="display: block; padding: 0 10px"> and strpos($address, '@') >= 1
</span><span class="cx" style="display: block; padding: 0 10px"> and strpos($address, '@') != strlen($address) - 1);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'php':
+ default:
+ return (boolean)filter_var($address, FILTER_VALIDATE_EMAIL);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the
+ * "intl" and "mbstring" PHP extensions.
+ * @return bool "true" if required functions for IDN support are present
+ */
+ public function idnSupported()
+ {
+ // @TODO: Write our own "idn_to_ascii" function for PHP <= 5.2.
+ return function_exists('idn_to_ascii') and function_exists('mb_convert_encoding');
+ }
+
+ /**
+ * Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
+ * Important: Address must be passed in same encoding as currently set in PHPMailer::$CharSet.
+ * This function silently returns unmodified address if:
+ * - No conversion is necessary (i.e. domain name is not an IDN, or is already in ASCII form)
+ * - Conversion to punycode is impossible (e.g. required PHP functions are not available)
+ * or fails for any reason (e.g. domain has characters not allowed in an IDN)
+ * @see PHPMailer::$CharSet
+ * @param string $address The email address to convert
+ * @return string The encoded address in ASCII form
+ */
+ public function punyencodeAddress($address)
+ {
+ // Verify we have required functions, CharSet, and at-sign.
+ if ($this->idnSupported() and
+ !empty($this->CharSet) and
+ ($pos = strrpos($address, '@')) !== false) {
+ $domain = substr($address, ++$pos);
+ // Verify CharSet string is a valid one, and domain properly encoded in this CharSet.
+ if ($this->has8bitChars($domain) and @mb_check_encoding($domain, $this->CharSet)) {
+ $domain = mb_convert_encoding($domain, 'UTF-8', $this->CharSet);
+ if (($punycode = defined('INTL_IDNA_VARIANT_UTS46') ?
+ idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46) :
+ idn_to_ascii($domain)) !== false) {
+ return substr($address, 0, $pos) . $punycode;
+ }
+ }
+ }
+ return $address;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Create a message and send it.
</span><span class="cx" style="display: block; padding: 0 10px"> * Uses the sending method specified by $Mailer.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Returns false on error - Use the ErrorInfo variable to view description of the error.
</del><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean false on error - See the ErrorInfo property for details of the error.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function send()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -922,11 +1211,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->postSend();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (phpmailerException $e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->mailHeader = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->setError($e->getMessage());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError($exc->getMessage());
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw $e;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw $exc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -935,38 +1224,67 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Prepare a message for sending.
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function preSend()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->mailHeader = "";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->error_count = 0; // Reset errors
+ $this->mailHeader = '';
+
+ // Dequeue recipient and Reply-To addresses with IDN
+ foreach (array_merge($this->RecipientsQueue, $this->ReplyToQueue) as $params) {
+ $params[1] = $this->punyencodeAddress($params[1]);
+ call_user_func_array(array($this, 'addAnAddress'), $params);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Validate From, Sender, and ConfirmReadingTo addresses
+ foreach (array('From', 'Sender', 'ConfirmReadingTo') as $address_kind) {
+ $this->$address_kind = trim($this->$address_kind);
+ if (empty($this->$address_kind)) {
+ continue;
+ }
+ $this->$address_kind = $this->punyencodeAddress($this->$address_kind);
+ if (!$this->validateAddress($this->$address_kind)) {
+ $error_message = $this->lang('invalid_address') . ' (punyEncode) ' . $this->$address_kind;
+ $this->setError($error_message);
+ $this->edebug($error_message);
+ if ($this->exceptions) {
+ throw new phpmailerException($error_message);
+ }
+ return false;
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set whether the message is multipart/alternative
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($this->AltBody)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->alternativeExists()) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->ContentType = 'multipart/alternative';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error_count = 0; // reset errors
</del><span class="cx" style="display: block; padding: 0 10px"> $this->setMessageType();
</span><span class="cx" style="display: block; padding: 0 10px"> // Refuse to send an empty message unless we are specifically allowing it
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$this->AllowEmpty and empty($this->Body)) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Create body before headers in case body makes changes to headers (e.g. altering transfer encoding)
+ $this->MIMEHeader = '';
+ $this->MIMEBody = $this->createBody();
+ // createBody may have added some headers, so retain them
+ $tempheaders = $this->MIMEHeader;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->MIMEHeader = $this->createHeader();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->MIMEBody = $this->createBody();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->MIMEHeader .= $tempheaders;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // To capture the complete message when using mail(), create
</span><span class="cx" style="display: block; padding: 0 10px"> // an extra header list which createHeader() doesn't fold in
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->Mailer == 'mail') {
</span><span class="cx" style="display: block; padding: 0 10px"> if (count($this->to) > 0) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->mailHeader .= $this->addrAppend("To", $this->to);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->mailHeader .= $this->addrAppend('To', $this->to);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->mailHeader .= $this->headerLine("To", "undisclosed-recipients:;");
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->mailHeader .= $this->headerLine(
</span><span class="cx" style="display: block; padding: 0 10px"> 'Subject',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -976,10 +1294,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Sign with DKIM if enabled
</span><span class="cx" style="display: block; padding: 0 10px"> if (!empty($this->DKIM_domain)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- && !empty($this->DKIM_private)
</del><span class="cx" style="display: block; padding: 0 10px"> && !empty($this->DKIM_selector)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- && !empty($this->DKIM_domain)
- && file_exists($this->DKIM_private)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ && (!empty($this->DKIM_private_string)
+ || (!empty($this->DKIM_private) && file_exists($this->DKIM_private))
+ )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $header_dkim = $this->DKIM_Add(
</span><span class="cx" style="display: block; padding: 0 10px"> $this->MIMEHeader . $this->mailHeader,
</span><span class="cx" style="display: block; padding: 0 10px"> $this->encodeHeader($this->secureHeader($this->Subject)),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -989,11 +1308,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> str_replace("\r\n", "\n", $header_dkim) . self::CRLF;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- } catch (phpmailerException $e) {
- $this->setError($e->getMessage());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
+ $this->setError($exc->getMessage());
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw $e;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw $exc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1003,7 +1321,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Actually send a message.
</span><span class="cx" style="display: block; padding: 0 10px"> * Send the email via the selected mechanism
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function postSend()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1011,20 +1329,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Choose the mailer and send through it
</span><span class="cx" style="display: block; padding: 0 10px"> switch ($this->Mailer) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'sendmail':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ case 'qmail':
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
</span><span class="cx" style="display: block; padding: 0 10px"> case 'smtp':
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
</span><span class="cx" style="display: block; padding: 0 10px"> case 'mail':
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $sendMethod = $this->Mailer.'Send';
+ if (method_exists($this, $sendMethod)) {
+ return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (phpmailerException $e) {
- $this->setError($e->getMessage());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
+ $this->setError($exc->getMessage());
+ $this->edebug($exc->getMessage());
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw $e;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw $exc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->edebug($e->getMessage() . "\n");
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1036,27 +1360,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see PHPMailer::$Sendmail
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function sendmailSend($header, $body)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->Sender != '') {
- $sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
+ if (!empty($this->Sender) and self::isShellSafe($this->Sender)) {
+ if ($this->Mailer == 'qmail') {
+ $sendmailFmt = '%s -f%s';
+ } else {
+ $sendmailFmt = '%s -oi -f%s -t';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->Mailer == 'qmail') {
+ $sendmailFmt = '%s';
+ } else {
+ $sendmailFmt = '%s -oi -t';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->SingleTo === true) {
- foreach ($this->SingleToArray as $val) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // TODO: If possible, this should be changed to escapeshellarg. Needs thorough testing.
+ $sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);
+
+ if ($this->SingleTo) {
+ foreach ($this->SingleToArray as $toAddr) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!@$mail = popen($sendmail, 'w')) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- fputs($mail, "To: " . $val . "\n");
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ fputs($mail, 'To: ' . $toAddr . "\n");
</ins><span class="cx" style="display: block; padding: 0 10px"> fputs($mail, $header);
</span><span class="cx" style="display: block; padding: 0 10px"> fputs($mail, $body);
</span><span class="cx" style="display: block; padding: 0 10px"> $result = pclose($mail);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // implement call back function if it exists
- $isSent = ($result == 0) ? 1 : 0;
- $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->doCallback(
+ ($result == 0),
+ array($toAddr),
+ $this->cc,
+ $this->bcc,
+ $this->Subject,
+ $body,
+ $this->From
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($result != 0) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1068,9 +1411,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> fputs($mail, $header);
</span><span class="cx" style="display: block; padding: 0 10px"> fputs($mail, $body);
</span><span class="cx" style="display: block; padding: 0 10px"> $result = pclose($mail);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // implement call back function if it exists
- $isSent = ($result == 0) ? 1 : 0;
- $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->doCallback(
+ ($result == 0),
+ $this->to,
+ $this->cc,
+ $this->bcc,
+ $this->Subject,
+ $body,
+ $this->From
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($result != 0) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1079,49 +1428,82 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
+ *
+ * Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
+ * @param string $string The string to be validated
+ * @see https://github.com/PHPMailer/PHPMailer/issues/924 CVE-2016-10045 bug report
+ * @access protected
+ * @return boolean
+ */
+ protected static function isShellSafe($string)
+ {
+ // Future-proof
+ if (escapeshellcmd($string) !== $string
+ or !in_array(escapeshellarg($string), array("'$string'", "\"$string\""))
+ ) {
+ return false;
+ }
+
+ $length = strlen($string);
+
+ for ($i = 0; $i < $length; $i++) {
+ $c = $string[$i];
+
+ // All other characters have a special meaning in at least one common shell, including = and +.
+ // Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
+ // Note that this does permit non-Latin alphanumeric characters based on the current locale.
+ if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Send mail using the PHP mail() function.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $header The message headers
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $body The message body
</span><span class="cx" style="display: block; padding: 0 10px"> * @link http://www.php.net/manual/en/book.mail.php
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function mailSend($header, $body)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $toArr = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ($this->to as $t) {
- $toArr[] = $this->addrFormat($t);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ($this->to as $toaddr) {
+ $toArr[] = $this->addrFormat($toaddr);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $to = implode(', ', $toArr);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (empty($this->Sender)) {
- $params = " ";
- } else {
- $params = sprintf("-f%s", $this->Sender);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $params = null;
+ //This sets the SMTP envelope sender which gets turned into a return-path header by the receiver
+ if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
+ // CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
+ if (self::isShellSafe($this->Sender)) {
+ $params = sprintf('-f%s', $this->Sender);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->Sender != '' and !ini_get('safe_mode')) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $old_from = ini_get('sendmail_from');
</span><span class="cx" style="display: block; padding: 0 10px"> ini_set('sendmail_from', $this->Sender);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $rt = false;
- if ($this->SingleTo === true && count($toArr) > 1) {
- foreach ($toArr as $val) {
- $rt = $this->mailPassthru($val, $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, $this->From);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = false;
+ if ($this->SingleTo and count($toArr) > 1) {
+ foreach ($toArr as $toAddr) {
+ $result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
+ $this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $rt = $this->mailPassthru($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, $this->From);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
+ $this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if (isset($old_from)) {
</span><span class="cx" style="display: block; padding: 0 10px"> ini_set('sendmail_from', $old_from);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!$rt) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$result) {
</ins><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1135,7 +1517,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function getSMTPInstance()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_object($this->smtp)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once 'class-smtp.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once( 'class-smtp.php' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp = new SMTP;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->smtp;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1151,62 +1533,59 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><span class="cx" style="display: block; padding: 0 10px"> * @uses SMTP
</span><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function smtpSend($header, $body)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $bad_rcpt = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if (!$this->smtpConnect()) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$this->smtpConnect($this->SMTPOptions)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
+ $smtp_from = $this->Sender;
+ } else {
+ $smtp_from = $this->From;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!$this->smtp->mail($smtp_from)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError()));
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->ErrorInfo, self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Attempt to send attach all recipients
- foreach ($this->to as $to) {
- if (!$this->smtp->recipient($to[0])) {
- $bad_rcpt[] = $to[0];
- $isSent = 0;
- } else {
- $isSent = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Attempt to send to all recipients
+ foreach (array($this->to, $this->cc, $this->bcc) as $togroup) {
+ foreach ($togroup as $to) {
+ if (!$this->smtp->recipient($to[0])) {
+ $error = $this->smtp->getError();
+ $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']);
+ $isSent = false;
+ } else {
+ $isSent = true;
+ }
+ $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->doCallback($isSent, $to[0], '', '', $this->Subject, $body, $this->From);
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ($this->cc as $cc) {
- if (!$this->smtp->recipient($cc[0])) {
- $bad_rcpt[] = $cc[0];
- $isSent = 0;
- } else {
- $isSent = 1;
- }
- $this->doCallback($isSent, '', $cc[0], '', $this->Subject, $body, $this->From);
- }
- foreach ($this->bcc as $bcc) {
- if (!$this->smtp->recipient($bcc[0])) {
- $bad_rcpt[] = $bcc[0];
- $isSent = 0;
- } else {
- $isSent = 1;
- }
- $this->doCallback($isSent, '', '', $bcc[0], $this->Subject, $body, $this->From);
- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (count($bad_rcpt) > 0) { //Create error message for any bad addresses
- throw new phpmailerException($this->lang('recipients_failed') . implode(', ', $bad_rcpt));
- }
- if (!$this->smtp->data($header . $body)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Only send the DATA command if we have viable recipients
+ if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('data_not_accepted'), self::STOP_CRITICAL);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->SMTPKeepAlive == true) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->SMTPKeepAlive) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->reset();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->quit();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->close();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Create error message for any bad addresses
+ if (count($bad_rcpt) > 0) {
+ $errstr = '';
+ foreach ($bad_rcpt as $bad) {
+ $errstr .= $bad['to'] . ': ' . $bad['error'];
+ }
+ throw new phpmailerException(
+ $this->lang('recipients_failed') . $errstr,
+ self::STOP_CONTINUE
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1217,15 +1596,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @uses SMTP
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function smtpConnect($options = array())
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function smtpConnect($options = null)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_null($this->smtp)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp = $this->getSMTPInstance();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Already connected?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //If no options are provided, use whatever is set in the instance
+ if (is_null($options)) {
+ $options = $this->SMTPOptions;
+ }
+
+ // Already connected?
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->smtp->connected()) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1234,25 +1618,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->setDebugLevel($this->SMTPDebug);
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->setDebugOutput($this->Debugoutput);
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->setVerp($this->do_verp);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tls = ($this->SMTPSecure == 'tls');
- $ssl = ($this->SMTPSecure == 'ssl');
</del><span class="cx" style="display: block; padding: 0 10px"> $hosts = explode(';', $this->Host);
</span><span class="cx" style="display: block; padding: 0 10px"> $lastexception = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ($hosts as $hostentry) {
</span><span class="cx" style="display: block; padding: 0 10px"> $hostinfo = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $host = $hostentry;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
+ // Not a valid host entry
+ continue;
+ }
+ // $hostinfo[2]: optional ssl or tls prefix
+ // $hostinfo[3]: the hostname
+ // $hostinfo[4]: optional port number
+ // The host string prefix can temporarily override the current setting for SMTPSecure
+ // If it's not specified, the default value is used
+ $prefix = '';
+ $secure = $this->SMTPSecure;
+ $tls = ($this->SMTPSecure == 'tls');
+ if ('ssl' == $hostinfo[2] or ('' == $hostinfo[2] and 'ssl' == $this->SMTPSecure)) {
+ $prefix = 'ssl://';
+ $tls = false; // Can't have SSL and TLS at the same time
+ $secure = 'ssl';
+ } elseif ($hostinfo[2] == 'tls') {
+ $tls = true;
+ // tls doesn't use a prefix
+ $secure = 'tls';
+ }
+ //Do we need the OpenSSL extension?
+ $sslext = defined('OPENSSL_ALGO_SHA1');
+ if ('tls' === $secure or 'ssl' === $secure) {
+ //Check for an OpenSSL constant rather than using extension_loaded, which is sometimes disabled
+ if (!$sslext) {
+ throw new phpmailerException($this->lang('extension_missing').'openssl', self::STOP_CRITICAL);
+ }
+ }
+ $host = $hostinfo[3];
</ins><span class="cx" style="display: block; padding: 0 10px"> $port = $this->Port;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (preg_match(
- '/^(.+):([0-9]+)$/',
- $hostentry,
- $hostinfo
- )
- ) { //If $hostentry contains 'address:port', override default
- $host = $hostinfo[1];
- $port = $hostinfo[2];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tport = (integer)$hostinfo[4];
+ if ($tport > 0 and $tport < 65536) {
+ $port = $tport;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->smtp->connect(($ssl ? 'ssl://' : '') . $host, $port, $this->Timeout, $options)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->Helo) {
</span><span class="cx" style="display: block; padding: 0 10px"> $hello = $this->Helo;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1260,12 +1666,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $hello = $this->serverHostname();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->hello($hello);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Automatically enable TLS encryption if:
+ // * it's not disabled
+ // * we have openssl extension
+ // * we are not already using SSL
+ // * the server offers STARTTLS
+ if ($this->SMTPAutoTLS and $sslext and $secure != 'ssl' and $this->smtp->getServerExt('STARTTLS')) {
+ $tls = true;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($tls) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$this->smtp->startTLS()) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('connect_host'));
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //We must resend HELO after tls negotiation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // We must resend EHLO after TLS negotiation
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->hello($hello);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->SMTPAuth) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1281,16 +1694,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (phpmailerException $e) {
- $lastexception = $e;
- //We must have connected, but then failed TLS or Auth, so close connection nicely
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
+ $lastexception = $exc;
+ $this->edebug($exc->getMessage());
+ // We must have connected, but then failed TLS or Auth, so close connection nicely
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->quit();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If we get here, all connection attempts have failed, so close connection hard
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If we get here, all connection attempts have failed, so close connection hard
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->close();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //As we've caught all exceptions, just report whatever the last one was
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // As we've caught all exceptions, just report whatever the last one was
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions and !is_null($lastexception)) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw $lastexception;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1303,7 +1717,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function smtpClose()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->smtp !== null) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_a($this->smtp, 'SMTP')) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->smtp->connected()) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->quit();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp->close();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1317,12 +1731,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * The default language is English.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $lang_path Path to the language file directory, with trailing separator (slash)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function setLanguage($langcode = 'en', $lang_path = 'language/')
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function setLanguage($langcode = 'en', $lang_path = '')
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Define full set of translatable strings
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Backwards compatibility for renamed language codes
+ $renamed_langcodes = array(
+ 'br' => 'pt_br',
+ 'cz' => 'cs',
+ 'dk' => 'da',
+ 'no' => 'nb',
+ 'se' => 'sv',
+ );
+
+ if (isset($renamed_langcodes[$langcode])) {
+ $langcode = $renamed_langcodes[$langcode];
+ }
+
+ // Define full set of translatable strings in English
</ins><span class="cx" style="display: block; padding: 0 10px"> $PHPMAILER_LANG = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'authenticate' => 'SMTP Error: Could not authenticate.',
</span><span class="cx" style="display: block; padding: 0 10px"> 'connect_host' => 'SMTP Error: Could not connect to SMTP host.',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1334,23 +1761,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'file_open' => 'File Error: Could not open file: ',
</span><span class="cx" style="display: block; padding: 0 10px"> 'from_failed' => 'The following From address failed: ',
</span><span class="cx" style="display: block; padding: 0 10px"> 'instantiate' => 'Could not instantiate mail function.',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'invalid_address' => 'Invalid address',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'invalid_address' => 'Invalid address: ',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'mailer_not_supported' => ' mailer is not supported.',
</span><span class="cx" style="display: block; padding: 0 10px"> 'provide_address' => 'You must provide at least one recipient email address.',
</span><span class="cx" style="display: block; padding: 0 10px"> 'recipients_failed' => 'SMTP Error: The following recipients failed: ',
</span><span class="cx" style="display: block; padding: 0 10px"> 'signing' => 'Signing Error: ',
</span><span class="cx" style="display: block; padding: 0 10px"> 'smtp_connect_failed' => 'SMTP connect() failed.',
</span><span class="cx" style="display: block; padding: 0 10px"> 'smtp_error' => 'SMTP server error: ',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'variable_set' => 'Cannot set or reset variable: '
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'variable_set' => 'Cannot set or reset variable: ',
+ 'extension_missing' => 'Extension missing: '
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Overwrite language-specific strings.
- //This way we'll never have missing translations - no more "language string failed to load"!
- $l = true;
- if ($langcode != 'en') { //There is no English translation file
- $l = @include $lang_path . 'phpmailer.lang-' . $langcode . '.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (empty($lang_path)) {
+ // Calculate an absolute path so it can work if CWD is not here
+ $lang_path = dirname(__FILE__). DIRECTORY_SEPARATOR . 'language'. DIRECTORY_SEPARATOR;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Validate $langcode
+ if (!preg_match('/^[a-z]{2}(?:_[a-zA-Z]{2})?$/', $langcode)) {
+ $langcode = 'en';
+ }
+ $foundlang = true;
+ $lang_file = $lang_path . 'phpmailer.lang-' . $langcode . '.php';
+ // There is no English translation file
+ if ($langcode != 'en') {
+ // Make sure language file path is readable
+ if (!is_readable($lang_file)) {
+ $foundlang = false;
+ } else {
+ // Overwrite language-specific strings.
+ // This way we'll never have missing translation keys.
+ $foundlang = include $lang_file;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->language = $PHPMAILER_LANG;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return ($l == true); //Returns false if language not found
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (boolean)$foundlang; // Returns false if language not found
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1375,8 +1818,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function addrAppend($type, $addr)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $addresses = array();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ($addr as $a) {
- $addresses[] = $this->addrFormat($a);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ($addr as $address) {
+ $addresses[] = $this->addrFormat($address);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $type . ': ' . implode(', ', $addresses) . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1393,9 +1836,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (empty($addr[1])) { // No name provided
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->secureHeader($addr[0]);
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . " <" . $this->secureHeader(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
</ins><span class="cx" style="display: block; padding: 0 10px"> $addr[0]
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ) . ">";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) . '>';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1406,47 +1849,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Original written by philippe.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $message The message to wrap
</span><span class="cx" style="display: block; padding: 0 10px"> * @param integer $length The line length to wrap to
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $qp_mode Whether to run in Quoted-Printable mode
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $qp_mode Whether to run in Quoted-Printable mode
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function wrapText($message, $length, $qp_mode = false)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($qp_mode) {
+ $soft_break = sprintf(' =%s', $this->LE);
+ } else {
+ $soft_break = $this->LE;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // If utf-8 encoding is used, we will need to make sure we don't
</span><span class="cx" style="display: block; padding: 0 10px"> // split multibyte characters when we wrap
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $is_utf8 = (strtolower($this->CharSet) == "utf-8");
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $is_utf8 = (strtolower($this->CharSet) == 'utf-8');
</ins><span class="cx" style="display: block; padding: 0 10px"> $lelen = strlen($this->LE);
</span><span class="cx" style="display: block; padding: 0 10px"> $crlflen = strlen(self::CRLF);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $message = $this->fixEOL($message);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Remove a trailing line break
</ins><span class="cx" style="display: block; padding: 0 10px"> if (substr($message, -$lelen) == $this->LE) {
</span><span class="cx" style="display: block; padding: 0 10px"> $message = substr($message, 0, -$lelen);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $line = explode($this->LE, $message); // Magic. We know fixEOL uses $LE
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Split message into lines
+ $lines = explode($this->LE, $message);
+ //Message will be rebuilt in here
</ins><span class="cx" style="display: block; padding: 0 10px"> $message = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- for ($i = 0; $i < count($line); $i++) {
- $line_part = explode(' ', $line[$i]);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ($lines as $line) {
+ $words = explode(' ', $line);
</ins><span class="cx" style="display: block; padding: 0 10px"> $buf = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- for ($e = 0; $e < count($line_part); $e++) {
- $word = $line_part[$e];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $firstword = true;
+ foreach ($words as $word) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($qp_mode and (strlen($word) > $length)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $space_left = $length - strlen($buf) - $crlflen;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($e != 0) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$firstword) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($space_left > 20) {
</span><span class="cx" style="display: block; padding: 0 10px"> $len = $space_left;
</span><span class="cx" style="display: block; padding: 0 10px"> if ($is_utf8) {
</span><span class="cx" style="display: block; padding: 0 10px"> $len = $this->utf8CharBoundary($word, $len);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (substr($word, $len - 1, 1) == "=") {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (substr($word, $len - 1, 1) == '=') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $len--;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (substr($word, $len - 2, 1) == "=") {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (substr($word, $len - 2, 1) == '=') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $len -= 2;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $part = substr($word, 0, $len);
</span><span class="cx" style="display: block; padding: 0 10px"> $word = substr($word, $len);
</span><span class="cx" style="display: block; padding: 0 10px"> $buf .= ' ' . $part;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $message .= $buf . sprintf("=%s", self::CRLF);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $message .= $buf . sprintf('=%s', self::CRLF);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $message .= $buf . $soft_break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1459,29 +1909,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $len = $length;
</span><span class="cx" style="display: block; padding: 0 10px"> if ($is_utf8) {
</span><span class="cx" style="display: block; padding: 0 10px"> $len = $this->utf8CharBoundary($word, $len);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (substr($word, $len - 1, 1) == "=") {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (substr($word, $len - 1, 1) == '=') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $len--;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (substr($word, $len - 2, 1) == "=") {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (substr($word, $len - 2, 1) == '=') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $len -= 2;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $part = substr($word, 0, $len);
</span><span class="cx" style="display: block; padding: 0 10px"> $word = substr($word, $len);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (strlen($word) > 0) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $message .= $part . sprintf("=%s", self::CRLF);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $message .= $part . sprintf('=%s', self::CRLF);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $buf = $part;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $buf_o = $buf;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $buf .= ($e == 0) ? $word : (' ' . $word);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$firstword) {
+ $buf .= ' ';
+ }
+ $buf .= $word;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (strlen($buf) > $length and $buf_o != '') {
</span><span class="cx" style="display: block; padding: 0 10px"> $message .= $buf_o . $soft_break;
</span><span class="cx" style="display: block; padding: 0 10px"> $buf = $word;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $firstword = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $message .= $buf . self::CRLF;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1491,12 +1945,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Find the last character boundary prior to $maxLength in a utf-8
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * quoted (printable) encoded string.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * quoted-printable encoded string.
</ins><span class="cx" style="display: block; padding: 0 10px"> * Original written by Colin Brown.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $encodedText utf-8 QP text
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $maxLength find last character boundary prior to this length
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param integer $maxLength Find the last character boundary prior to this length
+ * @return integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function utf8CharBoundary($encodedText, $maxLength)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1504,23 +1958,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $lookBack = 3;
</span><span class="cx" style="display: block; padding: 0 10px"> while (!$foundSplitPos) {
</span><span class="cx" style="display: block; padding: 0 10px"> $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $encodedCharPos = strpos($lastChunk, "=");
- if ($encodedCharPos !== false) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encodedCharPos = strpos($lastChunk, '=');
+ if (false !== $encodedCharPos) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Found start of encoded character byte within $lookBack block.
</span><span class="cx" style="display: block; padding: 0 10px"> // Check the encoded byte value (the 2 chars after the '=')
</span><span class="cx" style="display: block; padding: 0 10px"> $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2);
</span><span class="cx" style="display: block; padding: 0 10px"> $dec = hexdec($hex);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($dec < 128) { // Single byte character.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($dec < 128) {
+ // Single byte character.
</ins><span class="cx" style="display: block; padding: 0 10px"> // If the encoded char was found at pos 0, it will fit
</span><span class="cx" style="display: block; padding: 0 10px"> // otherwise reduce maxLength to start of the encoded char
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $maxLength = ($encodedCharPos == 0) ? $maxLength :
- $maxLength - ($lookBack - $encodedCharPos);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($encodedCharPos > 0) {
+ $maxLength = $maxLength - ($lookBack - $encodedCharPos);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $foundSplitPos = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ($dec >= 192) { // First byte of a multi byte character
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ($dec >= 192) {
+ // First byte of a multi byte character
</ins><span class="cx" style="display: block; padding: 0 10px"> // Reduce maxLength to split at start of character
</span><span class="cx" style="display: block; padding: 0 10px"> $maxLength = $maxLength - ($lookBack - $encodedCharPos);
</span><span class="cx" style="display: block; padding: 0 10px"> $foundSplitPos = true;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ($dec < 192) {
+ // Middle byte of a multi byte character, look further back
</ins><span class="cx" style="display: block; padding: 0 10px"> $lookBack += 3;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1531,9 +1989,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $maxLength;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Set the body wrapping.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Apply word wrapping to the message body.
+ * Wraps the message body to the number of chars set in the WordWrap property.
+ * You should only do this to plain-text bodies as wrapping HTML tags may break them.
+ * This is called automatically by createBody(), so you don't need to call it yourself.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1565,38 +2025,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set the boundaries
- $uniq_id = md5(uniqid(time()));
- $this->boundary[1] = 'b1_' . $uniq_id;
- $this->boundary[2] = 'b2_' . $uniq_id;
- $this->boundary[3] = 'b3_' . $uniq_id;
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ($this->MessageDate == '') {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= $this->headerLine('Date', self::rfcDate());
- } else {
- $result .= $this->headerLine('Date', $this->MessageDate);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->MessageDate = self::rfcDate();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result .= $this->headerLine('Date', $this->MessageDate);
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->ReturnPath) {
- $result .= $this->headerLine('Return-Path', '<' . trim($this->ReturnPath) . '>');
- } elseif ($this->Sender == '') {
- $result .= $this->headerLine('Return-Path', '<' . trim($this->From) . '>');
- } else {
- $result .= $this->headerLine('Return-Path', '<' . trim($this->Sender) . '>');
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // To be created automatically by mail()
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->Mailer != 'mail') {
- if ($this->SingleTo === true) {
- foreach ($this->to as $t) {
- $this->SingleToArray[] = $this->addrFormat($t);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($this->SingleTo) {
+ if ($this->Mailer != 'mail') {
+ foreach ($this->to as $toaddr) {
+ $this->SingleToArray[] = $this->addrFormat($toaddr);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- if (count($this->to) > 0) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
+ } else {
+ if (count($this->to) > 0) {
+ if ($this->Mailer != 'mail') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->addrAppend('To', $this->to);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (count($this->cc) == 0) {
- $result .= $this->headerLine('To', 'undisclosed-recipients:;');
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (count($this->cc) == 0) {
+ $result .= $this->headerLine('To', 'undisclosed-recipients:;');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1608,7 +2055,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // sendmail and mail() extract Bcc from the header before sending
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ((
+ $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
+ )
+ and count($this->bcc) > 0
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->addrAppend('Bcc', $this->bcc);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1621,17 +2072,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject)));
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->MessageID != '') {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Only allow a custom message ID if it conforms to RFC 5322 section 3.6.4
+ // https://tools.ietf.org/html/rfc5322#section-3.6.4
+ if ('' != $this->MessageID and preg_match('/^<.*@.*>$/', $this->MessageID)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->lastMessageID = $this->MessageID;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->lastMessageID = sprintf("<%s@%s>", $uniq_id, $this->ServerHostname());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->lastMessageID = sprintf('<%s@%s>', $this->uniqueid, $this->serverHostname());
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= $this->HeaderLine('Message-ID', $this->lastMessageID);
- $result .= $this->headerLine('X-Priority', $this->Priority);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result .= $this->headerLine('Message-ID', $this->lastMessageID);
+ if (!is_null($this->Priority)) {
+ $result .= $this->headerLine('X-Priority', $this->Priority);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->XMailer == '') {
</span><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->headerLine(
</span><span class="cx" style="display: block; padding: 0 10px"> 'X-Mailer',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer)'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $myXmailer = trim($this->XMailer);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1641,14 +2096,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->ConfirmReadingTo != '') {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result .= $this->headerLine('Disposition-Notification-To', '<' . $this->ConfirmReadingTo . '>');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Add custom headers
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- for ($index = 0; $index < count($this->CustomHeader); $index++) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ($this->CustomHeader as $header) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->headerLine(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- trim($this->CustomHeader[$index][0]),
- $this->encodeHeader(trim($this->CustomHeader[$index][1]))
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ trim($header[0]),
+ $this->encodeHeader(trim($header[1]))
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$this->sign_key_file) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1667,6 +2122,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function getMailMIME()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ismultipart = true;
</ins><span class="cx" style="display: block; padding: 0 10px"> switch ($this->message_type) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'inline':
</span><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->headerLine('Content-Type', 'multipart/related;');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1687,11 +2143,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><span class="cx" style="display: block; padding: 0 10px"> // Catches case 'plain': and case '':
</span><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->textLine('Content-Type: ' . $this->ContentType . '; charset=' . $this->CharSet);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $ismultipart = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //RFC1341 part 5 says 7bit is assumed if not specified
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC1341 part 5 says 7bit is assumed if not specified
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->Encoding != '7bit') {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC 2045 section 6.4 says multipart MIME parts may only use 7bit, 8bit or binary CTE
+ if ($ismultipart) {
+ if ($this->Encoding == '8bit') {
+ $result .= $this->headerLine('Content-Transfer-Encoding', '8bit');
+ }
+ // The only remaining alternatives are quoted-printable and base64, which are both 7bit compatible
+ } else {
+ $result .= $this->headerLine('Content-Transfer-Encoding', $this->Encoding);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->Mailer != 'mail') {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1704,16 +2169,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns the whole MIME message.
</span><span class="cx" style="display: block; padding: 0 10px"> * Includes complete headers and body.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Only valid post PreSend().
- * @see PHPMailer::PreSend()
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Only valid post preSend().
+ * @see PHPMailer::preSend()
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getSentMIMEMessage()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Create unique ID
+ * @return string
+ */
+ protected function generateId() {
+ return md5(uniqid(time()));
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Assemble the message body.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1725,6 +2197,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function createBody()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $body = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Create unique IDs and preset boundaries
+ $this->uniqueid = $this->generateId();
+ $this->boundary[1] = 'b1_' . $this->uniqueid;
+ $this->boundary[2] = 'b2_' . $this->uniqueid;
+ $this->boundary[3] = 'b3_' . $this->uniqueid;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->sign_key_file) {
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->getMailMIME() . $this->LE;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1732,37 +2209,70 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setWordWrap();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bodyEncoding = $this->Encoding;
+ $bodyCharSet = $this->CharSet;
+ //Can we do a 7-bit downgrade?
+ if ($bodyEncoding == '8bit' and !$this->has8bitChars($this->Body)) {
+ $bodyEncoding = '7bit';
+ //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
+ $bodyCharSet = 'us-ascii';
+ }
+ //If lines are too long, and we're not already using an encoding that will shorten them,
+ //change to quoted-printable transfer encoding for the body part only
+ if ('base64' != $this->Encoding and self::hasLineLongerThanMax($this->Body)) {
+ $bodyEncoding = 'quoted-printable';
+ }
+
+ $altBodyEncoding = $this->Encoding;
+ $altBodyCharSet = $this->CharSet;
+ //Can we do a 7-bit downgrade?
+ if ($altBodyEncoding == '8bit' and !$this->has8bitChars($this->AltBody)) {
+ $altBodyEncoding = '7bit';
+ //All ISO 8859, Windows codepage and UTF-8 charsets are ascii compatible up to 7-bit
+ $altBodyCharSet = 'us-ascii';
+ }
+ //If lines are too long, and we're not already using an encoding that will shorten them,
+ //change to quoted-printable transfer encoding for the alt body part only
+ if ('base64' != $altBodyEncoding and self::hasLineLongerThanMax($this->AltBody)) {
+ $altBodyEncoding = 'quoted-printable';
+ }
+ //Use this as a preamble in all multipart message types
+ $mimepre = "This is a multi-part message in MIME format." . $this->LE . $this->LE;
</ins><span class="cx" style="display: block; padding: 0 10px"> switch ($this->message_type) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'inline':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[1], '', '', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
+ $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('inline', $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'attach':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[1], '', '', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
+ $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, '', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('attachment', $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'inline_attach':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine('--' . $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->headerLine('Content-Type', 'multipart/related;');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[2], '', '', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, '', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('inline', $this->boundary[2]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('attachment', $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'alt':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[1], '', 'text/plain', '');
- $body .= $this->encodeString($this->AltBody, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
+ $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
+ $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[1], '', 'text/html', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[1], $bodyCharSet, 'text/html', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> if (!empty($this->Ical)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->getBoundary($this->boundary[1], '', 'text/calendar; method=REQUEST', '');
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1772,49 +2282,52 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->endBoundary($this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'alt_inline':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[1], '', 'text/plain', '');
- $body .= $this->encodeString($this->AltBody, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
+ $body .= $this->getBoundary($this->boundary[1], $altBodyCharSet, 'text/plain', $altBodyEncoding);
+ $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine('--' . $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->headerLine('Content-Type', 'multipart/related;');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[2], '', 'text/html', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('inline', $this->boundary[2]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->endBoundary($this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'alt_attach':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine('--' . $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[2], '', 'text/plain', '');
- $body .= $this->encodeString($this->AltBody, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
+ $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[2], '', 'text/html', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[2], $bodyCharSet, 'text/html', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->endBoundary($this->boundary[2]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('attachment', $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'alt_inline_attach':
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $mimepre;
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine('--' . $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->headerLine('Content-Type', 'multipart/alternative;');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine("\tboundary=\"" . $this->boundary[2] . '"');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[2], '', 'text/plain', '');
- $body .= $this->encodeString($this->AltBody, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[2], $altBodyCharSet, 'text/plain', $altBodyEncoding);
+ $body .= $this->encodeString($this->AltBody, $altBodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine('--' . $this->boundary[2]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->headerLine('Content-Type', 'multipart/related;');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->textLine("\tboundary=\"" . $this->boundary[3] . '"');
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $body .= $this->getBoundary($this->boundary[3], '', 'text/html', '');
- $body .= $this->encodeString($this->Body, $this->Encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $body .= $this->getBoundary($this->boundary[3], $bodyCharSet, 'text/html', $bodyEncoding);
+ $body .= $this->encodeString($this->Body, $bodyEncoding);
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE . $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('inline', $this->boundary[3]);
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->LE;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1823,7 +2336,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->attachAll('attachment', $this->boundary[1]);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // catch case 'plain' and case ''
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Catch case 'plain' and case '', applies to simple `text/plain` and `text/html` body content types
+ //Reset the `Encoding` property in case we changed it for line length reasons
+ $this->Encoding = $bodyEncoding;
</ins><span class="cx" style="display: block; padding: 0 10px"> $body .= $this->encodeString($this->Body, $this->Encoding);
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1833,31 +2348,51 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ($this->sign_key_file) {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!defined('PKCS7_TEXT')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new phpmailerException($this->lang('signing') . ' OpenSSL extension missing.');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new phpmailerException($this->lang('extension_missing') . 'openssl');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // @TODO would be nice to use php://temp streams here, but need to wrap for PHP < 5.1
</ins><span class="cx" style="display: block; padding: 0 10px"> $file = tempnam(sys_get_temp_dir(), 'mail');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- file_put_contents($file, $body); //TODO check this worked
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (false === file_put_contents($file, $body)) {
+ throw new phpmailerException($this->lang('signing') . ' Could not write temp file');
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $signed = tempnam(sys_get_temp_dir(), 'signed');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (@openssl_pkcs7_sign(
- $file,
- $signed,
- 'file://' . realpath($this->sign_cert_file),
- array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
- null
- )
- ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Workaround for PHP bug https://bugs.php.net/bug.php?id=69197
+ if (empty($this->sign_extracerts_file)) {
+ $sign = @openssl_pkcs7_sign(
+ $file,
+ $signed,
+ 'file://' . realpath($this->sign_cert_file),
+ array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
+ null
+ );
+ } else {
+ $sign = @openssl_pkcs7_sign(
+ $file,
+ $signed,
+ 'file://' . realpath($this->sign_cert_file),
+ array('file://' . realpath($this->sign_key_file), $this->sign_key_pass),
+ null,
+ PKCS7_DETACHED,
+ $this->sign_extracerts_file
+ );
+ }
+ if ($sign) {
</ins><span class="cx" style="display: block; padding: 0 10px"> @unlink($file);
</span><span class="cx" style="display: block; padding: 0 10px"> $body = file_get_contents($signed);
</span><span class="cx" style="display: block; padding: 0 10px"> @unlink($signed);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //The message returned by openssl contains both headers and body, so need to split them up
+ $parts = explode("\n\n", $body, 2);
+ $this->MIMEHeader .= $parts[0] . $this->LE . $this->LE;
+ $body = $parts[1];
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> @unlink($file);
</span><span class="cx" style="display: block; padding: 0 10px"> @unlink($signed);
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('signing') . openssl_error_string());
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (phpmailerException $e) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $body = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw $e;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw $exc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1886,9 +2421,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $encoding = $this->Encoding;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->textLine('--' . $boundary);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= sprintf("Content-Type: %s; charset=%s", $contentType, $charSet);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet);
</ins><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->LE;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC1341 part 5 says 7bit is assumed if not specified
+ if ($encoding != '7bit') {
+ $result .= $this->headerLine('Content-Transfer-Encoding', $encoding);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $result .= $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $result;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1907,26 +2445,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Set the message type.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * PHPMailer only supports some preset message types,
- * not arbitrary MIME structures.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * PHPMailer only supports some preset message types, not arbitrary MIME structures.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function setMessageType()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->message_type = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->alternativeExists()) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->message_type[] = "alt";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type[] = 'alt';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->inlineImageExists()) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->message_type[] = "inline";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type[] = 'inline';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->attachmentExists()) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->message_type[] = "attach";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type[] = 'attach';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->message_type = implode("_", $this->message_type);
- if ($this->message_type == "") {
- $this->message_type = "plain";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->message_type = implode('_', $type);
+ if ($this->message_type == '') {
+ //The 'plain' message_type refers to the message having a single body element, not that it is plain-text
+ $this->message_type = 'plain';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1962,7 +2500,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $type File extension (MIME) type.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $disposition Disposition to use
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1971,7 +2509,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If a MIME type is not specified, try to work it out from the file name
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If a MIME type is not specified, try to work it out from the file name
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($type == '') {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = self::filenameToType($path);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1992,12 +2530,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 7 => 0
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (phpmailerException $e) {
- $this->setError($e->getMessage());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (phpmailerException $exc) {
+ $this->setError($exc->getMessage());
+ $this->edebug($exc->getMessage());
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw $e;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw $exc;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->edebug($e->getMessage() . "\n");
</del><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2051,22 +2589,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $type = $attachment[4];
</span><span class="cx" style="display: block; padding: 0 10px"> $disposition = $attachment[6];
</span><span class="cx" style="display: block; padding: 0 10px"> $cid = $attachment[7];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($disposition == 'inline' && isset($cidUniq[$cid])) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($disposition == 'inline' && array_key_exists($cid, $cidUniq)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $cidUniq[$cid] = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mime[] = sprintf("--%s%s", $boundary, $this->LE);
- $mime[] = sprintf(
- "Content-Type: %s; name=\"%s\"%s",
- $type,
- $this->encodeHeader($this->secureHeader($name)),
- $this->LE
- );
- $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $mime[] = sprintf('--%s%s', $boundary, $this->LE);
+ //Only include a filename property if we have one
+ if (!empty($name)) {
+ $mime[] = sprintf(
+ 'Content-Type: %s; name="%s"%s',
+ $type,
+ $this->encodeHeader($this->secureHeader($name)),
+ $this->LE
+ );
+ } else {
+ $mime[] = sprintf(
+ 'Content-Type: %s%s',
+ $type,
+ $this->LE
+ );
+ }
+ // RFC1341 part 5 says 7bit is assumed if not specified
+ if ($encoding != '7bit') {
+ $mime[] = sprintf('Content-Transfer-Encoding: %s%s', $encoding, $this->LE);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ($disposition == 'inline') {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $mime[] = sprintf('Content-ID: <%s>%s', $cid, $this->LE);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If a filename contains any of these chars, it should be quoted,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2074,20 +2624,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Fixes a warning in IETF's msglint MIME checker
</span><span class="cx" style="display: block; padding: 0 10px"> // Allow for bypassing the Content-Disposition header totally
</span><span class="cx" style="display: block; padding: 0 10px"> if (!(empty($disposition))) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $name)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encoded_name = $this->encodeHeader($this->secureHeader($name));
+ if (preg_match('/[ \(\)<>@,;:\\"\/\[\]\?=]/', $encoded_name)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $mime[] = sprintf(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "Content-Disposition: %s; filename=\"%s\"%s",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'Content-Disposition: %s; filename="%s"%s',
</ins><span class="cx" style="display: block; padding: 0 10px"> $disposition,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->encodeHeader($this->secureHeader($name)),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encoded_name,
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->LE . $this->LE
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mime[] = sprintf(
- "Content-Disposition: %s; filename=%s%s",
- $disposition,
- $this->encodeHeader($this->secureHeader($name)),
- $this->LE . $this->LE
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($encoded_name)) {
+ $mime[] = sprintf(
+ 'Content-Disposition: %s; filename=%s%s',
+ $disposition,
+ $encoded_name,
+ $this->LE . $this->LE
+ );
+ } else {
+ $mime[] = sprintf(
+ 'Content-Disposition: %s%s',
+ $disposition,
+ $this->LE . $this->LE
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $mime[] = $this->LE;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2110,9 +2669,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mime[] = sprintf("--%s--%s", $boundary, $this->LE);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $mime[] = sprintf('--%s--%s', $boundary, $this->LE);
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return implode("", $mime);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return implode('', $mime);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2121,7 +2680,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $path The full path to the file
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @see EncodeFile(encodeFile
</del><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2134,9 +2692,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $magic_quotes = get_magic_quotes_runtime();
</span><span class="cx" style="display: block; padding: 0 10px"> if ($magic_quotes) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (version_compare(PHP_VERSION, '5.3.0', '<')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- set_magic_quotes_runtime(0);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_magic_quotes_runtime(false);
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ini_set('magic_quotes_runtime', 0);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Doesn't exist in PHP 5.4, but we don't need to check because
+ //get_magic_quotes_runtime always returns false in 5.4+
+ //so it will never get here
+ ini_set('magic_quotes_runtime', false);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $file_buffer = file_get_contents($path);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2149,8 +2710,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $file_buffer;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } catch (Exception $e) {
- $this->setError($e->getMessage());
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } catch (Exception $exc) {
+ $this->setError($exc->getMessage());
</ins><span class="cx" style="display: block; padding: 0 10px"> return '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2173,7 +2734,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> case '7bit':
</span><span class="cx" style="display: block; padding: 0 10px"> case '8bit':
</span><span class="cx" style="display: block; padding: 0 10px"> $encoded = $this->fixEOL($str);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Make sure it ends with a line break
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure it ends with a line break
</ins><span class="cx" style="display: block; padding: 0 10px"> if (substr($encoded, -(strlen($this->LE))) != $this->LE) {
</span><span class="cx" style="display: block; padding: 0 10px"> $encoded .= $this->LE;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2201,11 +2762,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function encodeHeader($str, $position = 'text')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $x = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $matchcount = 0;
</ins><span class="cx" style="display: block; padding: 0 10px"> switch (strtolower($position)) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'phrase':
</span><span class="cx" style="display: block; padding: 0 10px"> if (!preg_match('/[\200-\377]/', $str)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Can't use addslashes as we don't know what value has magic_quotes_sybase
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Can't use addslashes as we don't know the value of magic_quotes_sybase
</ins><span class="cx" style="display: block; padding: 0 10px"> $encoded = addcslashes($str, "\0..\37\177\\\"");
</span><span class="cx" style="display: block; padding: 0 10px"> if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) {
</span><span class="cx" style="display: block; padding: 0 10px"> return ($encoded);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2213,26 +2774,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return ("\"$encoded\"");
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $matchcount = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> /** @noinspection PhpMissingBreakStatementInspection */
</span><span class="cx" style="display: block; padding: 0 10px"> case 'comment':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $x = preg_match_all('/[()"]/', $str, $matches);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $matchcount = preg_match_all('/[()"]/', $str, $matches);
</ins><span class="cx" style="display: block; padding: 0 10px"> // Intentional fall-through
</span><span class="cx" style="display: block; padding: 0 10px"> case 'text':
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $matchcount += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($x == 0) { //There are no chars that need encoding
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //There are no chars that need encoding
+ if ($matchcount == 0) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return ($str);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $maxlen = 75 - 7 - strlen($this->CharSet);
</span><span class="cx" style="display: block; padding: 0 10px"> // Try to select the encoding which should produce the shortest output
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($x > strlen($str) / 3) {
- //More than a third of the content will need encoding, so B encoding will be most efficient
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($matchcount > strlen($str) / 3) {
+ // More than a third of the content will need encoding, so B encoding will be most efficient
</ins><span class="cx" style="display: block; padding: 0 10px"> $encoding = 'B';
</span><span class="cx" style="display: block; padding: 0 10px"> if (function_exists('mb_strlen') && $this->hasMultiBytes($str)) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Use a custom function which correctly encodes and wraps long
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2250,7 +2812,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $encoded = str_replace('=' . self::CRLF, "\n", trim($encoded));
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $encoded = preg_replace('/^(.*)$/m', " =?" . $this->CharSet . "?$encoding?\\1?=", $encoded);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encoded = preg_replace('/^(.*)$/m', ' =?' . $this->CharSet . "?$encoding?\\1?=", $encoded);
</ins><span class="cx" style="display: block; padding: 0 10px"> $encoded = trim(str_replace("\n", $this->LE, $encoded));
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $encoded;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2260,7 +2822,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Check if a string contains multi-byte characters.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $str multi-byte text to wrap encode
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function hasMultiBytes($str)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2272,21 +2834,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Does a string contain any 8-bit chars (in any charset)?
+ * @param string $text
+ * @return boolean
+ */
+ public function has8bitChars($text)
+ {
+ return (boolean)preg_match('/[\x80-\xFF]/', $text);
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Encode and wrap long multibyte strings for mail headers
</span><span class="cx" style="display: block; padding: 0 10px"> * without breaking lines within a character.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Adapted from a function by paravoid
+ * @link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $str multi-byte text to wrap encode
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $lf string to use as linefeed/end-of-line
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $linebreak string to use as linefeed/end-of-line
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function base64EncodeWrapMB($str, $lf = null)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function base64EncodeWrapMB($str, $linebreak = null)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $start = "=?" . $this->CharSet . "?B?";
- $end = "?=";
- $encoded = "";
- if ($lf === null) {
- $lf = $this->LE;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $start = '=?' . $this->CharSet . '?B?';
+ $end = '?=';
+ $encoded = '';
+ if ($linebreak === null) {
+ $linebreak = $this->LE;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $mb_length = mb_strlen($str, $this->CharSet);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2305,11 +2878,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $chunk = base64_encode($chunk);
</span><span class="cx" style="display: block; padding: 0 10px"> $lookBack++;
</span><span class="cx" style="display: block; padding: 0 10px"> } while (strlen($chunk) > $length);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $encoded .= $chunk . $lf;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encoded .= $chunk . $linebreak;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Chomp the last linefeed
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $encoded = substr($encoded, 0, -strlen($lf));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $encoded = substr($encoded, 0, -strlen($linebreak));
</ins><span class="cx" style="display: block; padding: 0 10px"> return $encoded;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2320,21 +2893,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $string The text to encode
</span><span class="cx" style="display: block; padding: 0 10px"> * @param integer $line_max Number of chars allowed on a line before wrapping
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @link PHP version adapted from http://www.php.net/manual/en/function.quoted-printable-decode.php#89417
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @link http://www.php.net/manual/en/function.quoted-printable-decode.php#89417 Adapted from this comment
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function encodeQP($string, $line_max = 76)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Use native function if it's available (>= PHP5.3)
+ if (function_exists('quoted_printable_encode')) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return quoted_printable_encode($string);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Fall back to a pure PHP implementation
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Fall back to a pure PHP implementation
</ins><span class="cx" style="display: block; padding: 0 10px"> $string = str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> array('%20', '%0D%0A.', '%0D%0A', '%'),
</span><span class="cx" style="display: block; padding: 0 10px"> array(' ', "\r\n=2E", "\r\n", '='),
</span><span class="cx" style="display: block; padding: 0 10px"> rawurlencode($string)
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $string = preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
- return $string;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return preg_replace('/[^\r\n]{' . ($line_max - 3) . '}[^=\r\n]{2}/', "$0=\r\n", $string);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2343,7 +2916,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $string
</span><span class="cx" style="display: block; padding: 0 10px"> * @param integer $line_max
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $space_conv
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $space_conv
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> * @deprecated Use encodeQP instead.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2365,45 +2938,44 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function encodeQ($str, $position = 'text')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //There should not be any EOL in the string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // There should not be any EOL in the string
</ins><span class="cx" style="display: block; padding: 0 10px"> $pattern = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $encoded = str_replace(array("\r", "\n"), '', $str);
</span><span class="cx" style="display: block; padding: 0 10px"> switch (strtolower($position)) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'phrase':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //RFC 2047 section 5.3
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC 2047 section 5.3
</ins><span class="cx" style="display: block; padding: 0 10px"> $pattern = '^A-Za-z0-9!*+\/ -';
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> /** @noinspection PhpMissingBreakStatementInspection */
</span><span class="cx" style="display: block; padding: 0 10px"> case 'comment':
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //RFC 2047 section 5.2
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC 2047 section 5.2
</ins><span class="cx" style="display: block; padding: 0 10px"> $pattern = '\(\)"';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //intentional fall-through
- //for this reason we build the $pattern without including delimiters and []
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // intentional fall-through
+ // for this reason we build the $pattern without including delimiters and []
</ins><span class="cx" style="display: block; padding: 0 10px"> case 'text':
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //RFC 2047 section 5.1
- //Replace every high ascii, control, =, ? and _ characters
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // RFC 2047 section 5.1
+ // Replace every high ascii, control, =, ? and _ characters
</ins><span class="cx" style="display: block; padding: 0 10px"> $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $matches = array();
</span><span class="cx" style="display: block; padding: 0 10px"> if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If the string contains an '=', make sure it's the first thing we replace
- //so as to avoid double-encoding
- $s = array_search('=', $matches[0]);
- if ($s !== false) {
- unset($matches[0][$s]);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If the string contains an '=', make sure it's the first thing we replace
+ // so as to avoid double-encoding
+ $eqkey = array_search('=', $matches[0]);
+ if (false !== $eqkey) {
+ unset($matches[0][$eqkey]);
</ins><span class="cx" style="display: block; padding: 0 10px"> array_unshift($matches[0], '=');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> foreach (array_unique($matches[0]) as $char) {
</span><span class="cx" style="display: block; padding: 0 10px"> $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Replace every spaces to _ (more readable than =20)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Replace every spaces to _ (more readable than =20)
</ins><span class="cx" style="display: block; padding: 0 10px"> return str_replace(' ', '_', $encoded);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add a string or binary attachment (non-filesystem).
</span><span class="cx" style="display: block; padding: 0 10px"> * This method can be used to attach ascii or binary data,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2422,7 +2994,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $type = '',
</span><span class="cx" style="display: block; padding: 0 10px"> $disposition = 'attachment'
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If a MIME type is not specified, try to work it out from the file name
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If a MIME type is not specified, try to work it out from the file name
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($type == '') {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = self::filenameToType($filename);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2442,7 +3014,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Add an embedded (inline) attachment from a file.
</span><span class="cx" style="display: block; padding: 0 10px"> * This can include images, sounds, and just about any other document type.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * These differ from 'regular' attachmants in that they are intended to be
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * These differ from 'regular' attachments in that they are intended to be
</ins><span class="cx" style="display: block; padding: 0 10px"> * displayed inline with the message, not just attached for download.
</span><span class="cx" style="display: block; padding: 0 10px"> * This is used in HTML messages that embed the images
</span><span class="cx" style="display: block; padding: 0 10px"> * the HTML refers to using the $cid value.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2453,7 +3025,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $encoding File encoding (see $Encoding).
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $type File MIME type.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $disposition Disposition to use
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True on successfully adding an attachment
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True on successfully adding an attachment
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2462,7 +3034,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If a MIME type is not specified, try to work it out from the file name
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If a MIME type is not specified, try to work it out from the file name
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($type == '') {
</span><span class="cx" style="display: block; padding: 0 10px"> $type = self::filenameToType($path);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2498,7 +3070,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $encoding File encoding (see $Encoding).
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $type MIME type.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $disposition Disposition to use
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True on successfully adding an attachment
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True on successfully adding an attachment
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function addStringEmbeddedImage(
</span><span class="cx" style="display: block; padding: 0 10px"> $string,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2508,8 +3080,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $type = '',
</span><span class="cx" style="display: block; padding: 0 10px"> $disposition = 'inline'
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //If a MIME type is not specified, try to work it out from the name
- if ($type == '') {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If a MIME type is not specified, try to work it out from the name
+ if ($type == '' and !empty($name)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $type = self::filenameToType($name);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2530,7 +3102,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check if an inline attachment is present.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function inlineImageExists()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2544,7 +3116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check if an attachment (non-inline) is present.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function attachmentExists()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2558,7 +3130,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check if this message has an alternative body set.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function alternativeExists()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2566,6 +3138,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Clear queued addresses of given kind.
+ * @access protected
+ * @param string $kind 'to', 'cc', or 'bcc'
+ * @return void
+ */
+ public function clearQueuedAddresses($kind)
+ {
+ $RecipientsQueue = $this->RecipientsQueue;
+ foreach ($RecipientsQueue as $address => $params) {
+ if ($params[0] == $kind) {
+ unset($this->RecipientsQueue[$address]);
+ }
+ }
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Clear all To recipients.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2575,6 +3163,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset($this->all_recipients[strtolower($to[0])]);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->to = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->clearQueuedAddresses('to');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2587,6 +3176,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset($this->all_recipients[strtolower($cc[0])]);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->cc = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->clearQueuedAddresses('cc');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2599,6 +3189,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unset($this->all_recipients[strtolower($bcc[0])]);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->bcc = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->clearQueuedAddresses('bcc');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2608,6 +3199,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function clearReplyTos()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ReplyTo = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->ReplyToQueue = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2620,6 +3212,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->cc = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->bcc = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $this->all_recipients = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->RecipientsQueue = array();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2651,8 +3244,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->error_count++;
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $lasterror = $this->smtp->getError();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
- $msg .= '<p>' . $this->lang('smtp_error') . $lasterror['smtp_msg'] . "</p>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($lasterror['error'])) {
+ $msg .= $this->lang('smtp_error') . $lasterror['error'];
+ if (!empty($lasterror['detail'])) {
+ $msg .= ' Detail: '. $lasterror['detail'];
+ }
+ if (!empty($lasterror['smtp_code'])) {
+ $msg .= ' SMTP code: ' . $lasterror['smtp_code'];
+ }
+ if (!empty($lasterror['smtp_code_ex'])) {
+ $msg .= ' Additional SMTP info: ' . $lasterror['smtp_code_ex'];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ErrorInfo = $msg;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2666,8 +3268,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function rfcDate()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Set the time zone to whatever the default is to avoid 500 errors
- //Will default to UTC if it's not set properly in php.ini
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Set the time zone to whatever the default is to avoid 500 errors
+ // Will default to UTC if it's not set properly in php.ini
</ins><span class="cx" style="display: block; padding: 0 10px"> date_default_timezone_set(@date_default_timezone_get());
</span><span class="cx" style="display: block; padding: 0 10px"> return date('D, j M Y H:i:s O');
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2680,14 +3282,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function serverHostname()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = 'localhost.localdomain';
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!empty($this->Hostname)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->Hostname;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif (isset($_SERVER['SERVER_NAME'])) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $result = $_SERVER['SERVER_NAME'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- $result = 'localhost.localdomain';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (function_exists('gethostname') && gethostname() !== false) {
+ $result = gethostname();
+ } elseif (php_uname('n') !== false) {
+ $result = php_uname('n');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> return $result;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2703,17 +3307,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setLanguage('en'); // set the default language
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (isset($this->language[$key])) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (array_key_exists($key, $this->language)) {
+ if ($key == 'smtp_connect_failed') {
+ //Include a link to troubleshooting docs on SMTP connection failure
+ //this is by far the biggest cause of support questions
+ //but it's usually not PHPMailer's fault.
+ return $this->language[$key] . ' https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->language[$key];
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return 'Language string failed to load: ' . $key;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Return the key as a fallback
+ return $key;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check if an error occurred.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True if an error did occur.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True if an error did occur.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function isError()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2758,29 +3369,58 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Create a message from an HTML string.
- * Automatically makes modifications for inline images and backgrounds
- * and creates a plain-text version by converting the HTML.
- * Overwrites any existing values in $this->Body and $this->AltBody
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns all custom headers.
+ * @return array
+ */
+ public function getCustomHeaders()
+ {
+ return $this->CustomHeader;
+ }
+
+ /**
+ * Create a message body from an HTML string.
+ * Automatically inlines images and creates a plain-text version by converting the HTML,
+ * overwriting any existing values in Body and AltBody.
+ * $basedir is used when handling relative image paths, e.g. <img src="images/a.png">
+ * will look for an image file in $basedir/images/a.png and convert it to inline.
+ * If you don't want to apply these transformations to your HTML, just set Body and AltBody yourself.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $message HTML message string
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $basedir baseline directory for path
- * @param bool $advanced Whether to use the advanced HTML to text converter
- * @return string $message
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $basedir base directory for relative paths to images
+ * @param boolean|callable $advanced Whether to use the internal HTML to text converter
+ * or your own custom converter @see PHPMailer::html2text()
+ * @return string $message The transformed message Body
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function msgHTML($message, $basedir = '', $advanced = false)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- preg_match_all("/(src|background)=[\"'](.*)[\"']/Ui", $message, $images);
- if (isset($images[2])) {
- foreach ($images[2] as $i => $url) {
- // do not change urls for absolute images (thanks to corvuscorax)
- if (!preg_match('#^[A-z]+://#', $url)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
+ if (array_key_exists(2, $images)) {
+ foreach ($images[2] as $imgindex => $url) {
+ // Convert data URIs into embedded images
+ if (preg_match('#^data:(image[^;,]*)(;base64)?,#', $url, $match)) {
+ $data = substr($url, strpos($url, ','));
+ if ($match[2]) {
+ $data = base64_decode($data);
+ } else {
+ $data = rawurldecode($data);
+ }
+ $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
+ if ($this->addStringEmbeddedImage($data, $cid, 'embed' . $imgindex, 'base64', $match[1])) {
+ $message = str_replace(
+ $images[0][$imgindex],
+ $images[1][$imgindex] . '="cid:' . $cid . '"',
+ $message
+ );
+ }
+ } elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[a-z][a-z0-9+.-]*://#i', $url)) {
+ // Do not change urls for absolute images (thanks to corvuscorax)
+ // Do not change urls that are already inline images
</ins><span class="cx" style="display: block; padding: 0 10px"> $filename = basename($url);
</span><span class="cx" style="display: block; padding: 0 10px"> $directory = dirname($url);
</span><span class="cx" style="display: block; padding: 0 10px"> if ($directory == '.') {
</span><span class="cx" style="display: block; padding: 0 10px"> $directory = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cid = md5($url) . '@phpmailer.0'; //RFC2392 S 2
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cid = md5($url) . '@phpmailer.0'; // RFC2392 S 2
</ins><span class="cx" style="display: block; padding: 0 10px"> if (strlen($basedir) > 1 && substr($basedir, -1) != '/') {
</span><span class="cx" style="display: block; padding: 0 10px"> $basedir .= '/';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2792,12 +3432,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cid,
</span><span class="cx" style="display: block; padding: 0 10px"> $filename,
</span><span class="cx" style="display: block; padding: 0 10px"> 'base64',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- self::_mime_types(self::mb_pathinfo($filename, PATHINFO_EXTENSION))
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::_mime_types((string)self::mb_pathinfo($filename, PATHINFO_EXTENSION))
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $message = preg_replace(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "/" . $images[1][$i] . "=[\"']" . preg_quote($url, '/') . "[\"']/Ui",
- $images[1][$i] . "=\"cid:" . $cid . "\"",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '/' . $images[1][$imgindex] . '=["\']' . preg_quote($url, '/') . '["\']/Ui',
+ $images[1][$imgindex] . '="cid:' . $cid . '"',
</ins><span class="cx" style="display: block; padding: 0 10px"> $message
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2805,27 +3445,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->isHTML(true);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (empty($this->AltBody)) {
- $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n";
- }
- //Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Convert all message body line breaks to CRLF, makes quoted-printable encoding work much better
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->Body = $this->normalizeBreaks($message);
</span><span class="cx" style="display: block; padding: 0 10px"> $this->AltBody = $this->normalizeBreaks($this->html2text($message, $advanced));
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$this->alternativeExists()) {
+ $this->AltBody = 'To view this email message, open it in a program that understands HTML!' .
+ self::CRLF . self::CRLF;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> return $this->Body;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Convert an HTML string into plain text.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This is used by msgHTML().
+ * Note - older versions of this function used a bundled advanced converter
+ * which was been removed for license reasons in #232.
+ * Example usage:
+ * <code>
+ * // Use default conversion
+ * $plain = $mail->html2text($html);
+ * // Use your own custom converter
+ * $plain = $mail->html2text($html, function($html) {
+ * $converter = new MyHtml2text($html);
+ * return $converter->get_text();
+ * });
+ * </code>
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $html The HTML text to convert
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $advanced Should this use the more complex html2text converter or just a simple one?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean|callable $advanced Any boolean value to use the internal converter,
+ * or provide your own callable for custom conversion.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function html2text($html, $advanced = false)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($advanced) {
- require_once 'extras/class.html2text.php';
- $h = new html2text($html);
- return $h->get_text();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_callable($advanced)) {
+ return call_user_func($advanced, $html);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return html_entity_decode(
</span><span class="cx" style="display: block; padding: 0 10px"> trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2844,94 +3497,109 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public static function _mime_types($ext = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $mimes = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'xl' => 'application/excel',
- 'hqx' => 'application/mac-binhex40',
- 'cpt' => 'application/mac-compactpro',
- 'bin' => 'application/macbinary',
- 'doc' => 'application/msword',
- 'word' => 'application/msword',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'xl' => 'application/excel',
+ 'js' => 'application/javascript',
+ 'hqx' => 'application/mac-binhex40',
+ 'cpt' => 'application/mac-compactpro',
+ 'bin' => 'application/macbinary',
+ 'doc' => 'application/msword',
+ 'word' => 'application/msword',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
+ 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
+ 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
+ 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
+ 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'class' => 'application/octet-stream',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'dll' => 'application/octet-stream',
- 'dms' => 'application/octet-stream',
- 'exe' => 'application/octet-stream',
- 'lha' => 'application/octet-stream',
- 'lzh' => 'application/octet-stream',
- 'psd' => 'application/octet-stream',
- 'sea' => 'application/octet-stream',
- 'so' => 'application/octet-stream',
- 'oda' => 'application/oda',
- 'pdf' => 'application/pdf',
- 'ai' => 'application/postscript',
- 'eps' => 'application/postscript',
- 'ps' => 'application/postscript',
- 'smi' => 'application/smil',
- 'smil' => 'application/smil',
- 'mif' => 'application/vnd.mif',
- 'xls' => 'application/vnd.ms-excel',
- 'ppt' => 'application/vnd.ms-powerpoint',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'dll' => 'application/octet-stream',
+ 'dms' => 'application/octet-stream',
+ 'exe' => 'application/octet-stream',
+ 'lha' => 'application/octet-stream',
+ 'lzh' => 'application/octet-stream',
+ 'psd' => 'application/octet-stream',
+ 'sea' => 'application/octet-stream',
+ 'so' => 'application/octet-stream',
+ 'oda' => 'application/oda',
+ 'pdf' => 'application/pdf',
+ 'ai' => 'application/postscript',
+ 'eps' => 'application/postscript',
+ 'ps' => 'application/postscript',
+ 'smi' => 'application/smil',
+ 'smil' => 'application/smil',
+ 'mif' => 'application/vnd.mif',
+ 'xls' => 'application/vnd.ms-excel',
+ 'ppt' => 'application/vnd.ms-powerpoint',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'wbxml' => 'application/vnd.wap.wbxml',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wmlc' => 'application/vnd.wap.wmlc',
- 'dcr' => 'application/x-director',
- 'dir' => 'application/x-director',
- 'dxr' => 'application/x-director',
- 'dvi' => 'application/x-dvi',
- 'gtar' => 'application/x-gtar',
- 'php3' => 'application/x-httpd-php',
- 'php4' => 'application/x-httpd-php',
- 'php' => 'application/x-httpd-php',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wmlc' => 'application/vnd.wap.wmlc',
+ 'dcr' => 'application/x-director',
+ 'dir' => 'application/x-director',
+ 'dxr' => 'application/x-director',
+ 'dvi' => 'application/x-dvi',
+ 'gtar' => 'application/x-gtar',
+ 'php3' => 'application/x-httpd-php',
+ 'php4' => 'application/x-httpd-php',
+ 'php' => 'application/x-httpd-php',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'phtml' => 'application/x-httpd-php',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'phps' => 'application/x-httpd-php-source',
- 'js' => 'application/x-javascript',
- 'swf' => 'application/x-shockwave-flash',
- 'sit' => 'application/x-stuffit',
- 'tar' => 'application/x-tar',
- 'tgz' => 'application/x-tar',
- 'xht' => 'application/xhtml+xml',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'phps' => 'application/x-httpd-php-source',
+ 'swf' => 'application/x-shockwave-flash',
+ 'sit' => 'application/x-stuffit',
+ 'tar' => 'application/x-tar',
+ 'tgz' => 'application/x-tar',
+ 'xht' => 'application/xhtml+xml',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'xhtml' => 'application/xhtml+xml',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'zip' => 'application/zip',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mp2' => 'audio/mpeg',
- 'mp3' => 'audio/mpeg',
- 'mpga' => 'audio/mpeg',
- 'aif' => 'audio/x-aiff',
- 'aifc' => 'audio/x-aiff',
- 'aiff' => 'audio/x-aiff',
- 'ram' => 'audio/x-pn-realaudio',
- 'rm' => 'audio/x-pn-realaudio',
- 'rpm' => 'audio/x-pn-realaudio-plugin',
- 'ra' => 'audio/x-realaudio',
- 'wav' => 'audio/x-wav',
- 'bmp' => 'image/bmp',
- 'gif' => 'image/gif',
- 'jpeg' => 'image/jpeg',
- 'jpe' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'png' => 'image/png',
- 'tiff' => 'image/tiff',
- 'tif' => 'image/tiff',
- 'eml' => 'message/rfc822',
- 'css' => 'text/css',
- 'html' => 'text/html',
- 'htm' => 'text/html',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'zip' => 'application/zip',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mp2' => 'audio/mpeg',
+ 'mp3' => 'audio/mpeg',
+ 'mpga' => 'audio/mpeg',
+ 'aif' => 'audio/x-aiff',
+ 'aifc' => 'audio/x-aiff',
+ 'aiff' => 'audio/x-aiff',
+ 'ram' => 'audio/x-pn-realaudio',
+ 'rm' => 'audio/x-pn-realaudio',
+ 'rpm' => 'audio/x-pn-realaudio-plugin',
+ 'ra' => 'audio/x-realaudio',
+ 'wav' => 'audio/x-wav',
+ 'bmp' => 'image/bmp',
+ 'gif' => 'image/gif',
+ 'jpeg' => 'image/jpeg',
+ 'jpe' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'png' => 'image/png',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'eml' => 'message/rfc822',
+ 'css' => 'text/css',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'shtml' => 'text/html',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'log' => 'text/plain',
- 'text' => 'text/plain',
- 'txt' => 'text/plain',
- 'rtx' => 'text/richtext',
- 'rtf' => 'text/rtf',
- 'xml' => 'text/xml',
- 'xsl' => 'text/xml',
- 'mpeg' => 'video/mpeg',
- 'mpe' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mov' => 'video/quicktime',
- 'qt' => 'video/quicktime',
- 'rv' => 'video/vnd.rn-realvideo',
- 'avi' => 'video/x-msvideo',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'log' => 'text/plain',
+ 'text' => 'text/plain',
+ 'txt' => 'text/plain',
+ 'rtx' => 'text/richtext',
+ 'rtf' => 'text/rtf',
+ 'vcf' => 'text/vcard',
+ 'vcard' => 'text/vcard',
+ 'xml' => 'text/xml',
+ 'xsl' => 'text/xml',
+ 'mpeg' => 'video/mpeg',
+ 'mpe' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mov' => 'video/quicktime',
+ 'qt' => 'video/quicktime',
+ 'rv' => 'video/vnd.rn-realvideo',
+ 'avi' => 'video/x-msvideo',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'movie' => 'video/x-sgi-movie'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (array_key_exists(strtolower($ext), $mimes)) {
+ return $mimes[strtolower($ext)];
+ }
+ return 'application/octet-stream';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2943,9 +3611,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public static function filenameToType($filename)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //In case the path is a URL, strip any query string before getting extension
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // In case the path is a URL, strip any query string before getting extension
</ins><span class="cx" style="display: block; padding: 0 10px"> $qpos = strpos($filename, '?');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($qpos !== false) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (false !== $qpos) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $filename = substr($filename, 0, $qpos);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $pathinfo = self::mb_pathinfo($filename);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2966,37 +3634,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public static function mb_pathinfo($path, $options = null)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $ret = array('dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $m = array();
- preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m);
- if (array_key_exists(1, $m)) {
- $ret['dirname'] = $m[1];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $pathinfo = array();
+ if (preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $pathinfo)) {
+ if (array_key_exists(1, $pathinfo)) {
+ $ret['dirname'] = $pathinfo[1];
+ }
+ if (array_key_exists(2, $pathinfo)) {
+ $ret['basename'] = $pathinfo[2];
+ }
+ if (array_key_exists(5, $pathinfo)) {
+ $ret['extension'] = $pathinfo[5];
+ }
+ if (array_key_exists(3, $pathinfo)) {
+ $ret['filename'] = $pathinfo[3];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (array_key_exists(2, $m)) {
- $ret['basename'] = $m[2];
- }
- if (array_key_exists(5, $m)) {
- $ret['extension'] = $m[5];
- }
- if (array_key_exists(3, $m)) {
- $ret['filename'] = $m[3];
- }
</del><span class="cx" style="display: block; padding: 0 10px"> switch ($options) {
</span><span class="cx" style="display: block; padding: 0 10px"> case PATHINFO_DIRNAME:
</span><span class="cx" style="display: block; padding: 0 10px"> case 'dirname':
</span><span class="cx" style="display: block; padding: 0 10px"> return $ret['dirname'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case PATHINFO_BASENAME:
</span><span class="cx" style="display: block; padding: 0 10px"> case 'basename':
</span><span class="cx" style="display: block; padding: 0 10px"> return $ret['basename'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case PATHINFO_EXTENSION:
</span><span class="cx" style="display: block; padding: 0 10px"> case 'extension':
</span><span class="cx" style="display: block; padding: 0 10px"> return $ret['extension'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case PATHINFO_FILENAME:
</span><span class="cx" style="display: block; padding: 0 10px"> case 'filename':
</span><span class="cx" style="display: block; padding: 0 10px"> return $ret['filename'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><span class="cx" style="display: block; padding: 0 10px"> default:
</span><span class="cx" style="display: block; padding: 0 10px"> return $ret;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3004,33 +3669,27 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Set or reset instance properties.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * You should avoid this function - it's more verbose, less efficient, more error-prone and
+ * harder to debug than setting properties directly.
</ins><span class="cx" style="display: block; padding: 0 10px"> * Usage Example:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * $page->set('X-Priority', '3');
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * `$mail->set('SMTPSecure', 'tls');`
+ * is the same as:
+ * `$mail->SMTPSecure = 'tls';`
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $name
- * @param mixed $value
- * NOTE: will not work with arrays, there are no arrays to set/reset
- * @throws phpmailerException
- * @return bool
- * @todo Should this not be using __set() magic function?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $name The property name to set
+ * @param mixed $value The value to set the property to
+ * @return boolean
+ * @TODO Should this not be using the __set() magic function?
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set($name, $value = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- try {
- if (isset($this->$name)) {
- $this->$name = $value;
- } else {
- throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL);
- }
- } catch (Exception $e) {
- $this->setError($e->getMessage());
- if ($e->getCode() == self::STOP_CRITICAL) {
- return false;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (property_exists($this, $name)) {
+ $this->$name = $value;
+ return true;
+ } else {
+ $this->setError($this->lang('variable_set') . $name);
+ return false;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return true;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3059,19 +3718,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return preg_replace('/(\r\n|\r|\n)/ms', $breaktype, $text);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Set the private key file and password for S/MIME signing.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Set the public and private key files and password for S/MIME signing.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $cert_filename
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $key_filename
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $key_pass Password for private key
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $extracerts_filename Optional path to chain certificate
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function sign($cert_filename, $key_filename, $key_pass)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '')
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sign_cert_file = $cert_filename;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sign_key_file = $key_filename;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->sign_key_pass = $key_pass;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->sign_extracerts_file = $extracerts_filename;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3088,7 +3748,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (((0x21 <= $ord) && ($ord <= 0x3A)) || $ord == 0x3C || ((0x3E <= $ord) && ($ord <= 0x7E))) {
</span><span class="cx" style="display: block; padding: 0 10px"> $line .= $txt[$i];
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $line .= "=" . sprintf("%02X", $ord);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $line .= '=' . sprintf('%02X', $ord);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $line;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3097,48 +3757,68 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generate a DKIM signature.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $s Header
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $signHeader
</ins><span class="cx" style="display: block; padding: 0 10px"> * @throws phpmailerException
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string The DKIM signature value
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function DKIM_Sign($s)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function DKIM_Sign($signHeader)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!defined('PKCS7_TEXT')) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->exceptions) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- throw new phpmailerException($this->lang("signing") . ' OpenSSL extension missing.');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new phpmailerException($this->lang('extension_missing') . 'openssl');
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $privKeyStr = file_get_contents($this->DKIM_private);
- if ($this->DKIM_passphrase != '') {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $privKeyStr = !empty($this->DKIM_private_string) ? $this->DKIM_private_string : file_get_contents($this->DKIM_private);
+ if ('' != $this->DKIM_passphrase) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $privKey = openssl_pkey_get_private($privKeyStr, $this->DKIM_passphrase);
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $privKey = $privKeyStr;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $privKey = openssl_pkey_get_private($privKeyStr);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (openssl_sign($s, $signature, $privKey)) {
- return base64_encode($signature);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Workaround for missing digest algorithms in old PHP & OpenSSL versions
+ //@link http://stackoverflow.com/a/11117338/333340
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0 and
+ in_array('sha256WithRSAEncryption', openssl_get_md_methods(true))) {
+ if (openssl_sign($signHeader, $signature, $privKey, 'sha256WithRSAEncryption')) {
+ openssl_pkey_free($privKey);
+ return base64_encode($signature);
+ }
+ } else {
+ $pinfo = openssl_pkey_get_details($privKey);
+ $hash = hash('sha256', $signHeader);
+ //'Magic' constant for SHA256 from RFC3447
+ //@link https://tools.ietf.org/html/rfc3447#page-43
+ $t = '3031300d060960864801650304020105000420' . $hash;
+ $pslen = $pinfo['bits'] / 8 - (strlen($t) / 2 + 3);
+ $eb = pack('H*', '0001' . str_repeat('FF', $pslen) . '00' . $t);
+
+ if (openssl_private_encrypt($eb, $signature, $privKey, OPENSSL_NO_PADDING)) {
+ openssl_pkey_free($privKey);
+ return base64_encode($signature);
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ openssl_pkey_free($privKey);
</ins><span class="cx" style="display: block; padding: 0 10px"> return '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Generate a DKIM canonicalization header.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $s Header
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $signHeader Header
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function DKIM_HeaderC($s)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function DKIM_HeaderC($signHeader)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $s = preg_replace("/\r\n\s+/", " ", $s);
- $lines = explode("\r\n", $s);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $signHeader = preg_replace('/\r\n\s+/', ' ', $signHeader);
+ $lines = explode("\r\n", $signHeader);
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ($lines as $key => $line) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- list($heading, $value) = explode(":", $line, 2);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ list($heading, $value) = explode(':', $line, 2);
</ins><span class="cx" style="display: block; padding: 0 10px"> $heading = strtolower($heading);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $value = preg_replace("/\s+/", " ", $value); // Compress useless spaces
- $lines[$key] = $heading . ":" . trim($value); // Don't forget to remove WSP around the value
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces
+ $lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $s = implode("\r\n", $lines);
- return $s;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $signHeader = implode("\r\n", $lines);
+ return $signHeader;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3172,7 +3852,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function DKIM_Add($headers_line, $subject, $body)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $DKIMsignatureType = 'rsa-sha256'; // Signature & hash algorithms
</ins><span class="cx" style="display: block; padding: 0 10px"> $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body
</span><span class="cx" style="display: block; padding: 0 10px"> $DKIMquery = 'dns/txt'; // Query method
</span><span class="cx" style="display: block; padding: 0 10px"> $DKIMtime = time(); // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3180,6 +3860,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = explode($this->LE, $headers_line);
</span><span class="cx" style="display: block; padding: 0 10px"> $from_header = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $to_header = '';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $date_header = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> $current = '';
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ($headers as $header) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (strpos($header, 'From:') === 0) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3188,9 +3869,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif (strpos($header, 'To:') === 0) {
</span><span class="cx" style="display: block; padding: 0 10px"> $to_header = $header;
</span><span class="cx" style="display: block; padding: 0 10px"> $current = 'to_header';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif (strpos($header, 'Date:') === 0) {
+ $date_header = $header;
+ $current = 'date_header';
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($current && strpos($header, ' =?') === 0) {
- $current .= $header;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($$current) && strpos($header, ' =?') === 0) {
+ $$current .= $header;
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $current = '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3198,6 +3882,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $from = str_replace('|', '=7C', $this->DKIM_QP($from_header));
</span><span class="cx" style="display: block; padding: 0 10px"> $to = str_replace('|', '=7C', $this->DKIM_QP($to_header));
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $date = str_replace('|', '=7C', $this->DKIM_QP($date_header));
</ins><span class="cx" style="display: block; padding: 0 10px"> $subject = str_replace(
</span><span class="cx" style="display: block; padding: 0 10px"> '|',
</span><span class="cx" style="display: block; padding: 0 10px"> '=7C',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3205,40 +3890,116 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ); // Copied header fields (dkim-quoted-printable)
</span><span class="cx" style="display: block; padding: 0 10px"> $body = $this->DKIM_BodyC($body);
</span><span class="cx" style="display: block; padding: 0 10px"> $DKIMlen = strlen($body); // Length of body
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $DKIMb64 = base64_encode(pack("H*", sha1($body))); // Base64 of packed binary SHA-1 hash of body
- $ident = ($this->DKIM_identity == '') ? '' : " i=" . $this->DKIM_identity . ";";
- $dkimhdrs = "DKIM-Signature: v=1; a=" .
- $DKIMsignatureType . "; q=" .
- $DKIMquery . "; l=" .
- $DKIMlen . "; s=" .
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $DKIMb64 = base64_encode(pack('H*', hash('sha256', $body))); // Base64 of packed binary SHA-256 hash of body
+ if ('' == $this->DKIM_identity) {
+ $ident = '';
+ } else {
+ $ident = ' i=' . $this->DKIM_identity . ';';
+ }
+ $dkimhdrs = 'DKIM-Signature: v=1; a=' .
+ $DKIMsignatureType . '; q=' .
+ $DKIMquery . '; l=' .
+ $DKIMlen . '; s=' .
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->DKIM_selector .
</span><span class="cx" style="display: block; padding: 0 10px"> ";\r\n" .
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n" .
- "\th=From:To:Subject;\r\n" .
- "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n" .
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "\tt=" . $DKIMtime . '; c=' . $DKIMcanonicalization . ";\r\n" .
+ "\th=From:To:Date:Subject;\r\n" .
+ "\td=" . $this->DKIM_domain . ';' . $ident . "\r\n" .
</ins><span class="cx" style="display: block; padding: 0 10px"> "\tz=$from\r\n" .
</span><span class="cx" style="display: block; padding: 0 10px"> "\t|$to\r\n" .
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "\t|$date\r\n" .
</ins><span class="cx" style="display: block; padding: 0 10px"> "\t|$subject;\r\n" .
</span><span class="cx" style="display: block; padding: 0 10px"> "\tbh=" . $DKIMb64 . ";\r\n" .
</span><span class="cx" style="display: block; padding: 0 10px"> "\tb=";
</span><span class="cx" style="display: block; padding: 0 10px"> $toSign = $this->DKIM_HeaderC(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $from_header . "\r\n" .
+ $to_header . "\r\n" .
+ $date_header . "\r\n" .
+ $subject_header . "\r\n" .
+ $dkimhdrs
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $signed = $this->DKIM_Sign($toSign);
</span><span class="cx" style="display: block; padding: 0 10px"> return $dkimhdrs . $signed . "\r\n";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Detect if a string contains a line longer than the maximum line length allowed.
+ * @param string $str
+ * @return boolean
+ * @static
+ */
+ public static function hasLineLongerThanMax($str)
+ {
+ //+2 to include CRLF line break for a 1000 total
+ return (boolean)preg_match('/^(.{'.(self::MAX_LINE_LENGTH + 2).',})/m', $str);
+ }
+
+ /**
+ * Allows for public read access to 'to' property.
+ * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
+ * @access public
+ * @return array
+ */
+ public function getToAddresses()
+ {
+ return $this->to;
+ }
+
+ /**
+ * Allows for public read access to 'cc' property.
+ * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
+ * @access public
+ * @return array
+ */
+ public function getCcAddresses()
+ {
+ return $this->cc;
+ }
+
+ /**
+ * Allows for public read access to 'bcc' property.
+ * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
+ * @access public
+ * @return array
+ */
+ public function getBccAddresses()
+ {
+ return $this->bcc;
+ }
+
+ /**
+ * Allows for public read access to 'ReplyTo' property.
+ * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
+ * @access public
+ * @return array
+ */
+ public function getReplyToAddresses()
+ {
+ return $this->ReplyTo;
+ }
+
+ /**
+ * Allows for public read access to 'all_recipients' property.
+ * @note: Before the send() call, queued addresses (i.e. with IDN) are not yet included.
+ * @access public
+ * @return array
+ */
+ public function getAllRecipientAddresses()
+ {
+ return $this->all_recipients;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Perform a callback.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $isSent
- * @param string $to
- * @param string $cc
- * @param string $bcc
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $isSent
+ * @param array $to
+ * @param array $cc
+ * @param array $bcc
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $subject
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $body
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $from
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from = null)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!empty($this->action_function) && is_callable($this->action_function)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $params = array($isSent, $to, $cc, $bcc, $subject, $body, $from);
</span></span></pre></div>
<a id="branches39srcwpincludesclasssmtpphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/3.9/src/wp-includes/class-smtp.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/3.9/src/wp-includes/class-smtp.php 2017-01-06 05:56:45 UTC (rev 39728)
+++ branches/3.9/src/wp-includes/class-smtp.php 2017-01-06 06:03:31 UTC (rev 39729)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,153 +1,225 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * PHPMailer RFC821 SMTP email transport class.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Version 5.2.7
- * PHP version 5.0.0
- * @category PHP
- * @package PHPMailer
- * @link https://github.com/PHPMailer/PHPMailer/
- * @author Marcus Bointon (coolbru) <phpmailer@synchromedia.co.uk>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * PHP Version 5
+ * @package PHPMailer
+ * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
</ins><span class="cx" style="display: block; padding: 0 10px"> * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
</span><span class="cx" style="display: block; padding: 0 10px"> * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @copyright 2013 Marcus Bointon
- * @copyright 2004 - 2008 Andy Prevost
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @author Brent R. Matzelle (original founder)
+ * @copyright 2014 Marcus Bointon
</ins><span class="cx" style="display: block; padding: 0 10px"> * @copyright 2010 - 2012 Jim Jagielski
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @copyright 2004 - 2009 Andy Prevost
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * PHPMailer RFC821 SMTP email transport class.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * Implements RFC 821 SMTP commands
- * and provides some utility methods for sending mail to an SMTP server.
- *
- * PHP Version 5.0.0
- *
- * @category PHP
- * @package PHPMailer
- * @link https://github.com/PHPMailer/PHPMailer/blob/master/class.smtp.php
- * @author Chris Ryan <unknown@example.com>
- * @author Marcus Bointon <phpmailer@synchromedia.co.uk>
- * @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.
+ * @package PHPMailer
+ * @author Chris Ryan
+ * @author Marcus Bointon <phpmailer@synchromedia.co.uk>
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> class SMTP
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The PHPMailer SMTP Version number.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The PHPMailer SMTP version number.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- const VERSION = '5.2.7';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const VERSION = '5.2.21';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP line break constant.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> const CRLF = "\r\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The SMTP port to use if one is not specified.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> const DEFAULT_SMTP_PORT = 25;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The maximum line length allowed by RFC 2822 section 2.1.1
+ * @var integer
+ */
+ const MAX_LINE_LENGTH = 998;
+
+ /**
+ * Debug level for no output
+ */
+ const DEBUG_OFF = 0;
+
+ /**
+ * Debug level to show client -> server messages
+ */
+ const DEBUG_CLIENT = 1;
+
+ /**
+ * Debug level to show client -> server and server -> client messages
+ */
+ const DEBUG_SERVER = 2;
+
+ /**
+ * Debug level to show connection status, client -> server and server -> client messages
+ */
+ const DEBUG_CONNECTION = 3;
+
+ /**
+ * Debug level to show all messages
+ */
+ const DEBUG_LOWLEVEL = 4;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The PHPMailer SMTP Version number.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
- * @deprecated This should be a constant
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string
+ * @deprecated Use the `VERSION` constant instead
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see SMTP::VERSION
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Version = '5.2.7';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Version = '5.2.21';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * SMTP server port number.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type int
- * @deprecated This is only ever ued as default value, so should be a constant
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var integer
+ * @deprecated This is only ever used as a default value, so use the `DEFAULT_SMTP_PORT` constant instead
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see SMTP::DEFAULT_SMTP_PORT
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $SMTP_PORT = 25;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * SMTP reply line ending
- * @type string
- * @deprecated Use the class constant instead
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * SMTP reply line ending.
+ * @var string
+ * @deprecated Use the `CRLF` constant instead
</ins><span class="cx" style="display: block; padding: 0 10px"> * @see SMTP::CRLF
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $CRLF = "\r\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Debug output level.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Options: 0 for no output, 1 for commands, 2 for data and commands
- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Options:
+ * * self::DEBUG_OFF (`0`) No debug output, default
+ * * self::DEBUG_CLIENT (`1`) Client commands
+ * * self::DEBUG_SERVER (`2`) Client commands and server responses
+ * * self::DEBUG_CONNECTION (`3`) As DEBUG_SERVER plus connection status
+ * * self::DEBUG_LOWLEVEL (`4`) Low-level data output, all messages
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $do_debug = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $do_debug = self::DEBUG_OFF;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The function/method to use for debugging output.
- * Options: 'echo', 'html' or 'error_log'
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * How to handle debug output.
+ * Options:
+ * * `echo` Output plain-text as-is, appropriate for CLI
+ * * `html` Output escaped, line breaks converted to `<br>`, appropriate for browser output
+ * * `error_log` Output to error log as configured in php.ini
+ *
+ * Alternatively, you can provide a callable expecting two params: a message string and the debug level:
+ * <code>
+ * $smtp->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
+ * </code>
+ * @var string|callable
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Debugoutput = 'echo';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to use VERP.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @link http://en.wikipedia.org/wiki/Variable_envelope_return_path
+ * @link http://www.postfix.org/VERP_README.html Info on VERP
+ * @var boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $do_verp = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The SMTP timeout value for reads, in seconds.
- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The timeout value for connection, in seconds.
+ * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
+ * This needs to be quite high to function correctly with hosts using greetdelay as an anti-spam measure.
+ * @link http://tools.ietf.org/html/rfc2821#section-4.5.3.2
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Timeout = 15;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Timeout = 300;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The SMTP timelimit value for reads, in seconds.
- * @type int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * How long to wait for commands to complete, in seconds.
+ * Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
+ * @var integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $Timelimit = 30;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Timelimit = 300;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @var array patterns to extract smtp transaction id from smtp reply
+ * Only first capture group will be use, use non-capturing group to deal with it
+ * Extend this class to override this property to fulfil your needs.
+ */
+ protected $smtp_transaction_id_patterns = array(
+ 'exim' => '/[0-9]{3} OK id=(.*)/',
+ 'sendmail' => '/[0-9]{3} 2.0.0 (.*) Message/',
+ 'postfix' => '/[0-9]{3} 2.0.0 Ok: queued as (.*)/'
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The socket for the server connection.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type resource
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var resource
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $smtp_conn;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Error message, if any, for the last call.
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Error information, if any, for the last SMTP command.
+ * @var array
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $error = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $error = array(
+ 'error' => '',
+ 'detail' => '',
+ 'smtp_code' => '',
+ 'smtp_code_ex' => ''
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The reply the server sent to us for HELO.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * If null, no HELO string has yet been received.
+ * @var string|null
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $helo_rply = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $helo_rply = null;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * The most recent reply received from the server.
- * @type string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The set of SMTP extensions sent in reply to EHLO command.
+ * Indexes of the array are extension names.
+ * Value at index 'HELO' or 'EHLO' (according to command that was sent)
+ * represents the server name. In case of HELO it is the only element of the array.
+ * Other values can be boolean TRUE or an array containing extension options.
+ * If null, no HELO/EHLO string has yet been received.
+ * @var array|null
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $last_reply = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $server_caps = null;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Constructor.
- * @access public
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The most recent reply received from the server.
+ * @var string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function __construct()
- {
- $this->smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected $last_reply = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->do_debug = 0;
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Output debugging info via a user-selected method.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @see SMTP::$Debugoutput
+ * @see SMTP::$do_debug
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $str Debug string to output
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param integer $level The debug level of this message; see DEBUG_* constants
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function edebug($str)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function edebug($str, $level = 0)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($level > $this->do_debug) {
+ return;
+ }
+ //Avoid clash with built-in function names
+ if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
+ call_user_func($this->Debugoutput, $str, $level);
+ return;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> switch ($this->Debugoutput) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'error_log':
</span><span class="cx" style="display: block; padding: 0 10px"> //Don't output, just log
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -164,103 +236,137 @@
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'echo':
</span><span class="cx" style="display: block; padding: 0 10px"> default:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Just echoes whatever was received
- echo $str;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Normalize line breaks
+ $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
+ echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
+ "\n",
+ "\n \t ",
+ trim($str)
+ )."\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Connect to an SMTP server.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $host SMTP server IP or host name
- * @param int $port The port number to connect to
- * @param int $timeout How long to wait for the connection to open
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $host SMTP server IP or host name
+ * @param integer $port The port number to connect to
+ * @param integer $timeout How long to wait for the connection to open
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $options An array of options for stream_context_create()
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connect($host, $port = null, $timeout = 30, $options = array())
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ static $streamok;
+ //This is enabled by default since 5.0.0 but some providers disable it
+ //Check this once and cache the result
+ if (is_null($streamok)) {
+ $streamok = function_exists('stream_socket_client');
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // Clear errors to avoid confusion
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = null;
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError('');
</ins><span class="cx" style="display: block; padding: 0 10px"> // Make sure we are __not__ connected
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->connected()) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Already connected, generate error
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = array('error' => 'Already connected to a server');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError('Already connected to a server');
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> if (empty($port)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $port = self::DEFAULT_SMTP_PORT;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> // Connect to the SMTP server
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug(
+ "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true),
+ self::DEBUG_CONNECTION
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $errno = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $errstr = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $socket_context = stream_context_create($options);
- //Suppress errors; connection failures are handled at a higher level
- $this->smtp_conn = @stream_socket_client(
- $host . ":" . $port,
- $errno,
- $errstr,
- $timeout,
- STREAM_CLIENT_CONNECT,
- $socket_context
- );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($streamok) {
+ $socket_context = stream_context_create($options);
+ set_error_handler(array($this, 'errorHandler'));
+ $this->smtp_conn = stream_socket_client(
+ $host . ":" . $port,
+ $errno,
+ $errstr,
+ $timeout,
+ STREAM_CLIENT_CONNECT,
+ $socket_context
+ );
+ restore_error_handler();
+ } else {
+ //Fall back to fsockopen which should work in more places, but is missing some features
+ $this->edebug(
+ "Connection: stream_socket_client not available, falling back to fsockopen",
+ self::DEBUG_CONNECTION
+ );
+ set_error_handler(array($this, 'errorHandler'));
+ $this->smtp_conn = fsockopen(
+ $host,
+ $port,
+ $errno,
+ $errstr,
+ $timeout
+ );
+ restore_error_handler();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // Verify we connected properly
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (empty($this->smtp_conn)) {
- $this->error = array(
- 'error' => 'Failed to connect to server',
- 'errno' => $errno,
- 'errstr' => $errstr
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!is_resource($this->smtp_conn)) {
+ $this->setError(
+ 'Failed to connect to server',
+ $errno,
+ $errstr
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 1) {
- $this->edebug(
- 'SMTP -> ERROR: ' . $this->error['error']
- . ": $errstr ($errno)"
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug(
+ 'SMTP ERROR: ' . $this->error['error']
+ . ": $errstr ($errno)",
+ self::DEBUG_CLIENT
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug('Connection: opened', self::DEBUG_CONNECTION);
</ins><span class="cx" style="display: block; padding: 0 10px"> // SMTP server can take longer to respond, give longer timeout for first read
</span><span class="cx" style="display: block; padding: 0 10px"> // Windows does not have support for this timeout function
</span><span class="cx" style="display: block; padding: 0 10px"> if (substr(PHP_OS, 0, 3) != 'WIN') {
</span><span class="cx" style="display: block; padding: 0 10px"> $max = ini_get('max_execution_time');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($max != 0 && $timeout > $max) { // Don't bother if unlimited
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Don't bother if unlimited
+ if ($max != 0 && $timeout > $max) {
</ins><span class="cx" style="display: block; padding: 0 10px"> @set_time_limit($timeout);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> stream_set_timeout($this->smtp_conn, $timeout, 0);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> // Get any announcement
</span><span class="cx" style="display: block; padding: 0 10px"> $announce = $this->get_lines();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ($this->do_debug >= 2) {
- $this->edebug('SMTP -> FROM SERVER:' . $announce);
- }
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Initiate a TLS (encrypted) session.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function startTLS()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!$this->sendCommand("STARTTLS", "STARTTLS", 220)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ //Allow the best TLS version(s) we can
+ $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
+
+ //PHP 5.6.7 dropped inclusion of TLS 1.1 and 1.2 in STREAM_CRYPTO_METHOD_TLS_CLIENT
+ //so add them back in manually if we can
+ if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
+ $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
+ $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Begin encrypted connection
</span><span class="cx" style="display: block; padding: 0 10px"> if (!stream_socket_enable_crypto(
</span><span class="cx" style="display: block; padding: 0 10px"> $this->smtp_conn,
</span><span class="cx" style="display: block; padding: 0 10px"> true,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- STREAM_CRYPTO_METHOD_TLS_CLIENT
- )
- ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $crypto_method
+ )) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,25 +376,64 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Perform SMTP authentication.
</span><span class="cx" style="display: block; padding: 0 10px"> * Must be run after hello().
</span><span class="cx" style="display: block; padding: 0 10px"> * @see hello()
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $username The user name
- * @param string $password The password
- * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5)
- * @param string $realm The auth realm for NTLM
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $username The user name
+ * @param string $password The password
+ * @param string $authtype The auth type (PLAIN, LOGIN, CRAM-MD5)
+ * @param string $realm The auth realm for NTLM
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $workstation The auth workstation for NTLM
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @access public
- * @return bool True if successfully authenticated.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth)
+ * @return bool True if successfully authenticated.* @access public
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function authenticate(
</span><span class="cx" style="display: block; padding: 0 10px"> $username,
</span><span class="cx" style="display: block; padding: 0 10px"> $password,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $authtype = 'LOGIN',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $authtype = null,
</ins><span class="cx" style="display: block; padding: 0 10px"> $realm = '',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $workstation = ''
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $workstation = '',
+ $OAuth = null
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (empty($authtype)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!$this->server_caps) {
+ $this->setError('Authentication is not allowed before HELO/EHLO');
+ return false;
+ }
+
+ if (array_key_exists('EHLO', $this->server_caps)) {
+ // SMTP extensions are available. Let's try to find a proper authentication method
+
+ if (!array_key_exists('AUTH', $this->server_caps)) {
+ $this->setError('Authentication is not allowed at this stage');
+ // 'at this stage' means that auth may be allowed after the stage changes
+ // e.g. after STARTTLS
+ return false;
+ }
+
+ self::edebug('Auth method requested: ' . ($authtype ? $authtype : 'UNKNOWN'), self::DEBUG_LOWLEVEL);
+ self::edebug(
+ 'Auth methods available on the server: ' . implode(',', $this->server_caps['AUTH']),
+ self::DEBUG_LOWLEVEL
+ );
+
+ if (empty($authtype)) {
+ foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN') as $method) {
+ if (in_array($method, $this->server_caps['AUTH'])) {
+ $authtype = $method;
+ break;
+ }
+ }
+ if (empty($authtype)) {
+ $this->setError('No supported authentication methods found');
+ return false;
+ }
+ self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
+ }
+
+ if (!in_array($authtype, $this->server_caps['AUTH'])) {
+ $this->setError("The requested authentication method \"$authtype\" is not supported by the server");
+ return false;
+ }
+ } elseif (empty($authtype)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $authtype = 'LOGIN';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> switch ($authtype) {
</span><span class="cx" style="display: block; padding: 0 10px"> case 'PLAIN':
</span><span class="cx" style="display: block; padding: 0 10px"> // Start authentication
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -317,59 +462,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- case 'NTLM':
- /*
- * ntlm_sasl_client.php
- * Bundled with Permission
- *
- * How to telnet in windows:
- * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
- * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
- */
- require_once 'extras/ntlm_sasl_client.php';
- $temp = new stdClass();
- $ntlm_client = new ntlm_sasl_client_class;
- //Check that functions are available
- if (!$ntlm_client->Initialize($temp)) {
- $this->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']
- );
- }
- return false;
- }
- //msg1
- $msg1 = $ntlm_client->TypeMsg1($realm, $workstation); //msg1
-
- if (!$this->sendCommand(
- 'AUTH NTLM',
- 'AUTH NTLM ' . base64_encode($msg1),
- 334
- )
- ) {
- return false;
- }
-
- //Though 0 based, there is a white space after the 3 digit number
- //msg2
- $challenge = substr($this->last_reply, 3);
- $challenge = base64_decode($challenge);
- $ntlm_res = $ntlm_client->NTLMResponse(
- substr($challenge, 24, 8),
- $password
- );
- //msg3
- $msg3 = $ntlm_client->TypeMsg3(
- $ntlm_res,
- $username,
- $realm,
- $workstation
- );
- // send encoded username
- return $this->sendCommand('Username', base64_encode($msg3), 235);
- break;
</del><span class="cx" style="display: block; padding: 0 10px"> case 'CRAM-MD5':
</span><span class="cx" style="display: block; padding: 0 10px"> // Start authentication
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -383,7 +475,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // send encoded credentials
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->sendCommand('Username', base64_encode($response), 235);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- break;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ default:
+ $this->setError("Authentication method \"$authtype\" is not supported");
+ return false;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -409,15 +503,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // RFC 2104 HMAC implementation for php.
</span><span class="cx" style="display: block; padding: 0 10px"> // Creates an md5 HMAC.
</span><span class="cx" style="display: block; padding: 0 10px"> // Eliminates the need to install mhash to compute a HMAC
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Hacked by Lance Rushing
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // by Lance Rushing
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $b = 64; // byte length for md5
- if (strlen($key) > $b) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $bytelen = 64; // byte length for md5
+ if (strlen($key) > $bytelen) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = pack('H*', md5($key));
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $key = str_pad($key, $b, chr(0x00));
- $ipad = str_pad('', $b, chr(0x36));
- $opad = str_pad('', $b, chr(0x5c));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $key = str_pad($key, $bytelen, chr(0x00));
+ $ipad = str_pad('', $bytelen, chr(0x36));
+ $opad = str_pad('', $bytelen, chr(0x5c));
</ins><span class="cx" style="display: block; padding: 0 10px"> $k_ipad = $key ^ $ipad;
</span><span class="cx" style="display: block; padding: 0 10px"> $k_opad = $key ^ $opad;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -427,19 +521,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Check connection state.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True if connected.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True if connected.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connected()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($this->smtp_conn)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_resource($this->smtp_conn)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $sock_status = stream_get_meta_data($this->smtp_conn);
</span><span class="cx" style="display: block; padding: 0 10px"> if ($sock_status['eof']) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // the socket is valid but we are not connected
- if ($this->do_debug >= 1) {
- $this->edebug(
- 'SMTP -> NOTICE: EOF caught while checking if connected'
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // The socket is valid but we are not connected
+ $this->edebug(
+ 'SMTP NOTICE: EOF caught while checking if connected',
+ self::DEBUG_CLIENT
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->close();
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -457,12 +550,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function close()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = null; // so there is no confusion
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError('');
+ $this->server_caps = null;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->helo_rply = null;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($this->smtp_conn)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_resource($this->smtp_conn)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // close the connection and cleanup
</span><span class="cx" style="display: block; padding: 0 10px"> fclose($this->smtp_conn);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->smtp_conn = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->smtp_conn = null; //Makes for cleaner serialization
+ $this->edebug('Connection: closed', self::DEBUG_CONNECTION);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -476,111 +571,101 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements rfc 821: DATA <CRLF>
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $msg_data Message data to send
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function data($msg_data)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //This will use the standard timelimit
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!$this->sendCommand('DATA', 'DATA', 354)) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* The server is ready to accept data!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * according to rfc821 we should not send more than 1000
- * including the CRLF
- * characters on a single line so we will break the data up
- * into lines by \r and/or \n then if needed we will break
- * each of those into smaller lines to fit within the limit.
- * in addition we will be looking for lines that start with
- * a period '.' and append and additional period '.' to that
- * line. NOTE: this does not count towards limit.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * According to rfc821 we should not send more than 1000 characters on a single line (including the CRLF)
+ * so we will break the data up into lines by \r and/or \n then if needed we will break each of those into
+ * smaller lines to fit within the limit.
+ * We will also look for lines that start with a '.' and prepend an additional '.'.
+ * NOTE: this does not count towards line-length limit.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Normalize the line breaks before exploding
- $msg_data = str_replace("\r\n", "\n", $msg_data);
- $msg_data = str_replace("\r", "\n", $msg_data);
- $lines = explode("\n", $msg_data);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Normalize line breaks before exploding
+ $lines = explode("\n", str_replace(array("\r\n", "\r"), "\n", $msg_data));
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /* We need to find a good way to determine if headers are
- * in the msg_data or if it is a straight msg body
- * currently I am assuming rfc822 definitions of msg headers
- * and if the first field of the first line (':' separated)
- * does not contain a space then it _should_ be a header
- * and we can process all lines before a blank "" line as
- * headers.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
+ * of the first line (':' separated) does not contain a space then it _should_ be a header and we will
+ * process all lines before a blank line as headers.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $field = substr($lines[0], 0, strpos($lines[0], ':'));
</span><span class="cx" style="display: block; padding: 0 10px"> $in_headers = false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($field) && !strstr($field, ' ')) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!empty($field) && strpos($field, ' ') === false) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $in_headers = true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //RFC 2822 section 2.1.1 limit
- $max_line_length = 998;
-
</del><span class="cx" style="display: block; padding: 0 10px"> foreach ($lines as $line) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $lines_out = null;
- if ($line == '' && $in_headers) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $lines_out = array();
+ if ($in_headers and $line == '') {
</ins><span class="cx" style="display: block; padding: 0 10px"> $in_headers = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // ok we need to break this line up into several smaller lines
- while (strlen($line) > $max_line_length) {
- $pos = strrpos(substr($line, 0, $max_line_length), ' ');
-
- // Patch to fix DOS attack
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Break this line up into several smaller lines if it's too long
+ //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len),
+ while (isset($line[self::MAX_LINE_LENGTH])) {
+ //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
+ //so as to avoid breaking in the middle of a word
+ $pos = strrpos(substr($line, 0, self::MAX_LINE_LENGTH), ' ');
+ //Deliberately matches both false and 0
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!$pos) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $pos = $max_line_length - 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //No nice break found, add a hard break
+ $pos = self::MAX_LINE_LENGTH - 1;
</ins><span class="cx" style="display: block; padding: 0 10px"> $lines_out[] = substr($line, 0, $pos);
</span><span class="cx" style="display: block; padding: 0 10px"> $line = substr($line, $pos);
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Break at the found point
</ins><span class="cx" style="display: block; padding: 0 10px"> $lines_out[] = substr($line, 0, $pos);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Move along by the amount we dealt with
</ins><span class="cx" style="display: block; padding: 0 10px"> $line = substr($line, $pos + 1);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- /* If processing headers add a LWSP-char to the front of new line
- * rfc822 on long msg headers
- */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //If processing headers add a LWSP-char to the front of new line RFC822 section 3.1.1
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($in_headers) {
</span><span class="cx" style="display: block; padding: 0 10px"> $line = "\t" . $line;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $lines_out[] = $line;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // send the lines to the server
- while (list(, $line_out) = @each($lines_out)) {
- if (strlen($line_out) > 0) {
- if (substr($line_out, 0, 1) == '.') {
- $line_out = '.' . $line_out;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Send the lines to the server
+ foreach ($lines_out as $line_out) {
+ //RFC2821 section 4.5.2
+ if (!empty($line_out) and $line_out[0] == '.') {
+ $line_out = '.' . $line_out;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $this->client_send($line_out . self::CRLF);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Message data has been sent, complete the command
- return $this->sendCommand('DATA END', '.', 250);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Message data has been sent, complete the command
+ //Increase timelimit for end of DATA command
+ $savetimelimit = $this->Timelimit;
+ $this->Timelimit = $this->Timelimit * 2;
+ $result = $this->sendCommand('DATA END', '.', 250);
+ //Restore timelimit
+ $this->Timelimit = $savetimelimit;
+ return $result;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP HELO or EHLO command.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used to identify the sending server to the receiving server.
</span><span class="cx" style="display: block; padding: 0 10px"> * This makes sure that client and server are in a known state.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Implements from RFC 821: HELO <SP> <domain> <CRLF>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Implements RFC 821: HELO <SP> <domain> <CRLF>
</ins><span class="cx" style="display: block; padding: 0 10px"> * and RFC 2821 EHLO.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $host The host name or IP to connect to
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function hello($host = '')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Try extended hello first (RFC 2821)
- if (!$this->sendHello('EHLO', $host)) {
- if (!$this->sendHello('HELO', $host)) {
- return false;
- }
- }
-
- return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Try extended hello first (RFC 2821)
+ return (boolean)($this->sendHello('EHLO', $host) or $this->sendHello('HELO', $host));
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -588,18 +673,65 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Low-level implementation used by hello()
</span><span class="cx" style="display: block; padding: 0 10px"> * @see hello()
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $hello The HELO string
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $host The hostname to say we are
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $host The hostname to say we are
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function sendHello($hello, $host)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $noerror = $this->sendCommand($hello, $hello . ' ' . $host, 250);
</span><span class="cx" style="display: block; padding: 0 10px"> $this->helo_rply = $this->last_reply;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($noerror) {
+ $this->parseHelloFields($hello);
+ } else {
+ $this->server_caps = null;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> return $noerror;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Parse a reply to HELO/EHLO command to discover server extensions.
+ * In case of HELO, the only parameter that can be discovered is a server name.
+ * @access protected
+ * @param string $type - 'HELO' or 'EHLO'
+ */
+ protected function parseHelloFields($type)
+ {
+ $this->server_caps = array();
+ $lines = explode("\n", $this->helo_rply);
+
+ foreach ($lines as $n => $s) {
+ //First 4 chars contain response code followed by - or space
+ $s = trim(substr($s, 4));
+ if (empty($s)) {
+ continue;
+ }
+ $fields = explode(' ', $s);
+ if (!empty($fields)) {
+ if (!$n) {
+ $name = $type;
+ $fields = $fields[0];
+ } else {
+ $name = array_shift($fields);
+ switch ($name) {
+ case 'SIZE':
+ $fields = ($fields ? $fields[0] : 0);
+ break;
+ case 'AUTH':
+ if (!is_array($fields)) {
+ $fields = array();
+ }
+ break;
+ default:
+ $fields = true;
+ }
+ }
+ $this->server_caps[$name] = $fields;
+ }
+ }
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP MAIL command.
</span><span class="cx" style="display: block; padding: 0 10px"> * Starts a mail transaction from the email address specified in
</span><span class="cx" style="display: block; padding: 0 10px"> * $from. Returns true if successful or false otherwise. If True
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -608,7 +740,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $from Source address of this message
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mail($from)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -624,35 +756,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP QUIT command.
</span><span class="cx" style="display: block; padding: 0 10px"> * Closes the socket if there is no error or the $close_on_error argument is true.
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements from rfc 821: QUIT <CRLF>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $close_on_error Should the connection close if an error occurs?
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $close_on_error Should the connection close if an error occurs?
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function quit($close_on_error = true)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> $noerror = $this->sendCommand('QUIT', 'QUIT', 221);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $e = $this->error; //Save any error
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $err = $this->error; //Save any error
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($noerror or $close_on_error) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->close();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = $e; //Restore any error from the quit command
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->error = $err; //Restore any error from the quit command
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $noerror;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP RCPT command.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Sets the TO argument to $to.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the TO argument to $toaddr.
</ins><span class="cx" style="display: block; padding: 0 10px"> * Returns true if the recipient was accepted false if it was rejected.
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $to The address the message is being sent to
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $address The address the message is being sent to
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function recipient($to)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function recipient($address)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->sendCommand(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'RCPT TO ',
- 'RCPT TO:<' . $to . '>',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'RCPT TO',
+ 'RCPT TO:<' . $address . '>',
</ins><span class="cx" style="display: block; padding: 0 10px"> array(250, 251)
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -662,7 +794,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Abort any transaction that is currently in progress.
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements rfc 821: RSET <CRLF>
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True on success.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True on success.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function reset()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -671,46 +803,61 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send a command to an SMTP server and check its return code.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $command The command name - not sent to the server
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $command The command name - not sent to the server
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $commandstring The actual command to send
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int|array $expect One or more expected integer success codes
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param integer|array $expect One or more expected integer success codes
</ins><span class="cx" style="display: block; padding: 0 10px"> * @access protected
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True on success.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean True on success.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function sendCommand($command, $commandstring, $expect)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> if (!$this->connected()) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = array(
- "error" => "Called $command without being connected"
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError("Called $command without being connected");
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Reject line breaks in all commands
+ if (strpos($commandstring, "\n") !== false or strpos($commandstring, "\r") !== false) {
+ $this->setError("Command '$command' contained line breaks");
+ return false;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->client_send($commandstring . self::CRLF);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $reply = $this->get_lines();
- $code = substr($reply, 0, 3);
-
- if ($this->do_debug >= 2) {
- $this->edebug('SMTP -> FROM SERVER:' . $reply);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->last_reply = $this->get_lines();
+ // Fetch SMTP code and possible error code explanation
+ $matches = array();
+ if (preg_match("/^([0-9]{3})[ -](?:([0-9]\\.[0-9]\\.[0-9]) )?/", $this->last_reply, $matches)) {
+ $code = $matches[1];
+ $code_ex = (count($matches) > 2 ? $matches[2] : null);
+ // Cut off error code from each response line
+ $detail = preg_replace(
+ "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m",
+ '',
+ $this->last_reply
+ );
+ } else {
+ // Fall back to simple parsing if regex fails
+ $code = substr($this->last_reply, 0, 3);
+ $code_ex = null;
+ $detail = substr($this->last_reply, 4);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!in_array($code, (array)$expect)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->last_reply = null;
- $this->error = array(
- "error" => "$command command failed",
- "smtp_code" => $code,
- "detail" => substr($reply, 4)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError(
+ "$command command failed",
+ $detail,
+ $code,
+ $code_ex
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 1) {
- $this->edebug(
- 'SMTP -> ERROR: ' . $this->error['error'] . ': ' . $reply
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug(
+ 'SMTP ERROR: ' . $this->error['error'] . ': ' . $this->last_reply,
+ self::DEBUG_CLIENT
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->last_reply = $reply;
- $this->error = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError('');
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -725,52 +872,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $from The address the message is from
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function sendAndMail($from)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->sendCommand("SAML", "SAML FROM:$from", 250);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->sendCommand('SAML', "SAML FROM:$from", 250);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP VRFY command.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $name The name to verify
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function verify($name)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->sendCommand("VRFY", "VRFY $name", array(250, 251));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->sendCommand('VRFY', "VRFY $name", array(250, 251));
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP NOOP command.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used to keep keep-alives alive, doesn't actually do anything
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function noop()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->sendCommand("NOOP", "NOOP", 250);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->sendCommand('NOOP', 'NOOP', 250);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP TURN command.
</span><span class="cx" style="display: block; padding: 0 10px"> * This is an optional command for SMTP that this class does not support.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * This method is here to make the RFC821 Definition
- * complete for this class and __may__ be implemented in future
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * This method is here to make the RFC821 Definition complete for this class
+ * and _may_ be implemented in future
</ins><span class="cx" style="display: block; padding: 0 10px"> * Implements from rfc 821: TURN <CRLF>
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function turn()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->error = array(
- 'error' => 'The SMTP TURN command is not implemented'
- );
- if ($this->do_debug >= 1) {
- $this->edebug('SMTP -> NOTICE: ' . $this->error['error']);
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->setError('The SMTP TURN command is not implemented');
+ $this->edebug('SMTP NOTICE: ' . $this->error['error'], self::DEBUG_CLIENT);
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -778,13 +921,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Send raw data to the server.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $data The data to send
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|bool The number of bytes sent to the server or FALSE on error
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return integer|boolean The number of bytes sent to the server or false on error
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function client_send($data)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 1) {
- $this->edebug("CLIENT -> SMTP: $data");
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
</ins><span class="cx" style="display: block; padding: 0 10px"> return fwrite($this->smtp_conn, $data);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -799,6 +940,57 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Get SMTP extensions available on the server
+ * @access public
+ * @return array|null
+ */
+ public function getServerExtList()
+ {
+ return $this->server_caps;
+ }
+
+ /**
+ * A multipurpose method
+ * The method works in three ways, dependent on argument value and current state
+ * 1. HELO/EHLO was not sent - returns null and set up $this->error
+ * 2. HELO was sent
+ * $name = 'HELO': returns server name
+ * $name = 'EHLO': returns boolean false
+ * $name = any string: returns null and set up $this->error
+ * 3. EHLO was sent
+ * $name = 'HELO'|'EHLO': returns server name
+ * $name = any string: if extension $name exists, returns boolean True
+ * or its options. Otherwise returns boolean False
+ * In other words, one can use this method to detect 3 conditions:
+ * - null returned: handshake was not or we don't know about ext (refer to $this->error)
+ * - false returned: the requested feature exactly not exists
+ * - positive value returned: the requested feature exists
+ * @param string $name Name of SMTP extension or 'HELO'|'EHLO'
+ * @return mixed
+ */
+ public function getServerExt($name)
+ {
+ if (!$this->server_caps) {
+ $this->setError('No HELO/EHLO was sent');
+ return null;
+ }
+
+ // the tight logic knot ;)
+ if (!array_key_exists($name, $this->server_caps)) {
+ if ($name == 'HELO') {
+ return $this->server_caps['EHLO'];
+ }
+ if ($name == 'EHLO' || array_key_exists('EHLO', $this->server_caps)) {
+ return false;
+ }
+ $this->setError('HELO handshake was used. Client knows nothing about server extensions');
+ return null;
+ }
+
+ return $this->server_caps[$name];
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Get the last reply from the server.
</span><span class="cx" style="display: block; padding: 0 10px"> * @access public
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -819,51 +1011,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function get_lines()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If the connection is bad, give up straight away
+ if (!is_resource($this->smtp_conn)) {
+ return '';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $data = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $endtime = 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // If the connection is bad, give up now
- if (!is_resource($this->smtp_conn)) {
- return $data;
- }
</del><span class="cx" style="display: block; padding: 0 10px"> stream_set_timeout($this->smtp_conn, $this->Timeout);
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->Timelimit > 0) {
</span><span class="cx" style="display: block; padding: 0 10px"> $endtime = time() + $this->Timelimit;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $str = @fgets($this->smtp_conn, 515);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 4) {
- $this->edebug("SMTP -> get_lines(): \$data was \"$data\"");
- $this->edebug("SMTP -> get_lines(): \$str is \"$str\"");
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
+ $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
</ins><span class="cx" style="display: block; padding: 0 10px"> $data .= $str;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 4) {
- $this->edebug("SMTP -> get_lines(): \$data is \"$data\"");
- }
- // if 4th character is a space, we are done reading, break the loop
- if (substr($str, 3, 1) == ' ') {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
+ if ((isset($str[3]) and $str[3] == ' ')) {
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> // Timed-out? Log and break
</span><span class="cx" style="display: block; padding: 0 10px"> $info = stream_get_meta_data($this->smtp_conn);
</span><span class="cx" style="display: block; padding: 0 10px"> if ($info['timed_out']) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($this->do_debug >= 4) {
- $this->edebug(
- 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)'
- );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug(
+ 'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
+ self::DEBUG_LOWLEVEL
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> // Now check if reads took too long
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($endtime) {
- if (time() > $endtime) {
- if ($this->do_debug >= 4) {
- $this->edebug(
- 'SMTP -> get_lines(): timelimit reached ('
- . $this->Timelimit . ' sec)'
- );
- }
- break;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($endtime and time() > $endtime) {
+ $this->edebug(
+ 'SMTP -> get_lines(): timelimit reached ('.
+ $this->Timelimit . ' sec)',
+ self::DEBUG_LOWLEVEL
+ );
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> return $data;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -871,7 +1054,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Enable or disable VERP address generation.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $enabled
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param boolean $enabled
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function setVerp($enabled = false)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -880,7 +1063,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Get VERP address generation mode.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return boolean
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getVerp()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -888,8 +1071,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Set error messages and codes.
+ * @param string $message The error message
+ * @param string $detail Further detail on the error
+ * @param string $smtp_code An associated SMTP error code
+ * @param string $smtp_code_ex Extended SMTP code
+ */
+ protected function setError($message, $detail = '', $smtp_code = '', $smtp_code_ex = '')
+ {
+ $this->error = array(
+ 'error' => $message,
+ 'detail' => $detail,
+ 'smtp_code' => $smtp_code,
+ 'smtp_code_ex' => $smtp_code_ex
+ );
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Set debug output method.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $method The function/method to use for debugging output.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|callable $method The name of the mechanism to use for debugging output, or a callable to handle it.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function setDebugOutput($method = 'echo')
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -907,7 +1107,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Set debug output level.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $level
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param integer $level
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function setDebugLevel($level = 0)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -916,7 +1116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Get debug output level.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getDebugLevel()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -925,7 +1125,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Set SMTP timeout.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $timeout
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param integer $timeout
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function setTimeout($timeout = 0)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -934,10 +1134,53 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Get SMTP timeout.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return integer
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getTimeout()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->Timeout;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Reports an error number and string.
+ * @param integer $errno The error number returned by PHP.
+ * @param string $errmsg The error message returned by PHP.
+ */
+ protected function errorHandler($errno, $errmsg)
+ {
+ $notice = 'Connection: Failed to connect to server.';
+ $this->setError(
+ $notice,
+ $errno,
+ $errmsg
+ );
+ $this->edebug(
+ $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg,
+ self::DEBUG_CONNECTION
+ );
+ }
+
+ /**
+ * Will return the ID of the last smtp transaction based on a list of patterns provided
+ * in SMTP::$smtp_transaction_id_patterns.
+ * If no reply has been received yet, it will return null.
+ * If no pattern has been matched, it will return false.
+ * @return bool|null|string
+ */
+ public function getLastTransactionID()
+ {
+ $reply = $this->getLastReply();
+
+ if (empty($reply)) {
+ return null;
+ }
+
+ foreach($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
+ if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
+ return $matches[1];
+ }
+ }
+
+ return false;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>