Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
$from_name = apply_filters( 'wp_mail_from_name', $from_name );

try {
$phpmailer->setFrom( $from_email, $from_name );
$phpmailer->setFrom( $from_email, $from_name, false );
} catch ( PHPMailer\PHPMailer\Exception $e ) {
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
$mail_error_data['phpmailer_exception_code'] = $e->getCode();
Expand Down
15 changes: 9 additions & 6 deletions tests/phpunit/tests/pluggable/wpMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,21 @@ public function test_wp_mail_addresses_arent_encoded() {
}

/**
* Test that the Sender field in the SMTP envelope is set by Core.
* Test that the Sender field in the SMTP envelope is not set by Core.
*
* A missing Sender field can lead to messages failing DMARC SPF checks.
* Correctly setting the Sender requires knowledge that is not available
* to Core. An incorrect value will often lead to messages being rejected
* by the receiving MTA, so it's the admin's responsibility to
* set it correctly.
*
* @ticket 49687
* @ticket 37736
*/
public function test_wp_mail_sender_set() {
wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should have been set.' );
public function test_wp_mail_sender_not_set() {
wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' );

$mailer = tests_retrieve_phpmailer_instance();

$this->assertSame( 'wordpress@example.org', $mailer->Sender );
$this->assertSame( '', $mailer->Sender );
}

/**
Expand Down
Loading