None of my Wordpress emails are sent to Gmail. More info:
- I am using EXIM mail server
- I am using wordpress latest version
- it happens only when emails are sent to Gmail
EXIM logs say that the email is sent succesfully to Gmail, but they are not sent, or sent in spam.
The problem is a combination of factors:
Sender
headerSender
header, it will most likely silently discard it, or send it as spam.Sender
headerOnce you know these, the fix is quite simple. If you are using Wordpress, the quick and dirty way to do it is to go to
wp-includes/pluggable.php
, look for thewp_mail()
function search for:then add the following right after it:
Once you do this, emails will work, and you can fix the problem the proper way, without overwriting the core, by writing a plugin. Wordpress uses phpmailer which knows about this issue, but wordpress doesn't use it. There is also a bug report on this issue.
To fix the problem using the core mail() function, you have to do the following:
There is another option that may work, depending on the configuration of your server (I couldn't test it, would love if someone could test this):