]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-smtp.php
WordPress 4.7
[autoinstalls/wordpress.git] / wp-includes / class-smtp.php
index 3ad081926a51a32d12a350623d7237df7785235c..f17ca0fd9717d618a37115083781385498303b65 100644 (file)
@@ -30,7 +30,7 @@ class SMTP
      * The PHPMailer SMTP version number.
      * @var string
      */
      * The PHPMailer SMTP version number.
      * @var string
      */
-    const VERSION = '5.2.22';
+    const VERSION = '5.2.14';
 
     /**
      * SMTP line break constant.
 
     /**
      * SMTP line break constant.
@@ -81,7 +81,7 @@ class SMTP
      * @deprecated Use the `VERSION` constant instead
      * @see SMTP::VERSION
      */
      * @deprecated Use the `VERSION` constant instead
      * @see SMTP::VERSION
      */
-    public $Version = '5.2.22';
+    public $Version = '5.2.14';
 
     /**
      * SMTP server port number.
 
     /**
      * SMTP server port number.
@@ -150,17 +150,6 @@ class SMTP
      */
     public $Timelimit = 300;
 
      */
     public $Timelimit = 300;
 
-       /**
-        * @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 (.*)/'
-       );
-
     /**
      * The socket for the server connection.
      * @var resource
     /**
      * The socket for the server connection.
      * @var resource
@@ -217,7 +206,7 @@ class SMTP
         }
         //Avoid clash with built-in function names
         if (!in_array($this->Debugoutput, array('error_log', 'html', 'echo')) and is_callable($this->Debugoutput)) {
         }
         //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);
+            call_user_func($this->Debugoutput, $str, $this->do_debug);
             return;
         }
         switch ($this->Debugoutput) {
             return;
         }
         switch ($this->Debugoutput) {
@@ -283,8 +272,8 @@ class SMTP
         $errstr = '';
         if ($streamok) {
             $socket_context = stream_context_create($options);
         $errstr = '';
         if ($streamok) {
             $socket_context = stream_context_create($options);
-            set_error_handler(array($this, 'errorHandler'));
-            $this->smtp_conn = stream_socket_client(
+            //Suppress errors; connection failures are handled at a higher level
+            $this->smtp_conn = @stream_socket_client(
                 $host . ":" . $port,
                 $errno,
                 $errstr,
                 $host . ":" . $port,
                 $errno,
                 $errstr,
@@ -292,14 +281,12 @@ class SMTP
                 STREAM_CLIENT_CONNECT,
                 $socket_context
             );
                 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
             );
         } 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,
             $this->smtp_conn = fsockopen(
                 $host,
                 $port,
@@ -307,7 +294,6 @@ class SMTP
                 $errstr,
                 $timeout
             );
                 $errstr,
                 $timeout
             );
-            restore_error_handler();
         }
         // Verify we connected properly
         if (!is_resource($this->smtp_conn)) {
         }
         // Verify we connected properly
         if (!is_resource($this->smtp_conn)) {
@@ -350,22 +336,11 @@ class SMTP
         if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
             return false;
         }
         if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) {
             return false;
         }
-
-        //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;
-        }
-
         // Begin encrypted connection
         if (!stream_socket_enable_crypto(
             $this->smtp_conn,
             true,
         // Begin encrypted connection
         if (!stream_socket_enable_crypto(
             $this->smtp_conn,
             true,
-            $crypto_method
+            STREAM_CRYPTO_METHOD_TLS_CLIENT
         )) {
             return false;
         }
         )) {
             return false;
         }
@@ -378,7 +353,7 @@ class SMTP
      * @see hello()
      * @param string $username The user name
      * @param string $password The password
      * @see hello()
      * @param string $username The user name
      * @param string $password The password
-     * @param string $authtype The auth type (PLAIN, LOGIN, CRAM-MD5)
+     * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
      * @param string $realm The auth realm for NTLM
      * @param string $workstation The auth workstation for NTLM
      * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth)
      * @param string $realm The auth realm for NTLM
      * @param string $workstation The auth workstation for NTLM
      * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth)
@@ -414,7 +389,7 @@ class SMTP
             );
 
             if (empty($authtype)) {
             );
 
             if (empty($authtype)) {
-                foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN') as $method) {
+                foreach (array('LOGIN', 'CRAM-MD5', 'PLAIN') as $method) {
                     if (in_array($method, $this->server_caps['AUTH'])) {
                         $authtype = $method;
                         break;
                     if (in_array($method, $this->server_caps['AUTH'])) {
                         $authtype = $method;
                         break;
@@ -698,7 +673,7 @@ class SMTP
     protected function parseHelloFields($type)
     {
         $this->server_caps = array();
     protected function parseHelloFields($type)
     {
         $this->server_caps = array();
-        $lines = explode("\n", $this->helo_rply);
+        $lines = explode("\n", $this->last_reply);
 
         foreach ($lines as $n => $s) {
             //First 4 chars contain response code followed by - or space
 
         foreach ($lines as $n => $s) {
             //First 4 chars contain response code followed by - or space
@@ -1140,47 +1115,4 @@ class SMTP
     {
         return $this->Timeout;
     }
     {
         return $this->Timeout;
     }
-
-    /**
-     * 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;
-    }
 }
 }