This is a continuation of the article “Testing your WordPress email settings for the wp_mail function.” That article explains how to check your WordPress email configuration. This is a good place to start because if the function itself is not working, you need to track that down first. It will tell you if issues are “upstream” from the function, and thus not related to your email settings.
If you determine wp_mail is functioning, then you can assume emails are generated. If they are, the next step is to consider other elements of your WordPress email configuration. This tracks “downstream” issues of why emails are not sent or received.
Understanding script based email
In order to determine what your problems might be, it is important to understand the potential email configuration requirements. Some issues are with the server. Other problems could be not understanding restrictions by your host.
Do your wp_mail settings conflict with your host’s email policies?
Valid email accounts
The first thing to know is what your host’s policies are for sending email via web scripts. Knowing if you are in compliance with your host’s email policies at the start could save a lot of time.
The wp_mail function by default will send from “firstname.lastname@example.org”. If that’s not an actual email address for yourdomain.com, your host may restrict sending. Check with your host to know if they require the “from” address be a real email. You can change the “from” address with WP’s “wp_mail_from” and “wp_mail_from_name” filters or you can use an SMTP account.
Valid email headers
Some hosts require that any server-side email script send with a “from” address that is an actual email address. This may seem basic, but I’ve had a lot of support inquiries that didn’t bother to check this. WordPress default configuration doesn’t cover this – it sends email without headers.
Make sure the return-path header is not only a valid address, but also matches the “from” address. This avoids flagging the message as spam. You can take care of this either by sending through an SMTP server or filter the phpmailer to make this match your “from” address.
Are you on a shared server?
If another user on your host has a script that is tying up the email server, that is going to effect your site (and therefore your email script).
On shared hosts, delayed email is a common problem. Remember that just because someone doesn’t receive a message within seconds does not by itself mean that the message is not being sent. Delayed sending may be the problem in this case.
What about spam filters?
Certain messages are blocked for address issues. Emails coming into one of the major email provider domains (hotmail, aol, gmail, yahoo) can get flagged for a number of reasons.
One question to consider is whether email is getting through to everyone, or is this limited to certain domains? Getting blocked or blacklisted by a specific host could be an issue.
An easy solution for wp_mail settings
The simplest way around all of this is to use a valid email account sent through an SMTP server. SMTP stands for Simple Mail Transfer Protocol and sending through an SMTP server simply means you have set up a real email address on your system and you are allowing the web based script (wp_mail) to connect to the server with appropriate account credentials. This will satisfy most hosting requirements and also help you avoid system bottlenecks on shared hosting.
No matter which way you choose to approach it, SMTP is a more reliable and more stable way of sending email through WordPress.
For more information on testing, troubleshooting, and changing your WordPress email configuration for wp_mail, here are some additional posts:
- Testing your WordPress email settings for the wp_mail function – some information on wp_mail and a testing script you can use to make sure it is sending messages.
- WordPress Email Settings: Changing the wp_mail address with a simple plugin – here is a very simple and lightweight script you can load as a plugin to change the email address that WordPress sends email from.
- Changing the wp_mail from address in WordPress without a plugin – provides a simple code snippet you can use to change the email address that WordPress sends from, no plugin required.
- Easy SMTP email settings for WordPress – how to change your WordPress email configuration to send email from a valid SMTP server with a simple script, no plugin required.