Postfix: Using Gmail as a Relay Host

Chris Kankiewicz
Jul 7, 2012 · 2 min read
Image for post
Image for post

I maintain several Linux servers at any given moment. Every server has postfix installed for sending emails, usually notifications or warning messages of some sort and most of these servers are professionally hosted allowing outbound emails with little to no configuration beyond installing postfix. However, my home server lies behind my ISP and they block all outbound emails citing SPAM as the reason. Regardless of their reasoning I had to find a workaround to allow me to send email notifications from behind my ISP. Well, it turns out this is rather painless with postfix and a Gmail account.

First, set up a Gmail account, note the user name and password for later.

Install postfix

Add the following to /etc/postfix/main.cnf

Create the file /etc/postfix/sasl_passwd and add the following:

Be sure to replace [username] and [password] with your account user name and password.

Modify file permissions and generate sasl_passwd.db

Restart postfix service

Send a test email

Replace [email_address] with your email address to receive a test message.

Chris Kankiewicz

Passionate PHP developer, Linux junkie, gamer and hacker.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store