Skip to content

Mail: Returning Envelope Sender #9412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
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 @@ -406,7 +406,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, false );
$phpmailer->setFrom( $from_email, $from_name );
} 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: 6 additions & 9 deletions tests/phpunit/tests/pluggable/wpMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,21 +408,18 @@ public function test_wp_mail_addresses_arent_encoded() {
}

/**
* Test that the Sender field in the SMTP envelope is not set by Core.
* Test that the Sender field in the SMTP envelope is set by Core.
*
* 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.
* A missing Sender field can lead to messages failing DMARC SPF checks.
*
* @ticket 37736
* @ticket 49687
*/
public function test_wp_mail_sender_not_set() {
wp_mail( '[email protected]', 'Testing the Sender field', 'The Sender field should not have been set.' );
public function test_wp_mail_sender_set() {
wp_mail( '[email protected]', 'Testing the Sender field', 'The Sender field should have been set.' );

$mailer = tests_retrieve_phpmailer_instance();

$this->assertSame( '', $mailer->Sender );
$this->assertSame( '[email protected]', $mailer->Sender );
}

/**
Expand Down
Loading