Reduce the risk of email rejection by making WordPress send emails via SMTP if DKIM is configured

Originally published on the Bytemark forum

I recently migrated yet another WordPress site from a Turnkey Linux install to join my others on Bytemark Symbiosis. As I’ve briefly mentioned elsewhere, this went without major problems.

I also decided to configure SPF and DKIM as part of my plan to finish migrating mail services over. However, I didn’t consider the fact that this has an impact on the deliverability of emails sent from WordPress and presumably other similar PHP-based web applications.

I’ve been using a catch-all forwarding rule and spotted a rejected email from Yahoo! Mail. The rejected email was a blog post that was shared by email using WordPress JetPack sharing. The rejection notice quoted 554 5.7.9: Message not accepted for policy reasons. The explanatory URL clarifies:

Your email failed one or more of the following industry-wide authentication checks that Yahoo uses to verify emails are truly sent from the domains they claim to originate from.

It goes on to briefly explain DKIM, SPF and DMARC (not currently implemented in Symbiosis).

Thankfully, this is a solvable problem – in fact, it’s not even really a problem, as Yahoo! Mail is just doing its job by checking for correct DKIM headers.

However, WordPress doesn’t make solving it obvious. Chad Butler has done a ton of investigation into WordPress’s email woes, pointing the finger at the wp_mail function – a “wrapper” for phpmailer. The solution is to force WordPress to use SMTP via phpmailer. Here are two suggested approaches:

  1. Edit your theme’s functions.php to include an extra code snippet that configures WordPress to use SMTP to send email.
  2. Use an extra plugin to bring this functionality to all themes and WordPress email functions. Chad recommends WP Mail SMTP which I’ve just deployed and tested briefly with WordPress 4.0.1 (this may useful for multi-site setups too).

With both approaches, there are some Symbiosis-specific things you should be aware of (I’ll use the standard Symbiosis examples here):

  • You need to create a mailbox first, if that isn’t obvious, e.g. blog.
  • The SMTP host is mail.my-brilliant-site.com (on default port 25).
  • The username must follow the example blog@my-brilliant-site.com. Obvious, perhaps, but I always forget this.
  • SMTP requires authentication.
  • I used TLS encryption successfully.

If you’ve tweaked your Symbiosis install to be non-standard, then you’ll have to reflect that here but otherwise it’s pretty much the same as setting up a mail client to send mail.

If you’re using the WP Mail SMTP plugin, then you can send a test email. I recommend trying to send it to a Gmail or Yahoo! Mail address. The result you’re looking for is bool(true) – in addition to the test email of course, which you can examine to ensure it includes the right DKIM-Signature header.

I hope this helps with any head-scratching you might have also been doing!

Developers: stop re-AOLizing the web!

No AOLI recently succumbed to the hype and downloaded Mailbox, a mobile email client that tries to help you manage your overflowing email inbox and achieve the mythical “inbox zero”.

Mailbox does this by encouraging you to immediately archive, trash or schedule the email for a re-read or response using a swipe interface. It’s pretty good, actually, and I’ve found myself with fewer new emails just sitting in my inbox waiting for me to do something with them. My older email archive is another matter.

There’s one major flaw however.

By using Mailbox, I’m effectively helping to re-AOLize the web. You see, Mailbox only supports two email providers: Gmail and Apple iCloud.

I find it incredible that an app developer working on an open, well-documented and well-understood platform like email has effectively closed down access to their product to users who are on just a couple of providers.

Don’t get me wrong: I know the problems are difficult, especially as open platforms beget a multitude of implementations.

But by choosing to lock yourself into the Google API, when there is another, really open way to do things, feels like a mistake to me. If Mailbox supported any standardised IMAP provider, they’d no doubt have access to a much wider user base who would use their app across multiple providers.

And they might even be able to charge for the app and make an income – rather than selling themselves to Dropbox to survive.

It doesn’t help that locking me even more to the Google ecosystem and all the threats to my privacy and freedom that brings with it. Dropbox is another cloud company with a questionable approach to customer’s privacy and freedom.

Google (and to a lesser extent) Apple, Facebook and Twitter, have little interest in allowing their products to inter-operate in a meaningful way. Let’s remember that this is exactly how much of the consumer internet worked in the late 80s and 90s: CompuServe only reluctantly added email to its internal messaging and AoL generally preferred to lock down users to its own walled-garden of content rather than having them access the web. Both these networks, once seen as pioneers are now effectively defunct.

When developers choose to lock-in to an ecosystem like Google, they also lock in users. And that’s when innovation dies: users’ choice is restricted, so they demand less (and alternatives don’t get developed). By using it myself, I’m helping depress demand for a good email client that works with multiple providers. That’s not a good thing because it means I’ll have less choice.

Despite email being an inherently tedious form of communication, it’s essential and here to stay. If developers want to play their part in improving email, then it’s not going to be by re-AOLizing the web and locking down to a single provider: it’s going to be by supporting open email platforms that enable a wide range of people to use your product.

As it stands, Mailbox has been a useful so far. But I know my own time with it is limited, as I continue to transition away from closed source, anti-privacy services like Gmail to self-hosted, free and open source alternatives.

And that will be a loss for the Mailbox developers.