Sending Automated Emails From Your Website
Sending automated emails from your website sounds simple, but if you run your own website which uses this functionality a lot, you may well be familiar with the dreaded problem of SPAM filters.
Successfully delivering email into a user’s inbox can be littered with pitfalls and it’s quite common for website owners to encounter issues where emails just aren’t delivered or they end up in a spam/junk folder most of time.
Over the years we have worked with many clients who struggled with this problem due to how their website was set up by a previous web developer, a lot of the time these are WordPress sites but the issues can be found on any type of website.
So why do automated emails so often end up not being delivered or end up in the spam folder?
The number one reason for the failure of email delivery is because the web developer is relying on the script behind website itself to send the emails, instead of sending the mail through a real mailbox.
For WordPress, Drupal and many other types of websites, the code behind the website relies on the PHP mail() function to send email, and this is the default method for sending email unless the website developer chooses otherwise.
Inexperienced web developers, or even just people trying to churn out websites as quickly as possible will quite commonly just leave the website to use this default setting, usually because they have done a couple of tests to their own email address and they got the mail successfully, and because they don’t have a deeper understanding of how email is delivered.
PHP mail can actually be carefully configured to correctly deliver email most of the time if it uses proper email headers, but there is a much more robust way to send email.
Using a real email address with a real SMTP (Simple Mail Transfer Protocol) server will see a much higher likelihood of your email always being delivered successfully.
This involves your website using the server and login details of a real email address to send the email. The website doesn’t use a script or send the email itself, it basically connects to the SMTP server of the real email address, tells it the subject, message and recipient and then the email is sent as if someone was manually sending email from that address.
Almost any email address can be used, as long as it has an SMTP host. For example, a Gmail address can be used, but of course you would want to be sending email from an address on your own website domain.
The reason this method is much more successful is because spammers normally use scripts instead of real email addresses, and anti-spam methods watch out for any script generated email and commonly mark it as spam or even reject the email altogether.
SPF, DKIM and DMARC
Simply using a real SMTP email address is not the end of the story and does not guarantee success. You also need to ensure that email host DNS records are correctly configured for Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM) and Domain-based Message Authentication, Reporting and Conformance (DMARC).
This is where things fall apart for most web developers, they simply don’t have the required knowledge of web hosting, email protocols and DNS records, and if they don’t have a web host doing all of this for them then their client ends up with an email service that is not fully configured to successfully deliver email 100% of the time.
The purpose of SPF, DKIM and DMARC is to prove to the email server that is receiving email that the incoming email is genuine, is coming from where it says its coming from and the sender can be identified.
When these 3 protocols are configured correctly, it is highly unlikely that the emails being sent from your website will end up in a user’s spam folder…unless the email contains suspicions content.
The last part of the puzzle is the actual content of the email itself.
A while ago we worked on a project where another web development company had set up a WordPress website for a sister organisation of one of our clients. Email was not being delivered or was ending up in spam/junk folders.
Because we manage the web hosting server for this client, we got involved to diagnose the issue.
The other web development company had made 2 mistakes. Firstly, they had configured the website to use the default PHP mail instead of a real mailbox, as described earlier. We identified this and set up a real email address with the correct SPF, DKIM and DMARC records, and provided the SMTP login details so they could use the real email address instead.
However, email was still going into some recipient’s spam/junk folders, or was not being received at all. We verified everything was correct on the server and the DNS records were all ok by using an independent 3rd party tool called MX Toolbox, and we provided this evidence to the other web development company, as any other factors were their responsibility, and we suggested that they look into the content of the emails.
The other web development company refused to believe the content of the emails could be to blame and weren't making much effort to resolve the issue, and because one of our valued clients was basically stuck with this, we decided to investigate it ourselves, even though it wasn’t within our remit!
We ran one of the emails through a spam analyser called Mail tester and low and behold, the content of the email had a high spam score. The reason? The beginning of the email was addressed with the text “Dear Friend,”. This is actually one of signals that the SpamAssasin spam filter uses to identify spam email. Combined with some other minor text issues, this was enough to mark the email as spam for some recipients with a more sensitive spam filter.
There are various different anti-spam filters used by different web hosts and email providers, so an email may be received ok at Gmail but is blocked at Hotmail etc, depending on the algorithm used. Some are a lot more sensitive than others, and in some cases will reject an email completely so it doesnt even make it to the spam folder.
Specialist Email Delivery Services
If you are sending large volumes of emails from your website, or you are sending critical transactional emails like invoices etc, where deliverability is very important, then you may want to consider using a specific solution built for this purpose instead of a regular mailbox. There are many of these services available, one of the more popular ones is called SendGrid. If sending via SMTP is causing you too many problems with deliverability, its maybe time to invest in one of these services.
We can set up SendGrid solutions for our clients websites when a robust, enterprise level automated email sending solution is essential.
The moral of the story is that sending automated emails isn’t as simple as it would appear, and you can’t just spin up a WordPress or Drupal website and expect emails to be delivered 100% of the time without further effort.
Using a proper SMTP email address, ensuring all email related DNS records are correctly configured, and finally ensuring the text of your emails doesn’t fall foul of a spam filter all combine to ensure your users or customers always get your emails 100% of the time, and if you're still experiencing email deliverability issues then its time to use a specialist email delivery service like SendGrid.
At Problue Solutions we have the knowledge and experience to ensure your website always delivers email successfully. If you would like to talk about a website project, get in touch.