WordPress.org

Make WordPress Core

Changeset 38287


Ignore:
Timestamp:
08/20/2016 02:20:04 AM (3 years ago)
Author:
boonebgorges
Message:

Mail: Don't set Sender field when setting From.

[38058] changed wp_mail() so that it used PHPMailer's setFrom()
method rather than setting the From and FromName headers directly. See
behavior of setting the Sender field. This causes mail to be
called with the -f flag, which causes outgoing email to fail on some
server environments.

Merges [38286] to the 4.6 branch.

Props Clorith, iandunn, DrewAPicture.
Fixes #37736.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/pluggable.php

    r38058 r38287  
    350350    $from_name = apply_filters( 'wp_mail_from_name', $from_name );
    351351
    352     $phpmailer->setFrom( $from_email, $from_name );
     352    $phpmailer->setFrom( $from_email, $from_name, false );
    353353
    354354    // Set destination addresses
  • branches/4.6/tests/phpunit/tests/mail.php

    r38058 r38287  
    343343        }
    344344    }
     345
     346    /**
     347     * Test that the Sender field in the SMTP envelope is not set by Core.
     348     *
     349     * Correctly setting the Sender requires knowledge that is not available
     350     * to Core. An incorrect value will often lead to messages being rejected
     351     * by the receiving MTA, so it's the admin's responsibility to
     352     * set it correctly.
     353     *
     354     * @ticket 37736
     355     */
     356    public function test_wp_mail_sender_not_set() {
     357        wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' );
     358
     359        $mailer = tests_retrieve_phpmailer_instance();
     360
     361        $this->assertEquals( '', $mailer->Sender );
     362    }
    345363}
Note: See TracChangeset for help on using the changeset viewer.