Home » Cloud Computing » Postfix + Gmail: A Pain-Free SMTP Relay for Wazo PBX

The Most Versatile VoIP Provider: FREE PORTING

Postfix + Gmail: A Pain-Free SMTP Relay for Wazo PBX

Let’s face it. As the number of Internet service providers blocking downstream email servers continues to proliferate, getting a reliable email server configured with Incredible PBX™ and other VoIP servers has become painful. If you’re new to all of this, here’s the simple explanation. Internet providers such as Comcast intentionally block outbound email from mail servers managed by their residential customers. While it may appear arbitrary, there actually is a good reason. The bad guys quickly discovered that many folks setting up SendMail and Postfix servers didn’t much know what they were doing, and it became fairly easy to turn these servers into anonymous email relay hosts for spammers. The sledgehammer solution was to simply block all of these servers from sending outbound email except through Comcast’s SMTP servers. In the VoIP world, that meant you could no longer depend upon your server to notify you when critical services came unglued.

We previously have posted tutorials showing how to configure SendMail to send outbound emails using either your Gmail account or your Comcast account. There’s one major problem on the Wazo platform. It uses Postfix instead of SendMail. More importantly, you can’t replace the mail server without breaking Wazo.

Configuring Gmail as an SMTP Relay Host for Postfix

So here’s the step-by-step procedure to configure Wazo to use Gmail as your SMTP relay:

1. Log into your server as root and issue the following command:

dpkg-reconfigure postfix

Click OK on the first dialog. Choose Internet Site as your Type of Mail Configuration. Accept the defaults for the System Mail Name, Root and Postmaster Recipient, and Other Destinations. Choose Yes for Forced Synchronous updates. Accept the defaults for the Local Networks, Default Mailbox Size, and Local Address Extension Character. Choose IPv4 for the Internet Protocol.

2. Once Postfix is reconfigured, edit /etc/postfix/main.cf. In the second section of code beginning with relayhost =, replace it with the following block of commands:

relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_fallback_relay =

3. Install the following package: apt-get install libsasl2-modules

4. Create the following new file using your Gmail account name and password.

nano -w /etc/postfix/sasl_passwd:

[smtp.gmail.com]:587	yourname@gmail.com:yourpassword

5. Change the permissions on the sasl_passwd file:

chmod 600 /etc/postfix/sasl_passwd

6. Use postmap to compile and hash the sasl_passwd file:

postmap /etc/postfix/sasl_passwd

7. Restart Postfix: /etc/init.d/postfix restart

8. Send yourself a test email: echo "test" | mail -s "Test Mail" somebody@gmail.com

What Could Possibly Go Wrong?

In a perfect world, you’d be all set, and your emails would start arriving as scheduled. But things aren’t always that simple.

If you happen to be using a Gmail account with 2-Step Verification enabled, then your standard Gmail password obviously isn’t going to work. Instead, you’ll need to create an App Password for exclusive use with Postfix. Here’s how. Once you’ve generated the password, just substitute it for your standard Gmail password in step #4 above. Then recompile and hash the sasl_passwd file in step #6 and restart Postfix in step #7.

If your Gmail account was created from an IP address that differs from the IP address of your Wazo server, then you may also need to relax Google’s security mechanisms before attempting to send your first email in step #8. Login to your Gmail account and perform the Google Reset Procedure. Then enable Less Secure Apps using this Google tool. Now attempt to send yourself a test email as documented in step #8 above. Enjoy!

Published: Monday, May 29, 2017  


Support Issues. With any application as sophisticated as this one, you’re bound to have questions. Blog comments are a difficult place to address support issues although we welcome general comments about our articles and software. If you have particular support issues, we encourage you to get actively involved in the PBX in a Flash Forum. It’s the best Asterisk tech support site in the business, and it’s all free! Please have a look and post your support questions there. Unlike some forums, the PIAF Forum is extremely friendly and is supported by literally hundreds of Asterisk gurus and thousands of users just like you. You won’t have to wait long for an answer to your question.



Need help with Asterisk? Visit the PBX in a Flash Forum.


 

Special Thanks to Our Generous Sponsors


FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!
 

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.
 



Some Recent Nerd Vittles Articles of Interest…


1 Comment

  1. Totally agree, getting a reliable email server configured with Incredible PBX & other VoIP servers has become painful!

Comments are closed.