The wp_mail function doesn't work after updating WordPress to version 4.6.

My code is:

$headers = 'From: ' . $this->from_name . ' <' . $this->from_email .'>' . "\r\n";
wp_mail( $service->getEmail(), $this->admin_daily_subject, $admin_daily_message, $headers );

It worked perfectly before the update. Also, I've noticed that sending emails doesn't work in Contact Form 7. Any ideas? Thanks in advance.


As I did not find the solution, I replaced wp_mail with mail function and added some headers:

$headers = 'From: ' . $this->from_name . ' <'.$this->from_email.'>' . "\r\n" .
                           'Reply-To: '.$this->from_email . "\r\n" .
                           'X-Mailer: PHP/' . phpversion() . "\r\n" .
                           "Content-Type: text/html; charset=UTF-8";
mail( $service->getEmail(), $this->admin_daily_subject, $admin_daily_message, $headers );

With this update it works. I hope there will be some updates of wp codex about using wp_mail() with 4.6 or somebody will find a solutions.


It looks like I am not the only one that is facing this issue:

There was an error trying to send your message

  • Could you turn debug on and see if there are errors? Aug 17, 2016 at 10:24
  • Already done, there is nothing in debug.log.
    – IvnH
    Aug 17, 2016 at 10:27
  • 3
    If you search for wp_mail on changes in 4.6 you will see that there are two changes. Maybe this will help somehow Aug 17, 2016 at 10:29
  • 1
    After you call wp_mail(), can you post the output of the phpmailer debug? global $phpmailer; echo $phpmailer->ErrorInfo Aug 17, 2016 at 12:24
  • 2
    If someone want to compare wp_mail with previous revision, it can be find here: https://core.trac.wordpress.org/changeset/38058/ Aug 17, 2016 at 13:27

3 Answers 3


The solution has been found here - Make WordPress Core

I've made changes in wp-includes/pluggable.php on line 352 from

$phpmailer->setFrom( $from_email, $from_name ); 


$phpmailer->setFrom( $from_email, $from_name, false ); 

And it works! Thanks to Marius L. J. (Clorith)!

  • 2
    Just a heads up - should WordPress push out a minor update your changes may be overridden. It's not suggestible to modify core files since they do often get overwritten on update.
    – Howdy_McGee
    Aug 19, 2016 at 18:54
  • 2
    I hope WordPress will include this patch in the new release, because this example was taken from wp core tracking website.
    – IvnH
    Aug 19, 2016 at 19:28
  • 1
    It will be included in 4.6.1
    – Ian Dunn
    Aug 21, 2016 at 18:46
  • How do you write this into a filter?
    – Chris Pink
    Oct 21, 2016 at 8:29

On you on WAMP? Regardless, it sounds like the built-in php mail() function in your php build is unavailable for whatever reason (it doesn't usually work on WAMP or on *nix builds that don't have an internal smtp server). Your best bet is probably to start using SMTP to send emails.

You could roll your own plugin for that, but I personally like to use WP Mail SMTP. You could use a gmail account for SMTP credentials or something like Mailgun depending on the volume of emails you need to send.

If you did want to write your own plugin, you would want to hook phpmailer_init and modify the global $phpmailer variable with something like this:

$phpmailer->Host = "smtp.example.com";
$phpmailer->Port = <SMTP PORT>;
$phpmailer->SMTPSecure = 'ssl';  //optional, can also be 'tls'
$phpmailer->SMTPAuth = true;
$phpmailer->Username = '<your smtp username>';
$phpmailer->Password = '<your smtp password>';
  • Thanks for your reply, It worked on my hosting before update of WP and on hundreds of plugin users websites. Also I'am looking on Contact form 7 support forum and many people face the same problem with CF7.
    – IvnH
    Aug 17, 2016 at 13:12

I installed WP-Mail-SMTP Created a [email protected] with a 0b quote. Configured the WP-Mail-SMTP to use the [email protected] - SSL On - Change localhost to the server you host on - SMTP port for SSL is 465 Tested WP-Mail-SMTP worked.

I them still could not get contact form 7 to work, I then thought missing piece of that puzzle was that I had to edit the contact form 7 from address which was [email protected] to be [email protected]

Also, reading the https://contactform7.com/faq/ was helpful, turned me onto using the track delivery app in the cpanel hosting, good to check this as it will tell you if your even connecting and trying to send email. Also user had akismet enabled but was not active so turned that off. Also mentions some issues with cache clearing frequency.

Other things to look at are if you have the right PHP version set in cPanel.

A previous post mentioning to edit pluggable.php in wp includes is a bad idea, you should not be editing the core of WordPress to fix such issues as a new core update will just break it again most likely.


I removed captcha from one form that was not working and it worked!!


Something with recaptcha is broken.


Plugin support forums about recaptcha breaking the form sending said to add:


Thought I would document my entire effort to fix in case any of my failed efforts bear fruit for someone else struggling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.