Configuring postfix with Gmail

Posted on

Configuring postfix with Gmail – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ubuntu, email, postfix, .

This is what I did..

sudo apt-get install postfix

This is my /etc/postfix/

# See /usr/share/postfix/ for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

myhostname =

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

myorigin = /etc/mailname
mydestination =
relayhost = []:587
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
default_transport = smtp
relay_transport = smtp
inet_protocols = all

# SASL Settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem

Then I created the file /etc/mailname with my hostname as content:

Then I created the file /etc/postfix/sasl_passwd:


Then sudo postmap /etc/postfix/sasl/passwd

sudo cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

service postfix restart

Still sends nothing… I’m on Ubuntu Server 12.04.

Solution :

Consult your /var/log/mail.log for details.

Your config seems to be correct and actually works as for satellite site config for postfix on Ubuntu 12.04.

It’s not really a one-liner to configure postfix for gmail, so I made a configuration script that does the whole process automatically. The script will ask you for your gmail username and password, and configure everything else automatically.

Check it out here.

I suggest you to purge (delete) all existing postfix configuration before running the script.
You can do this by running:

sudo apt-get purge -y postfix

Leave a Reply

Your email address will not be published. Required fields are marked *