The Ultimate WordPress Email Troubleshooting Guide

black and gray digital device

Email communication is one of the most important part of any website. There is just so much riding on effective email communication. Even though there is more spam emails than ever, more marketing emails but for transactional communication it is the best and easiest route to implement.

While a good Email communication adds to trust of a site, a missing email communication can lead to trust deficit.

“Imagine purchasing a product and not getting an order confirmation email”. While implementation is easiest, maintenance and monitoring is not. Luckily for WordPress sites, the WordPress has inbuilt email functionality called “wp_mail” which takes care of the implementation part. Other plugins like BuddyPress user their own version of Email implementation via a PHP library called PHPMailer. In case you want to send BuddyPress emails via WP_MAIL use this plugin

Identifying the Problem

There are various levels at which the email sending problem can appear. Assuming you have already installed a contact form plugin and verified that the emails are not being sent.

  1. DNS records : This means that the mail server in your WordPress web host is not configured properly.
  2. Email Buffer overflow : Every mail server has a email buffer which stores all the outgoing emails which the server is unable to sent in realtime. Once this buffer is full, the emails coming next are simply rejected.
  3. Code : A poorly written code or a the server could simply be sending an email in a loop or a barrage of emails are sent at a time all in one go. There is little you can do about this, the trick is to avoid scenarios which can lead to a barrage of emails. Remove certain defaults like BBPress auto subscription to forums, BuddyPress site notices etc.
  4. SPAM : Once your domain has been marked as spam or blacklisted, you will need to appeal to various email clients to remove it from the spam list.
  5. Debugging from Mail Server logs : You can get clues from the mail logs on what is wrong with your emails.

While the quick fix for solving email issues has been installing a Email relay service which uses their own servers for sending emails. The positive side is that emails are sent reliability the downside is that the service can cause a lag as it involves an additional API hit to a third party server for “every” mail.

Which means for bulk emails the Lag would be pretty significant. WordPress core contributor Konstantin explains it in this blog post that using third party Email relay service can be slow as 90 times for a 20 bulk email than handling emails on your own WP server.

There are multiple softwares to enabling mail service in your service, if you are not using cpanel you can easily install them manually, like Postfix, SendMail, Exim, Qmail etc. delving into these is out of scope for this article but PostFix is the most reliable option and sendmail is the most popular one created in 1980s.

DNS Configuration

If your server is also the Mail server for your site, you have to ensure that there are 3 entries which should be present in your DNS. You must ensure that your DNS, cloudflare or godaddy has these entries in the DNS records.

There are three records required : PTR, DKIM and the SPF.

If you have cpanel in your web host, you can easily find these entries in the Cpanel – Mail – Configuration. If you do not have cPanel installed check the site https://www.mail-tester.com/ to find issues related to the emails and it will show all the records missing in your DNS.

PTR

The PTR is the reverse DNS which helps the Mail clients (gmail, outlook) to verify the source of the mail. Like the mails sent by your server have a “From” email header, “a[email protected]” and the “yoursite.com” is on same server IP this record helps verify that the sending server ip is same as the from mail. So, you should never set an email like [email protected] (“From” email different than the site) as your “From” email in emails which are sent from the site.

DKIM

This record is an authentication which helps email senders and recipients from spoofing and phishing emails. This is like you take responsibility of the emails which are sent from your mail server. Adding genuineness to the emails sent from your server.

SPF

This record confirms that the mail server and your site domain is allowed to send email on behalf of your domain.

Google Postmasters

The last step is telling Google that you are the contact person for emails sent from this domain to the gmail client. This is almost necessary if you want Gmail to accept emails sent by your server. Registration is easy, just go to postmaster.google.com and add your domain, you will be required to enter DNS entry to verify. Once verified this ensures that the emails will be received by Gmail. Note, this ensures emails are delivered to Gmail otherwise they’re simply rejected.

Analysis of EXIM

You will be able to find exim reports in Email deliverability of WHM panel. Or directly download it via SSH. It gives an exact reason why the emails are not being sent out.

this will help you in identifying the problems in your emails. In fact any problem in email sending including blacklisting by email clients can be located here.

Email buffer overflow

Every Mail server has a buffer where it stores all incoming emails. Every mails server has a maximum rate limit on how many emails it can send per hour. Once that buffer is full the emails are rejected. The only solution is to either reduce the number of emails sent out or increase the number of mails sent per hour.

Code

Writing efficient code for emails is really the key for any good code that sends emails. Before 2017 it was really impossible to avoid the situation where bulk emails are sent in 1 php process itself. For example, You want to send a bulk Email notice to all the thousand members of your site, the only option to do so was a PHP Mail loop for 1000 users. Not only that will consume enormous resources from your server but also render server irresponsive for that time. With new age technologies like Workers, you get the option to run the mail loop via javascript which sends php email in batches of 20 emails and does not affect the front end performance as Javascript worker do not stop the main script execution. We’re using this strategy in Send All Member Notice feature in VibeBP.

Emails landing in SPAM

Another big issue is that Emails often land in SPAM. Once you have verified that the DNS records are correct, it comes down to the reputation of your Site and your server. Now, different email clients, like gmail, hotmail ,live,outlook , yahoo have their own interface to file an appeal for the mails not being sent.

The first point is to verify your “SenderScore” for the emails by simply filling out a form on senderscore.org and enter your server IP address which is sending the emails.

Another tool to verify your sender score is called https://www.mail-tester.com/ , you have to send an email from your domain and then verify the score.

In case you find some issues, like you are blacklisted by Gmail or Outlook, you will have to file an appeal with them which can take many days to clear.

While for Gmail we have Google postmasters , for Hotmail / Live / Outlook / Yahoo you will have to register on Outlook postmasters. Another way is to go to SpamHaus project and use their request removal tool.

While writing this article I did a through check on what exists on internet and it was astonishing to note that many big sites only talk about installing a Mail plugin that is bypassing the not sending email issue altogether which is no troubleshooting at all. Further more using third party plugins having outside mail server have an adverse effect on site’s performance.

I would be regularly updating this article with new information in future as well. Hope this article helps you in debugging and solving the mail issues in your WordPress site.

Leave a Reply

%d bloggers like this: