mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
External Libraries: Upgrade PHPMailer to version 6.1.6.
Now that WordPress Core supports PHP >= 5.6, the PHPMailer library can be updated to the latest version. The PHPMailer files now reside in a new directory, `wp-includes/PHPMailer`. These files are copied verbatim from the library upstream and will make updating in the future easier. For backwards compatibility, the old files will remain and trigger deprecated file warnings. The PHPMailer class is also now under the `PHPMailer\PHPMailer\PHPMailer` namespace. The `PHPMailer` class in the global namespace has been aliased for a seamless transition. This upgrade also clears up a handful of PHP compatibility issues detailed in #49922. For a full list of changes, see the PHPMailer GitHub: https://github.com/PHPMailer/PHPMailer/compare/v5.2.27...v6.1.6. Props Synchro, SergeyBiryukov, desrosj, donmhico, ayeshrajans. Fixes #41750. git-svn-id: https://develop.svn.wordpress.org/trunk@48033 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -158,7 +158,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
*
|
||||
* @since 1.2.1
|
||||
*
|
||||
* @global PHPMailer $phpmailer
|
||||
* @global PHPMailer\PHPMailer\PHPMailer $phpmailer
|
||||
*
|
||||
* @param string|array $to Array or comma-separated list of email addresses to send message.
|
||||
* @param string $subject Email subject
|
||||
@@ -210,10 +210,11 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
global $phpmailer;
|
||||
|
||||
// (Re)create it, if it's gone missing.
|
||||
if ( ! ( $phpmailer instanceof PHPMailer ) ) {
|
||||
require_once ABSPATH . WPINC . '/class-phpmailer.php';
|
||||
require_once ABSPATH . WPINC . '/class-smtp.php';
|
||||
$phpmailer = new PHPMailer( true );
|
||||
if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) {
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
|
||||
require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
|
||||
$phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
|
||||
}
|
||||
|
||||
// Headers.
|
||||
@@ -356,7 +357,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
|
||||
try {
|
||||
$phpmailer->setFrom( $from_email, $from_name, false );
|
||||
} catch ( phpmailerException $e ) {
|
||||
} catch ( PHPMailer\PHPMailer\Exception $e ) {
|
||||
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
|
||||
$mail_error_data['phpmailer_exception_code'] = $e->getCode();
|
||||
|
||||
@@ -404,7 +405,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
$phpmailer->addReplyTo( $address, $recipient_name );
|
||||
break;
|
||||
}
|
||||
} catch ( phpmailerException $e ) {
|
||||
} catch ( PHPMailer\PHPMailer\Exception $e ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -455,12 +456,16 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
foreach ( (array) $headers as $name => $content ) {
|
||||
// Only add custom headers not added automatically by PHPMailer.
|
||||
if ( ! in_array( $name, array( 'MIME-Version', 'X-Mailer' ), true ) ) {
|
||||
$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
|
||||
try {
|
||||
$phpmailer->addCustomHeader( sprintf( '%1$s: %2$s', $name, $content ) );
|
||||
} catch ( PHPMailer\PHPMailer\Exception $e ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) {
|
||||
$phpmailer->addCustomHeader( sprintf( "Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary ) );
|
||||
$phpmailer->addCustomHeader( sprintf( 'Content-Type: %s; boundary="%s"', $content_type, $boundary ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +473,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
foreach ( $attachments as $attachment ) {
|
||||
try {
|
||||
$phpmailer->addAttachment( $attachment );
|
||||
} catch ( phpmailerException $e ) {
|
||||
} catch ( PHPMailer\PHPMailer\Exception $e ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -486,17 +491,17 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
// Send!
|
||||
try {
|
||||
return $phpmailer->send();
|
||||
} catch ( phpmailerException $e ) {
|
||||
} catch ( PHPMailer\PHPMailer\Exception $e ) {
|
||||
|
||||
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
|
||||
$mail_error_data['phpmailer_exception_code'] = $e->getCode();
|
||||
|
||||
/**
|
||||
* Fires after a phpmailerException is caught.
|
||||
* Fires after a PHPMailer\PHPMailer\Exception is caught.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param WP_Error $error A WP_Error object with the phpmailerException message, and an array
|
||||
* @param WP_Error $error A WP_Error object with the PHPMailer\PHPMailer\Exception message, and an array
|
||||
* containing the mail recipient, subject, message, headers, and attachments.
|
||||
*/
|
||||
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
|
||||
|
||||
Reference in New Issue
Block a user