How can I ensure that emails generated by the server/Wordpress don't end up in spam?

May 23, 2017 552 views
WordPress Apache Email Ubuntu 16.04

I'm not trying to run my own mail server, so email for this domain is hosted elsewhere. But, of course, Wordpress needs to send email (woocommerce orders, password reset notifications, contact forms etc) from the domain. Human to human email is fine, but any emails from the website itself go directly to spam. I have mx records and an spf record that I got from the email host. I have edited the spf record with the addition of include:mydomainexample.com, (in addition to the originalinclude:exampleemailhost.com) but I'm not sure that's the correct domain with my setup?

It seems like maybe I need to install Postfix to properly send email from my own server. I'm prepared to follow this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-16-04

However, it seems like this tutorial is aimed at users who have one domain per droplet? I use the LAMP stack and have multiple virtual hosts. Is there different steps involved if I wanted to properly configure sending email from each domain I have associated with my droplet?

1 Answer
jtittle1 May 23, 2017
Accepted Answer

@kelseybarmettler

The issue is that by default, WordPress uses PHP's mail() function and nothing more. Mail sent using this function is inevitably going to end up in spam/junk due to the fact that there's no authorization.

It's simple to create a function that runs mail() through a loop and sends 10k-100k e-mails in a very short period of time complete with random messages and e-mails. Since there's no authorization to an e-mail server, via SMTP or API, the mail comes through from whatever the hostname of the VPS or Droplet happens to be and gets flagged (as it should).

What I recommend using using a transactional e-mail provider, such as SparkPost. The service is free up to 100k e-mails per month, and it's one that I recommend to most that I work with who need e-mail but don't want to manage their own mail server.

https://www.sparkpost.com/

There's a WordPress plugin to help in connecting as well.

https://wordpress.org/plugins/sparkpost/

...

Of course, there are others: Mandrill, MailGun, and SendGrid, just to name a few.

https://www.mandrill.com/pricing/

https://sendgrid.com/pricing/

https://www.mailgun.com/pricing

  • Thanks, that really opened my eyes– I knew that Wordpress sent email through the php mail function but I didn't know there was an alternative! It looks like sparkpost will solve this issue for all of the simple email needs I have for my multiple domains. Much appreciated!

    • @kelseybarmettler

      No problem at all :-). I normally recommend G Suite for e-mail and those providers for just about everything else. It keeps things easy, plus, managing an actual mail server is a major pain and there's a lot to handle and maintain. Even as a sysadmin, I try to avoid it :-).

      • I completely agree and plan to avoid it completely. Nothing makes me feel dumber than email delivery issues lol. Thanks

Have another answer? Share your knowledge.