How to set up postfix on nginx server to allow WP send emails through aka ( via SMTP with TLS auth?

Hi there. Sorry for the noob question, but I’m pretty new on managing a vps and It seems DO community lacks a few articles regarding setting up an email server properly.

I running a 1GB VPS powered by Ubuntu 12.04 and I successfully installed a LEMP Stack (nginx, php5-fpm, mysql and Wordpress), so everything was running smoothly and working 100% (performance, W3 total cache etc.), my website was scoring 80/100 on Google PageSpeed, CPU consume was low and stable, however, as soon as I started configuring Ubuntu to allow PHP/Wordpress to send emails (let’s say contact form 7 submissions, wp email notifications), then my nightmares began.

Since my Droplet was created, I got DNS records properly configured to allow my domain respond on servers, this means that I’m able to login to my email accounts by typing and then I’m redirected to site so that I can login with and have complete access to my mailbox, send/receive emails etc.

While I was on my old shared hosting I used to rely on the same configuration, however, my wordpress site was able to send emails through PHP mail( ) function as also with the help of a plugin “WP Mail SMTP”, which can be configured to send emails via SMPT with TLS authentication.

Then I started reading the articles available here on DO about postfix, Exim, Sendmail, “SMTP as relay for Gmail and Hotmail on postfix” etc., but even after following these tutorials strictly I couldn’t enable php/wordpress to send emails on my server.

I don’t need a full email server running on my VPS, I just want my web applications to be able to send emails through a account with TLS authentication.

I’ve taken a snapshot of my droplet on its stable stage (LEMP + Wordpress fully working) and everything email related untouched, and since I’ve messed a lot with postfix, Exim and sendmail I had to rebuild my droplet from the snapshot so that I could proceed on my attempts to get email working again.

Has anyone configured Ubuntu or other Linux distro properly to enable php/wordpress to send emails through a third party service such as gmail or hotmail?

I really need this to work because this is the only thing compromising the development environment I’m trying to set up on my VPS.

Thanks in advance for your help.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

The easiest solution would be sending mail straight from the droplet and not through Outlook (i.e. through the mail() function). <br> <br>You can do that by installing an MTA such as postfix: <br><pre>DEBIAN_FRONTEND=noninteractive sudo apt-get install postfix</pre>Then edit Postfix’s config to listen on the loopback interface only: <a href=“”></a>. <br> <br>Once you’ve done that, try sending emails using the php mail() function, does it work?

Sounds like you I had a nightmare of a time setting up emails to work. I’ve been at it for almost 3 days on just this issue. Finally got it to work following this tutorial: <br> <br> <br> <br>My personal setup: <br> <br>Configured MX records for microsoft Outlook which I’ve been incredibly impressed with. I’m talking about the web version which used to be hotmail. So far it seems to be a cleaner email system than gmail or yahoo and you can set it up with your own domain name for free unlike gmail which charges you $50/year for their google apps version. You’ll need to google search this though. <br> <br>Then wait until the MX records on digital ocean are all set (up to 24 hours) and go activate your Outlook mail with your domain instead of <br> <br>Once I could send/recieve emails from this, I just had to follow the tutorial at the above link. <br> <br>I did not have to install postfix or anything else on my server for this to work.

Hi. Thanks for your reply. While researching I’ve come across this article, but bypassed it giving the fact I was a bit lost with all available (not so promising) options. <br> <br>Could you please tell me if this set up would work if I had a few virtual hosts running wordpress (currently 3 light traffic wordpress web sites) and each one has its own domain? <br> <br>I don’t want to mess up everything again and then have to rebuild my Droplet one more time. Although I understand everyone has a specific usage/demand regarding sending emails from the server or through a relay configuration, It would be great if postfix, sendmail or any other stable MTA came pre-configured for the most common usages on DO Droplets. <br> <br>Again, thanks for your help. I’ll try this solution and research about it a bit more, but a few weeks ago I had never touched terminal on mac/linux before, and now I’m running a high performance server with ubuntu, nginx, wordpress and a few caching techniques, and compared to my old shared hosting, my web sites are blazing fast. <br> <br>While trying to manage for the first time ever my own VPS, I’ve gained a lot experience, as also I’ve learnt a couple new interesting things etc., however, my lack of “sysadmin” knowledge is leading me on spending too much time on research, trial and error and this is compromising my production. <br> <br>I’m starting to think that maybe I haven’t made the right choice, and now I’m seriously considering moving on to a managed WP hosting such as WP Engine. So sad :(