Important Note: Don’t miss out on the formatting tips and extra plugins at the end of this guide..! 😉
What is an SMTP Server?
SMTP stands for Simple Mail Transfer Protocol. An SMTP Server basically is a transactional service that sends emails for you. You connect to the service (with authentication credentials) and give it the email data and it send it for you. (End noob rant.)
Why should you use an SMTP Email Plugin for WordPress?
Even if you are using an external newsletter service, at some stage WordPress – or a WordPress plugin – will want to send an email – whether to you, another site admin, a customer or other user. Whether it’s new user notifications or lost password or order receipts – it’s gonna happen. Using a trusted SMTP mail server (external mailing service) for sending these emails WILL increase their deliverability overall, and less lost emails will mean a better user experience for your visitors and reflect better on your business.
Sending emails from your own domain is simply not as good because if you get listed via SPAM blocklists (because for example people still do mark as SPAM lists or newsletters they have forgotten that they have signed up to!) it will reduce your email deliverability and thus cause you unnecessary business hiccups and support issues from people simply not receiving your legitimate emails. So the sooner you do this it will be less headaches!
Setting up SMTP mailing will also mean if you are using a newsletter plugin (such as our free WP Infinity Responder) rather than an external service, that those emails will be send via SMTP too. In fact anything uses the wp_mail() function will be send via the SMTP service. So this is partly a guide for using SMTP for that plugin (rather than adding SMTP support into WP Infinity Responder when existing plugins handle it well already.) A few other newsletter plugins do have internal SMTP support so if you are using one you might want to use those settings as well (or check if it is necessary) – but even then, it is still important to set up SMTP mailing for the rest of your system emails!
Where do I get an outgoing SMTP mail server account?
There are a number of free and paid alternatives depending on your email volume of course. If you are starting out, I recommend using SendGrid or MailGun. They both have great free plans for sending emails via there SMTP servers and a good reputation. Of course if you are already using a premium newsletter service such as MailChimp you can probably just use that account too (eg. the MailChimp SMTP service is called Mandrill.) Of course there are other for reputatable email sending services that you can find. But do note, it is generally better to NOT use your website hosting or internet service provider’s SMTP server, as you cannot be guaranteed what kind of email sending reputation they have – if other users get blocked for abuse you can be too!
How do I setup outgoing SMTP mail for WordPress?
By default, WordPress uses it’s internal wp_mail function to send mail (using php_mailer rather than just the mail() or sendmail() function.) So basically you need a plugin that hooks into the existing wp_mail function and tells it to send the email using the SMTP server instead. Fortunately, there are a number of WordPress plugins that do this for you, but some of them are better than others of course. You should be able to easily enter your SMTP credentials into any SMTP plugin by simple (but careful) copy and paste. (Some will also take an API key for a specific service.) Then send a test email to make sure it is working fine (Gentle reminder: Do NOT be lazy and skip on the testing step! Ever.)
What do I do if a plugin doesn’t send a test email?
First, you want to recheck your settings and try again. A single character out of place can cause a credential or API key failure. IF the plugin provides debugging or diagnostic information you can check that out too. Note that most SMTP plugins do not have an “on/off” switch – you need to deactivate the plugin. SO, remember to disable any other SMTP plugin that is not working as soon as possible so at least WordPress mails will go out again. If it doesn’t work first time you may wish to continue testing on a development copy of your site (on the same hosting) to prevent any email loss while you are working out how to fix it. You may want to try again with another plugin or a different credential method (ie. API or User/Pass settings.) Of course, again make sure you only have only one SMPTP plugin active at a time so they don’t conflict.
Sidenote: It is also a good idea if you have sending problems to check with your hosting as to whether you are behind a server Firewall, as this can be blocking the outgoing port your hosting account needs to connect to the email server through! This has happened to me a few times. (It is less likely on a VPS or managed hosting than shared hosting but still a possibility.) Test a different port first if you can or contact your hosting provider to make sure if you are having difficulties with this (or check your Firewall settings yourself if you have access to them.)
Which SMTP plugin should I use for WordPress?
I recently tested about half a dozen SMTP plugins – just because I couldn’t get a test email to send at all, despite having set this up many times before. It turned out that in this case my hosting did have a firewall on the port that I needed, and it worked fine when they whitelisted the port for the account/domain. So any of the other plugins I tried probably would have worked too. But then, if that didn’t happen you probably wouldn’t be reading this guide made from my testing notes – so that if you’re having troubles, you can use the best plugin from the outset instead of spending a few hours finding and testing them all like me. 🙂
The result is this little guide. You can see the other alternatives below, but the clear winner at this stage has to be… *drumroll*
Post SMTP Mailer and Email Log (update: previously called “Postman”)
Apart from having great email testing and logging features already integrated, it has many other features that make it stand out from the rest, especially including API support for Gmail, SendGrid, and Mandrill. With OAuth and HTTPS mailing fallbacks using Zend_Mail rather than PHP Mailer. Truly nex levl stuff…
- OAuth 2.0 Support (going a step above and beyond)
- Setup Wizard (nooby friendly)
- Test Emails with instant accurate results (awesome)
- Connectivity Test (wow this works really well)
- Additional Recipients (CC or BCC) (great for devs!)
- Network Timeout Settings (yay!)
- Logging Levels (big thankyou!)
Update: now includes an SMTP fallback for when primary delivery method fails (as suggested by yours truly.)
Check out Post SMTP Mailer and Email Log on WordPress.org.
Can you give me some sample SMTP settings?
Finding your API Key or User/Pass/Port credentials to use with the SMTP is usually the only tricky part of this process, as account interfaces tend to get rearranged over time in my experience (which can be pretty annoying!) So while I could give you a visual guide for each service here, I honestly wouldn’t have time to keep it up to date. Instead you may have to do a Google search if it is not immediately obvious where to get your API or User/Pass/Port Credentials for a particular service (again keeping in mind how up to date the directions you find may be.) Or if you are feeling lucky, just explore the mailing service account area until you find where they are… trusting that it will be there somewhere. 😀
SMTP Server: smtp.mandrillapp.com
Use Authentication: Plain
Password: <Any API Key>
What other SMTP Plugins can I use?
Most of the other SMTP plugins for WordPress are fairly on par in what they do – they give you a SMTP setting screens and the ability to send a test email. And (maybe) return some debug results on how that went. which generally means they either work or they don’t. But since that could be the difference between 5 minutes becomes 3 hours… I think it’s better to use a plugin with in-built diagnostics from the outset, don’t you?
The runner up here is WP Mail SMTP. Simply because it returns the full test email debug dump information onscreen straight away and that can help you get things fixed – not that it is all that readable or understandable but it is there! Believe it or not most of the other plugins didn’t do this. Configure SMTP is another good plugin that is very widely used and been around for awhile now, so another good alternative.
Anything else I should know?
Yes! If you don’t already, probably the most important thing you need to know that formatting emails is different to formatting websites! This is because mail clients (whether programs or webmail for the user reading the mail) are far more limited in what they support and process for display from the email body. Basically this means that to format an email “properly” (in HTML rather than plain text) can be likened to writing an early-internet website with simple HTML – most likely using <table> formatting no wider than 600px (though 800px max is also used these days.) CSS styling support is available in emails but compared to web design is very limited – and must be coded inline not via stylesheets. And background images, margins(!) and float clears are not reliably supported either! Plus the way images can be delivered and used is different too (more on that one in the next question.) There are also a few workarounds needed to avoid display bugs in different email clients… yes this could – and probably will be – an entire guide in itself, so for now here are some existing resources to avoid the major pitfalls:
HTML Email Resources
- Rock Solid Email Tips
- Creating a Simple Responsive HTML Email
- Creating a Future Proof Responsive Email without Media Queries
- Responsive Email Templates from Zurb
- Email Client CSS Support Table
- Litmus (premium email client testing service
- HTML5 Video in Emails (bonus find!)
What about Images in Emails?
The first thing you need to use only JPG or GIF formats as some email clients do not support PNGs! Yeesh. But the main problem with email images is that the majority of clients actually BLOCK directly referenced image location URLs for security purposes. (This is basically to prevent spammers from getting your computer’s IP address if you download an image from their server.) The result of that is really ugly emails with broken image placeholders where your <img> tags are instead of your beautifully formatted email copy. Ouch!
The only feasible workaround for this is to actually attach the images used in the email to the email itself and reference them appropriately in the email HTML. This might seem like a pain – and it kinda is – but unfortunately there is no other reliable solution (eg. using the “data:” method for images is blocked in Gmail so that one is out.) The reliable way is done by using the “cid” method in the image tag’s source attribute.
eg: <img src=”cid:0″> (where ‘0’ is the index ID of the image attachment.)
I first came across this problem when using my WP Infinity Responder plugin and solved it then (using the cid attachment method), but have since extracted the code user to make a little extra plugin to work for all other WordPress-sent emails too.