Make WordPress Core

Ticket #39714: 39714-1.diff

File 39714-1.diff, 4.8 KB (added by Ipstenu, 8 years ago)

Update PHPMailer to 5.2.2, no longer fork library

  • wp-includes/class-smtp.php

     
    378378     * @see hello()
    379379     * @param string $username The user name
    380380     * @param string $password The password
    381      * @param string $authtype The auth type (PLAIN, LOGIN, CRAM-MD5)
     381     * @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5, XOAUTH2)
    382382     * @param string $realm The auth realm for NTLM
    383383     * @param string $workstation The auth workstation for NTLM
    384384     * @param null|OAuth $OAuth An optional OAuth instance (@see PHPMailerOAuth)
     
    414414            );
    415415
    416416            if (empty($authtype)) {
    417                 foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN') as $method) {
     417                foreach (array('CRAM-MD5', 'LOGIN', 'PLAIN', 'NTLM', 'XOAUTH2') as $method) {
    418418                    if (in_array($method, $this->server_caps['AUTH'])) {
    419419                        $authtype = $method;
    420420                        break;
     
    462462                    return false;
    463463                }
    464464                break;
     465            case 'XOAUTH2':
     466                //If the OAuth Instance is not set. Can be a case when PHPMailer is used
     467                //instead of PHPMailerOAuth
     468                if (is_null($OAuth)) {
     469                    return false;
     470                }
     471                $oauth = $OAuth->getOauth64();
     472
     473                // Start authentication
     474                if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
     475                    return false;
     476                }
     477                break;
     478            case 'NTLM':
     479                /*
     480                 * ntlm_sasl_client.php
     481                 * Bundled with Permission
     482                 *
     483                 * How to telnet in windows:
     484                 * http://technet.microsoft.com/en-us/library/aa995718%28EXCHG.65%29.aspx
     485                 * PROTOCOL Docs http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication
     486                 */
     487                require_once 'extras/ntlm_sasl_client.php';
     488                $temp = new stdClass;
     489                $ntlm_client = new ntlm_sasl_client_class;
     490                //Check that functions are available
     491                if (!$ntlm_client->initialize($temp)) {
     492                    $this->setError($temp->error);
     493                    $this->edebug(
     494                        'You need to enable some modules in your php.ini file: '
     495                        . $this->error['error'],
     496                        self::DEBUG_CLIENT
     497                    );
     498                    return false;
     499                }
     500                //msg1
     501                $msg1 = $ntlm_client->typeMsg1($realm, $workstation); //msg1
     502
     503                if (!$this->sendCommand(
     504                    'AUTH NTLM',
     505                    'AUTH NTLM ' . base64_encode($msg1),
     506                    334
     507                )
     508                ) {
     509                    return false;
     510                }
     511                //Though 0 based, there is a white space after the 3 digit number
     512                //msg2
     513                $challenge = substr($this->last_reply, 3);
     514                $challenge = base64_decode($challenge);
     515                $ntlm_res = $ntlm_client->NTLMResponse(
     516                    substr($challenge, 24, 8),
     517                    $password
     518                );
     519                //msg3
     520                $msg3 = $ntlm_client->typeMsg3(
     521                    $ntlm_res,
     522                    $username,
     523                    $realm,
     524                    $workstation
     525                );
     526                // send encoded username
     527                return $this->sendCommand('Username', base64_encode($msg3), 235);
    465528            case 'CRAM-MD5':
    466529                // Start authentication
    467530                if (!$this->sendCommand('AUTH CRAM-MD5', 'AUTH CRAM-MD5', 334)) {
     
    11831246
    11841247                return false;
    11851248    }
    1186 }
     1249}
     1250 No newline at end of file
  • wp-includes/class-phpmailer.php

     
    288288
    289289    /**
    290290     * SMTP auth type.
    291      * Options are CRAM-MD5, LOGIN, PLAIN, attempted in that order if not specified
     291     * Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified
    292292     * @var string
    293293     */
    294294    public $AuthType = '';
     
    15171517    public function getSMTPInstance()
    15181518    {
    15191519        if (!is_object($this->smtp)) {
    1520                         require_once( 'class-smtp.php' );
    15211520            $this->smtp = new SMTP;
    15221521        }
    15231522        return $this->smtp;
     
    40374036        $errorMsg = '<strong>' . $this->getMessage() . "</strong><br />\n";
    40384037        return $errorMsg;
    40394038    }
    4040 }
     4039}
     4040 No newline at end of file