[wp-hackers] Bug in wp_mail

Ron Guerin ron at vnetworx.net
Sun Feb 21 22:08:24 UTC 2010


Peter Westwood wrote:
> On 21 Feb 2010, at 21:07, Ron Guerin wrote:
>
>   
>> I think something else must be wrong in addition, since WP is
>> overriding  PHP's explicit sendmail_from , which it seems to me should
>> be a workaround for a mere failure to set the sender.
>>
>> I have patched the bug locally by adding (wp-includes/pluggable.php)
>>
>>        // 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->Sender = $from_email;
>>
>> ... but this will be overwritten at next upgrade, and I'm guessing the
>> problem really needs something more than that as a proper fix.
>>
>>     
>
>
> This has been discussed at length in the past:
>
> http://core.trac.wordpress.org/ticket/5007
> http://core.trac.wordpress.org/ticket/5294
>
> Basically, what we have at the moment works best for the largest percentage of end-users.
>   

I'll grant that getting PHP mail() to do the right thing by everyone
isn't always easy, but other people do it.  (I have done so myself) This
is a bug, not a feature.

> If you want to for sender to be set the same as $from_email then the follow (untested) plugin should do the trick.
>
> <?php
> /*
>  * Plugin Name: pjw-wp-phpmailer-sender-equals-from
>  * Version: 0.1
>  * Plugin URI: http://blog.ftwr.co.uk/#
>  * Description: Set the sender on PHPMailer to be the same as From
>  * Author: Peter Westwood
>  * Author URI: http://blog.ftwr.co.uk/
>  **/
>
> add_action('phpmailer_init', 'pjw_phpmailer_init');
>
> function pjw_phpmailer_init($php_mailer) {
>     $php_mailer->Sender = $phpmailer->From;
> }
> ?>
>
>   

I thought about doing something like this myself, but I feel using
plugins to fix bugs in WordPress is really not a solution, it's
avoidance of the problem.  Every new copy of WP that gets installed is a
new opportunity for the bug to manifest itself, and only further
encourages people to ignore mail coming from buggy webapps running on
their web servers.

- Ron


More information about the wp-hackers mailing list