mirror of
git://develop.git.wordpress.org/
synced 2025-04-26 07:02:13 +02:00
Mail: Reset PHPMailer properties between use.
Props xknown, martinkrcho, tykoted. git-svn-id: https://develop.svn.wordpress.org/trunk@54529 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ebaac57a9a
commit
3765886b49
@ -353,6 +353,8 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
$phpmailer->clearAttachments();
|
||||
$phpmailer->clearCustomHeaders();
|
||||
$phpmailer->clearReplyTos();
|
||||
$phpmailer->Body = '';
|
||||
$phpmailer->AltBody = '';
|
||||
|
||||
// Set "From" name and email.
|
||||
|
||||
|
@ -475,4 +475,21 @@ class Tests_Mail extends WP_UnitTestCase {
|
||||
$this->assertTrue( $result1 );
|
||||
$this->assertFalse( $result2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that AltBody is reset between each wp_mail call.
|
||||
*
|
||||
* @covers :wp_mail
|
||||
*/
|
||||
public function test_wp_mail_resets_properties() {
|
||||
$wp_mail_set_text_message = function ( $phpmailer ) {
|
||||
$phpmailer->AltBody = 'user1';
|
||||
};
|
||||
add_action( 'phpmailer_init', $wp_mail_set_text_message );
|
||||
wp_mail( 'user1@example.localhost', 'Test 1', '<p>demo</p>', 'Content-Type: text/html' );
|
||||
remove_action( 'phpmailer_init', $wp_mail_set_text_message );
|
||||
wp_mail( 'user2@example.localhost', 'Test 2', 'test2' );
|
||||
$phpmailer = $GLOBALS['phpmailer'];
|
||||
$this->assertNotSame( 'user1', $phpmailer->AltBody );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user