Make WordPress Core


Ignore:
Timestamp:
01/10/2026 11:50:11 PM (7 months ago)
Author:
SergeyBiryukov
Message:

External Libraries: Upgrade PHPMailer to version 7.0.2.

The latest version:

  • Includes a fix for sendmail parameter problems in WordPress.
  • Reduces memory consumption when sending large attachments.

References:

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

Props SirLouen, robinvandervliet, desrosj, siliconforks, digitalblanket, studiomondiale, jorbin, westonruter, dmsnell, zoe20, Monarobase, amanandhishoe, SergeyBiyrukov.
Fixes #64491. See #64368.

File:
1 edited

Legend:

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

    r61249 r61468  
    3535     *
    3636     * @var string
    37      */
    38     const VERSION = '7.0.0';
     37     * @deprecated This constant will be removed in PHPMailer 8.0. Use `PHPMailer::VERSION` instead.
     38     */
     39    const VERSION = '7.0.2';
    3940
    4041    /**
     
    495496        //so add them back in manually if we can
    496497        if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) {
     498            // phpcs:ignore PHPCompatibility.Constants.NewConstants.stream_crypto_method_tlsv1_2_clientFound
    497499            $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT;
     500            // phpcs:ignore PHPCompatibility.Constants.NewConstants.stream_crypto_method_tlsv1_1_clientFound
    498501            $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT;
    499502        }
     
    634637                    return false;
    635638                }
    636                 $oauth = $OAuth->getOauth64();
     639                try {
     640                    $oauth = $OAuth->getOauth64();
     641                } catch (\Exception $e) {
     642                    // We catch all exceptions and convert them to PHPMailer exceptions to be able to
     643                    // handle them correctly later
     644                    throw new Exception("SMTP authentication error", 0, $e);
     645                }
    637646                /*
    638647                 * An SMTP command line can have a maximum length of 512 bytes, including the command name,
     
    762771    }
    763772
     773    private function iterateLines($s)
     774    {
     775        $start = 0;
     776        $length = strlen($s);
     777
     778        for ($i = 0; $i < $length; $i++) {
     779            $c = $s[$i];
     780            if ($c === "\n" || $c === "\r") {
     781                yield substr($s, $start, $i - $start);
     782                if ($c === "\r" && $i + 1 < $length && $s[$i + 1] === "\n") {
     783                    $i++;
     784                }
     785                $start = $i + 1;
     786            }
     787        }
     788
     789        yield substr($s, $start);
     790    }
     791
    764792    /**
    765793     * Send an SMTP DATA command.
     
    790818         */
    791819
    792         //Normalize line breaks before exploding
    793         $lines = explode("\n", str_replace(["\r\n", "\r"], "\n", $msg_data));
     820        //Iterate over lines with normalized line breaks
     821        $lines = $this->iterateLines($msg_data);
    794822
    795823        /* To distinguish between a complete RFC822 message and a plain message body, we check if the first field
     
    798826         */
    799827
    800         $field = substr($lines[0], 0, strpos($lines[0], ':'));
     828        $first_line = $lines->current();
     829        $field = substr($first_line, 0, strpos($first_line, ':'));
    801830        $in_headers = false;
    802831        if (!empty($field) && strpos($field, ' ') === false) {
Note: See TracChangeset for help on using the changeset viewer.