Make WordPress Core


Ignore:
Timestamp:
09/30/2025 12:46:53 PM (14 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Upgrade PHPMailer to version 6.11.0.

This is a large maintenance release with address parser improvements.

References:

Follow-up to [54937], [55557], [56484], [57137], [59246], [59481], [60623].

Props SirLouen, jrf, mukesh27, SergeyBiryukov.
Fixes #64052.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/PHPMailer/SMTP.php

    r60623 r60813  
    3636     * @var string
    3737     */
    38     const VERSION = '6.10.0';
     38    const VERSION = '6.11.0';
    3939
    4040    /**
    … …  
    206206        'ZoneMTA' => '/[\d]{3} Message queued as (.*)/',
    207207        'Mailjet' => '/[\d]{3} OK queued as (.*)/',
     208        'Gsmtp' => '/[\d]{3} 2\.0\.0 OK (.*) - gsmtp/',
    208209    ];
    209210
    … …  
    634635                }
    635636                $oauth = $OAuth->getOauth64();
    636 
    637                 //Start authentication
    638                 if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
    639                     return false;
     637                /*
     638                 * An SMTP command line can have a maximum length of 512 bytes, including the command name,
     639                 * so the base64-encoded OAUTH token has a maximum length of:
     640                 * 512 - 13 (AUTH XOAUTH2) - 2 (CRLF) = 497 bytes
     641                 * If the token is longer than that, the command and the token must be sent separately as described in
     642                 * https://www.rfc-editor.org/rfc/rfc4954#section-4
     643                 */
     644                if ($oauth === '') {
     645                    //Sending an empty auth token is legitimate, but it must be encoded as '='
     646                    //to indicate it's not a 2-part command
     647                    if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 =', 235)) {
     648                        return false;
     649                    }
     650                } elseif (strlen($oauth) <= 497) {
     651                    //Authenticate using a token in the initial-response part
     652                    if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2 ' . $oauth, 235)) {
     653                        return false;
     654                    }
     655                } else {
     656                    //The token is too long, so we need to send it in two parts.
     657                    //Send the auth command without a token and expect a 334
     658                    if (!$this->sendCommand('AUTH', 'AUTH XOAUTH2', 334)) {
     659                        return false;
     660                    }
     661                    //Send the token
     662                    if (!$this->sendCommand('OAuth TOKEN', $oauth, [235, 334])) {
     663                        return false;
     664                    }
     665                    //If the server answers with 334, send an empty line and wait for a 235
     666                    if (
     667                        substr($this->last_reply, 0, 3) === '334'
     668                        && $this->sendCommand('AUTH End', '', 235)
     669                    ) {
     670                        return false;
     671                    }
    640672                }
    641673                break;
    … …  
    13101342                //stream_select returns false when the `select` system call is interrupted
    13111343                //by an incoming signal, try the select again
    1312                 if (stripos($message, 'interrupted system call') !== false) {
     1344                if (
     1345                    stripos($message, 'interrupted system call') !== false ||
     1346                    (
     1347                        // on applications with a different locale than english, the message above is not found because
     1348                        // it's translated. So we also check for the SOCKET_EINTR constant which is defined under
     1349                        // Windows and UNIX-like platforms (if available on the platform).
     1350                        defined('SOCKET_EINTR') &&
     1351                        stripos($message, 'stream_select(): Unable to select [' . SOCKET_EINTR . ']') !== false
     1352                    )
     1353                ) {
    13131354                    $this->edebug(
    13141355                        'SMTP -> get_lines(): retrying stream_select',
Note: See TracChangeset for help on using the changeset viewer.