Troubleshooting wp_mail WordPress Email Configuration

This is a continuation of the thoughts presented in the article “Testing the wp_mail Function.”  That article focused on how to actually check your WordPress email configuration with direct test of the wp_mail function to be sure that the function itself is working.  This is a good place to start if you are troubleshooting because if the function itself is not working, you need to track that down first.

If you have determined that wp_mail is operable, it is then probable that emails are being generated.  Knowing this, the next step is to consider other elements of your WordPress email configuration to track down why emails are not being sent or received.

Understanding script based email

WordPress sends email using wp_mail, a function that for all practical purposes operates like php’s mail. It is a way for your site to send email via a PHP script.

In order to determine what your problems might be, it is important to understand the potential email configuration requirements. Some issues could be server-based, others could be not understanding restrictions by your host.

What are 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. If you spend a lot of time trying to track down problems before even knowing if you are in compliance with your host’s email policies, you could be wasting a lot of time.

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 by default sends email from a generic address “[email protected]”. If your host has a requirement that you send from a valid email address and you don’t have a [email protected] email configured, then your site can’t send email.

This isn’t a requirement with all hosts, but you should check to see if it is a requirement of yours. If this is a requirement, there are some things you can do to change the default “from” address.  See the following:

Another commonly overlooked issue that is similar is that some hosts require you send with a valid “from” header. Again, the WordPress default configuration doesn’t cover this – it sends email without headers.

Are you on a shared server?

In general, on shared hosting, the email process is shared, too. 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).

For those running WordPress on shared hosts, the issue most often is that email is delayed (sometimes significantly), not that it is inoperable.  But it is important to know if this is something you are likely to be effected by.  Just because someone doesn’t receive a message within seconds does not by itself mean that the message is not being sent.  It could be delayed.

What about spam filters?

Sometimes, the issue is that certain messages are simply blocked because of an addressing issue.  Emails coming into one of the major email provider domains (hotmail, aol, gmail, yahoo) can get flagged for a number of reasons.

If email from wp_mail is not getting delivered, you may need to consider is it not 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

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.

My usual solution for this is a plugin called WP Mail SMTP.  The problem with this is that the plugin has not been updated in over 2 years.  That could mean issues with more recent versions of WordPress (although at present that shouldn’t be the case) and also means you are likely on your own for support.

There are a few other plugins out there for this purpose as well.  Although not as popular (yet) as WP Mail SMTP, Easy WP SMTP looks promising.  Another is WP SMTP.

Using one of these plugins is an easy way to change your WordPress email configuration to send email via SMTP.  That 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:


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>