Email send stops working on a WordPress site: Troubleshooting

The other day we had an issue where emails just stopped working on one site.  Emails from Contact Form 7, Event Espresso, and even standard WordPress functionality like notification email for new user sign up.

We finally got it fixed – turned out to be a problem on the host side – but I thought I’d share the troubleshooting we did, because it really helped to narrow down the possible problem and save us some time.

The first thing to do in troubleshooting is to narrow down the possible causes of the problem.

First, is it happening throughout all mail functionality on the site?  If you aren’t receiving emails from, for example, Contact Form 7, is it a problem with your contact form, or is it ALL mail functionality on the site.   Try testing other mail functionality – like new user signup, comment notifications, etc.  In our case, it was first reported as a problem with our Event Confirmation emails in the Event Espresso plugin, but a quick test revealed that our contact form wasn’t working either.

Obviously, if you’ve just installed something, like a new plugin, that would be the first place to look.  Plugins can conflict with each other and cause problems.  Or, if you’ve just done an upgrade of WP.  But in this case, we hadn’t made any significant site changes in the previous few days.   And we checked to make sure the emails for the site were functional (eg you can send/receive emails at @yoursite.com email addresses, particularly your admin email) .  [As an aside, I did run across info that some servers (GoDaddy?) are picky about what your admin email is — one thing to try when you’re having problems is to set your admin email to something like info@yoursite.com, and set up that email address to forward to your yahoo or gmail type email address] But in our case, our emails were functioning correctly, so that wasn’t the problem.

Most  WordPress mail funtionality uses php mail() as the way to send messages, so if you’re unable to receive emails sent from the site, a good test is to see if php mail is working on your server, outside of WordPress.   If you can’t get php mail to work outside of WordPress, you can pretty much rule out WordPress or any plugins as your problem, and go straight to technical support at your host with that info.

To test php mail is really simple, you don’t need to be able to code to do this, just know how to create a file, copy/paste, and ftp the file to your site.

1. Create a new file (use Notepad if you don’t have a better text editor) and call it emailtest.php.
2. In the file, minimally you’ll need something like this (obviously replacing the email address below with YOUR email address):

If you want even more information it’s a good idea to add something like this, which will echo back the from and to, and also allows you to specify the “from” . (Again, replace the email and the from email with actual emails-a good test is to use your personal email as the $email, and your site admin email as the $fromemail)  :

For my test file, I actually included both of the above, plus the second test again with different emails that were not from my site’s domain–I changed the email to my gmail account, for example.

Save the file and place it on your server, in the same location as your wp-config.php  file for your site.

Then in your browser, go to http://whateveryoursite.com/emailtest.php

When you load the page, it will attempt to send your emails.  If it works, you should get success messages for all 3 tests, and receive 3 emails to the specified accounts.

If everything succeeds, then your problem is likely to be within WordPress, so return to troubleshooting there, looking for conflicting plugins and such.

If everything fails, or even more interestingly, parts of it fail, then you have more information to work with, and to take to your host’s support folks.

In our case, we had the bizarre situation where the simple case (no from specified) failed, and the only way the more complex test would pass was if we sent to an email address on our domain. This definitely looked like a host issue, so we passed our results on to support, including pointing them to the test file we’d created, and they fixed it very quickly (kudos Bluehost!).

But having this information up front helped to get us to the right people in support and avoided any pushback that it was something within our control that we had broken.

Source for the basis of this script: http://wordpress.org/support/topic/sign-up-not-working-properly-on-my-site and also support on the Bluehost forums