Baadier
By:
Baadier

WordPress sends all mail from root@localhost using wp_mail()

January 30, 2017 740 views
WordPress Nginx Email Ubuntu 16.04

I have a Digital Ocean droplet that was configured using the Laravel Forge build scripts.

It comes with LEMP stack setup.

All my emails from a WordPress site I have set up are sending out via root@localhost and consequently been rejected.

Sending via SMTP or the SparkPost API doesnt help nor does changing the email sender in functions.php or using a plugin to change it help.

FML I've been stuck on this for a few days already.

Any ideas?

4 Answers

@Baadier

Are you using a WordPress plugin to integrate with a third-party solution, such as WP Mail SMTP?

https://wordpress.org/plugins/wp-mail-smtp/

By default, WordPress relies on PHP's built-in mail() function which, without a valid and working mail server, will ultimately result in e-mails sent from WordPress landing in the SPAM/Junk folder. You can get around this by using a plugin, such as the one referenced about, that will allow you to integrate with third-party solutions such as Google Gmail, Mailgun, SendGrid, and others.

I've used this plugin in the past and it's always worked without any issues, so long as the connection details that are provided to it are correct.

@jtittle

I tried using WP Mail SMTP and using SparkPost which is what I'm using but nothing seems to stop WordPress from using root@locahost as the sender address.

Because the sender address fails validation the mail gets rejected by wp_mail()

@Baadier

I'd recommend checking this plugin out:

https://wordpress.org/plugins/cb-change-mail-sender/

That plugin should help you to get around the default name and e-mail used by WordPress without having to actually implement the code yourself.

@jtittle

Hmm I dont think that will work as I've implemented an alternate but similar plugin and added the necessary filters to functions.php to over ride the sender and it still doesnt work.

Have another answer? Share your knowledge.