Email issues - I'm a bit confused

June 5, 2014 2.8k views
Hello all :) I've set up a WordPress site on my droplet (LAMP, Ubuntu 12.04). I'm also using google apps to handle my email. I have my DNS set up to use gmail, as well. the problem is with the WordPress site. I've set up Postfix (and followed this tutorial to relay gmail: and PHP mail (msmtp) and they *seem* to be working - especially the PHP mail. All of the tests are coming through just fine. However, I have my google apps email address set as the admin in my WordPress environment, and I have a contact form that's set to send notifications to that address. I also have the form (uses Gravity Forms) to email a copy of the filled-out form to whatever end user filled it out. None of those emails are coming through anywhere. It's like WordPress isn't connected to any sort of mail setup at all. I tried using a WordPress SMTP plugin, but that also fails with a message: SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0) There's a few of my tests that are showing up in my /var/mail folder, but it appears they are postfix error messages - they all say the"user" doesn't exist (but I set one up, so it *should* be there). here's one of the messages, if it helps: Diagnostic-Code: X-Postfix; unknown user: "shelly" So I'm kinda stumped as to what I'm doing wrong here. In all honesty, I don't want to use my droplet for mail at all, I just want to have Gmail/Google Apps handle it completely. If anyone could point me to whatever I'm doing wrong/missing, I'd really appreciate it.
7 Answers
My suggestion bypasses postfix completely why not use a Wordpress SMTP plugin with a gmail account you create solely for notifications from your site?
Check postfix's error logs:
tail -30 /var/log/mail.log

tail -30 /var/log/mail.err

Do you see any errors in there?
The error it self is clean enough: "Failed to connect to server".
Now, what that means? Your server couldn't resolve the provided address name. So the question is: why does it work locally? Because your machine knows itself.

A working DNS service is a must to properly do name conversion of provided addresses.
Crazy. I guess I'm just impatient! The SMTP plugin is now working just fine. (I'll also note that a few hours after I sent the test emails, several of them popped through to my inbox.)

I guess all I had to do was give it a couple of hours.

Thanks for the suggestions, I appreciate it :)
...and impatience again, I guess. It worked the one time, and now it's no longer working again. I guess I'll keep plugging away at it.
For the record, the errors in the log files were "unknown user", even though the user is definitely there. @Alexandre, the "failed to connect to server" was a message from the SMTP plugin, not the error logs. My DNS is fine. I can even send test emails from the command line and they come through - it's just via WordPress that they don't.

I apologize for not coming back to this until now. david294611's answer was what I did - and it's working great.

I'm getting ready to add in 2-factor authentication to be sure it still works with that, but so far, I haven't needed anything but gmail and the SMTP plugin (I'm using this one, if it helps anyone in the future: and all is working perfectly well. Exactly what I wanted.

Have another answer? Share your knowledge.