Opened 20 months ago
Last modified 13 months ago
#18792 accepted defect (bug)
Wrong FROM email when using wp_mail and built in mail() function
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | External Libraries | Version: | 3.2.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | knut@… |
Description
When using wp_mail in combination with mail() function, then From: envelope passed through -f parameter to sendmail is not set correctly.
Here is simple patch, that fixes the problem:
--- pluggable.php 2011-09-26 20:54:02.219330702 +0200
+++ pluggable.fixed.php 2011-09-27 18:19:21.283454810 +0200
@@ -394,8 +394,7 @@
}
// Plugin authors can override the potentially troublesome default
- $phpmailer->From = apply_filters( 'wp_mail_from' , $from_email );
- $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );
+ $phpmailer->SetFrom(apply_filters('wp_mail_from', $from_email),apply_filters('wp_mail_from_name', $from_name));
// Set destination addresses
if ( !is_array( $to ) )
Change History (4)
- Component changed from Mail to External Libraries
- Owner set to westi
- Status changed from new to accepted
comment:3
KevinHamilton — 13 months ago
- Keywords has-patch added
I hit a similar issue with the 'return-path' and 'reply-to' email headers not being correctly populated. Using the setFrom() method helps ensure that headers are correctly assigned.
At the moment a simple plugin helps resolve the issue, but it would be great to hear if these patches will make their way in the core in the future.
Note: See
TracTickets for help on using
tickets.

If sending emails in a loop with a different From address for each, the above patch results in the envelope for all being set to the same as the first. Need to also reset the Sender property, as in the following patch: