<!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>[46097] trunk/src/wp-includes: Mail: Update PHPMailer to 5.2.27.</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 { white-space: pre-line; 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/46097">46097</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/46097","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-09-12 14:36:42 +0000 (Thu, 12 Sep 2019)</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: Update PHPMailer to 5.2.27.
The full list of changes is available here:
https://github.com/PHPMailer/PHPMailer/compare/v5.2.22...PHPMailer:v5.2.27
Props MattyRob, ayeshrajans, rogueresearch, bgermann, slaFFik, Presskopp, aaroncampbell.
Fixes <a href="https://core.trac.wordpress.org/ticket/40472">#40472</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclassphpmailerphp">trunk/src/wp-includes/class-phpmailer.php</a></li>
<li><a href="#trunksrcwpincludesclasssmtpphp">trunk/src/wp-includes/class-smtp.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclassphpmailerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-phpmailer.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-phpmailer.php 2019-09-12 13:05:35 UTC (rev 46096)
+++ trunk/src/wp-includes/class-phpmailer.php 2019-09-12 14:36:42 UTC (rev 46097)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,7 +31,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * The PHPMailer Version number.
</span><span class="cx" style="display: block; padding: 0 10px"> * @var 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 $Version = '5.2.22';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Version = '5.2.27';
</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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -440,9 +440,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Parameters:
</span><span class="cx" style="display: block; padding: 0 10px"> * boolean $result result of the send action
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * string $to email address of the recipient
- * string $cc cc email addresses
- * string $bcc bcc email addresses
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * array $to email addresses of the recipients
+ * array $cc cc email addresses
+ * array $bcc bcc email addresses
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -659,6 +659,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ($exceptions !== null) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->exceptions = (boolean)$exceptions;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ //Pick an appropriate debug output format automatically
+ $this->Debugoutput = (strpos(PHP_SAPI, 'cli') !== false ? 'echo' : 'html');
</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">@@ -1294,9 +1296,12 @@
</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_selector)
- && (!empty($this->DKIM_private_string)
- || (!empty($this->DKIM_private) && file_exists($this->DKIM_private))
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ and !empty($this->DKIM_selector)
+ and (!empty($this->DKIM_private_string)
+ or (!empty($this->DKIM_private)
+ and self::isPermittedPath($this->DKIM_private)
+ and file_exists($this->DKIM_private)
+ )
</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"> $header_dkim = $this->DKIM_Add(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1462,6 +1467,18 @@
</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">+ * Check whether a file path is of a permitted type.
+ * Used to reject URLs and phar files from functions that access local file paths,
+ * such as addAttachment.
+ * @param string $path A relative or absolute path to a file.
+ * @return bool
+ */
+ protected static function isPermittedPath($path)
+ {
+ return !preg_match('#^[a-z]+://#i', $path);
+ }
+
+ /**
</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="lines" style="display: block; padding: 0 10px; color: #888">@@ -1623,8 +1640,13 @@
</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">- if (!preg_match('/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*):?([0-9]*)$/', trim($hostentry), $hostinfo)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!preg_match(
+ '/^((ssl|tls):\/\/)*([a-zA-Z0-9\.-]*|\[[a-fA-F0-9:]+\]):?([0-9]*)$/',
+ trim($hostentry),
+ $hostinfo
+ )) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Not a valid host entry
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->edebug('Ignoring invalid host: ' . $hostentry);
</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"> // $hostinfo[2]: optional ssl or tls prefix
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1743,6 +1765,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'dk' => 'da',
</span><span class="cx" style="display: block; padding: 0 10px"> 'no' => 'nb',
</span><span class="cx" style="display: block; padding: 0 10px"> 'se' => 'sv',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'sr' => 'rs'
</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 (isset($renamed_langcodes[$langcode])) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1784,7 +1807,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // There is no English translation file
</span><span class="cx" style="display: block; padding: 0 10px"> if ($langcode != 'en') {
</span><span class="cx" style="display: block; padding: 0 10px"> // Make sure language file path is readable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!is_readable($lang_file)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!self::isPermittedPath($lang_file) or !is_readable($lang_file)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $foundlang = false;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> // Overwrite language-specific strings.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2025,10 +2048,7 @@
</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">- if ($this->MessageDate == '') {
- $this->MessageDate = self::rfcDate();
- }
- $result .= $this->headerLine('Date', $this->MessageDate);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result .= $this->headerLine('Date', $this->MessageDate == '' ? self::rfcDate() : $this->MessageDate);
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // To be created automatically by mail()
</span><span class="cx" style="display: block; padding: 0 10px"> if ($this->SingleTo) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2495,6 +2515,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Add an attachment from a path on the filesystem.
</span><span class="cx" style="display: block; padding: 0 10px"> * Never use a user-supplied path to a file!
</span><span class="cx" style="display: block; padding: 0 10px"> * Returns false if the file could not be found or read.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Explicitly *does not* support passing URLs; PHPMailer is not an HTTP client.
+ * If you need to do that, fetch the resource yourself and pass it in via a local file or string.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $path Path to the attachment.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $name Overrides the attachment name.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $encoding File encoding (see $Encoding).
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2506,7 +2528,7 @@
</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="cx" style="display: block; padding: 0 10px"> try {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!@is_file($path)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!self::isPermittedPath($path) or !@is_file($path)) {
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2687,7 +2709,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected function encodeFile($path, $encoding = 'base64')
</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">- if (!is_readable($path)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!self::isPermittedPath($path) or !file_exists($path)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> throw new phpmailerException($this->lang('file_open') . $path, self::STOP_CONTINUE);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $magic_quotes = get_magic_quotes_runtime();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3031,7 +3053,7 @@
</span><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!@is_file($path)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (!self::isPermittedPath($path) or !@is_file($path)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->setError($this->lang('file_access') . $path);
</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">@@ -4034,7 +4056,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function errorMessage()
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $errorMsg = '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n";
</ins><span class="cx" style="display: block; padding: 0 10px"> return $errorMsg;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasssmtpphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-smtp.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-smtp.php 2019-09-12 13:05:35 UTC (rev 46096)
+++ trunk/src/wp-includes/class-smtp.php 2019-09-12 14:36:42 UTC (rev 46097)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,7 +30,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * The PHPMailer SMTP version number.
</span><span class="cx" style="display: block; padding: 0 10px"> * @var 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">- const VERSION = '5.2.22';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const VERSION = '5.2.27';
</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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,7 +81,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @deprecated Use the `VERSION` constant instead
</span><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.22';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $Version = '5.2.27';
</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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,18 +150,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $Timelimit = 300;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; 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 (.*)/'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @var array Patterns to extract an SMTP transaction id from reply to a DATA command.
+ * The first capture group in each regex will be used as the ID.
+ */
+ 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"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string The last transaction ID issued in response to a DATA command,
+ * if one was detected
+ */
+ protected $last_smtp_transaction_id;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The socket for the server connection.
</span><span class="cx" style="display: block; padding: 0 10px"> * @var resource
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -227,12 +232,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> case 'html':
</span><span class="cx" style="display: block; padding: 0 10px"> //Cleans up output a bit for a better looking, HTML-safe output
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo htmlentities(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ echo gmdate('Y-m-d H:i:s') . ' ' . htmlentities(
</ins><span class="cx" style="display: block; padding: 0 10px"> preg_replace('/[\r\n]+/', '', $str),
</span><span class="cx" style="display: block; padding: 0 10px"> ENT_QUOTES,
</span><span class="cx" style="display: block; padding: 0 10px"> 'UTF-8'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )
- . "<br>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) . "<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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,7 +246,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "\n",
</span><span class="cx" style="display: block; padding: 0 10px"> "\n \t ",
</span><span class="cx" style="display: block; padding: 0 10px"> trim($str)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )."\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) . "\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="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,7 +280,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> // Connect to the SMTP server
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edebug(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "Connection: opening to $host:$port, timeout=$timeout, options=".var_export($options, true),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "Connection: opening to $host:$port, timeout=$timeout, options=" .
+ var_export($options, true),
</ins><span class="cx" style="display: block; padding: 0 10px"> self::DEBUG_CONNECTION
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $errno = 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -362,14 +367,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"> // Begin encrypted connection
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!stream_socket_enable_crypto(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_error_handler(array($this, 'errorHandler'));
+ $crypto_ok = stream_socket_enable_crypto(
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->smtp_conn,
</span><span class="cx" style="display: block; padding: 0 10px"> true,
</span><span class="cx" style="display: block; padding: 0 10px"> $crypto_method
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- )) {
- return false;
- }
- return true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ );
+ restore_error_handler();
+ return $crypto_ok;
</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">@@ -398,8 +403,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"> if (array_key_exists('EHLO', $this->server_caps)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // SMTP extensions are available. Let's try to find a proper authentication method
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // SMTP extensions are available; try to find a proper authentication method
</ins><span class="cx" style="display: block; padding: 0 10px"> if (!array_key_exists('AUTH', $this->server_caps)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setError('Authentication is not allowed at this stage');
</span><span class="cx" style="display: block; padding: 0 10px"> // 'at this stage' means that auth may be allowed after the stage changes
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -424,7 +428,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->setError('No supported authentication methods found');
</span><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">- self::edebug('Auth method selected: '.$authtype, self::DEBUG_LOWLEVEL);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::edebug('Auth method selected: ' . $authtype, self::DEBUG_LOWLEVEL);
</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 (!in_array($authtype, $this->server_caps['AUTH'])) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -487,7 +491,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Works like hash_hmac('md5', $data, $key)
</span><span class="cx" style="display: block; padding: 0 10px"> * in case that function is not available
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $data The data to hash
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $key The key to hash with
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $key The key to hash with
</ins><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">@@ -564,10 +568,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Send an SMTP DATA command.
</span><span class="cx" style="display: block; padding: 0 10px"> * Issues a data command and sends the msg_data to the server,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * finalizing the mail transaction. $msg_data is the message
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * finializing the mail transaction. $msg_data is the message
</ins><span class="cx" style="display: block; padding: 0 10px"> * that is to be send with the headers. Each header needs to be
</span><span class="cx" style="display: block; padding: 0 10px"> * on a single line followed by a <CRLF> with the message headers
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * and the message body being separated by an additional <CRLF>.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * and the message body being separated by and additional <CRLF>.
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -647,6 +651,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $savetimelimit = $this->Timelimit;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->Timelimit = $this->Timelimit * 2;
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->sendCommand('DATA END', '.', 250);
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->recordLastTransactionID();
</ins><span class="cx" style="display: block; padding: 0 10px"> //Restore timelimit
</span><span class="cx" style="display: block; padding: 0 10px"> $this->Timelimit = $savetimelimit;
</span><span class="cx" style="display: block; padding: 0 10px"> return $result;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -830,7 +835,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $code_ex = (count($matches) > 2 ? $matches[2] : null);
</span><span class="cx" style="display: block; padding: 0 10px"> // Cut off error code from each response line
</span><span class="cx" style="display: block; padding: 0 10px"> $detail = preg_replace(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "/{$code}[ -]".($code_ex ? str_replace('.', '\\.', $code_ex).' ' : '')."/m",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "/{$code}[ -]" .
+ ($code_ex ? str_replace('.', '\\.', $code_ex) . ' ' : '') . "/m",
</ins><span class="cx" style="display: block; padding: 0 10px"> '',
</span><span class="cx" style="display: block; padding: 0 10px"> $this->last_reply
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -926,7 +932,10 @@
</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><span class="cx" style="display: block; padding: 0 10px"> $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT);
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return fwrite($this->smtp_conn, $data);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_error_handler(array($this, 'errorHandler'));
+ $result = fwrite($this->smtp_conn, $data);
+ restore_error_handler();
+ 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="lines" style="display: block; padding: 0 10px; color: #888">@@ -1026,8 +1035,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL);
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL);
</span><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 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen
- if ((isset($str[3]) and $str[3] == ' ')) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled),
+ // or 4th character is a space, we are done reading, break the loop,
+ // string array access is a micro-optimisation over strlen
+ if (!isset($str[3]) or (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="lines" style="display: block; padding: 0 10px; color: #888">@@ -1042,7 +1053,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Now check if reads took too long
</span><span class="cx" style="display: block; padding: 0 10px"> if ($endtime and time() > $endtime) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edebug(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'SMTP -> get_lines(): timelimit reached ('.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'SMTP -> get_lines(): timelimit reached (' .
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->Timelimit . ' sec)',
</span><span class="cx" style="display: block; padding: 0 10px"> self::DEBUG_LOWLEVEL
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1145,10 +1156,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Reports an error number and string.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param integer $errno The error number returned by PHP.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $errmsg The error message returned by PHP.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $errfile The file the error occurred in
+ * @param integer $errline The line number the error occurred on
</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 function errorHandler($errno, $errmsg)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function errorHandler($errno, $errmsg, $errfile = '', $errline = 0)
</ins><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notice = 'Connection: Failed to connect to server.';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notice = 'Connection failed.';
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->setError(
</span><span class="cx" style="display: block; padding: 0 10px"> $notice,
</span><span class="cx" style="display: block; padding: 0 10px"> $errno,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1155,32 +1168,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $errmsg
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->edebug(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $notice . ' Error number ' . $errno . '. "Error notice: ' . $errmsg,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $notice . ' Error #' . $errno . ': ' . $errmsg . " [$errfile line $errline]",
</ins><span class="cx" style="display: block; padding: 0 10px"> self::DEBUG_CONNECTION
</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">- /**
- * 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();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Extract and return the ID of the last SMTP transaction based on
+ * a list of patterns provided in SMTP::$smtp_transaction_id_patterns.
+ * Relies on the host providing the ID in response to a DATA command.
+ * If no reply has been received yet, it will return null.
+ * If no pattern was matched, it will return false.
+ * @return bool|null|string
+ */
+ protected function recordLastTransactionID()
+ {
+ $reply = $this->getLastReply();
</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($reply)) {
- return null;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (empty($reply)) {
+ $this->last_smtp_transaction_id = null;
+ } else {
+ $this->last_smtp_transaction_id = false;
+ foreach ($this->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
+ if (preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
+ $this->last_smtp_transaction_id = $matches[1];
+ }
+ }
+ }
</ins><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->smtp_transaction_id_patterns as $smtp_transaction_id_pattern) {
- if(preg_match($smtp_transaction_id_pattern, $reply, $matches)) {
- return $matches[1];
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->last_smtp_transaction_id;
+ }
</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 false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Get the queue/transaction ID of the last SMTP transaction
+ * If no reply has been received yet, it will return null.
+ * If no pattern was matched, it will return false.
+ * @return bool|null|string
+ * @see recordLastTransactionID()
+ */
+ public function getLastTransactionID()
+ {
+ return $this->last_smtp_transaction_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>