Installing Postfix
apt-get install postfix -y
In deb-installer choose no configuration
Configuring postfix
cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
Edit /etc/postfix/main.cf file & insert following lines with your favourite editor
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = vidyadhar.home.network
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/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_use_tls=yes
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
Define Username and Password
Next we’ll need to define the sasl_passwd file. Create the file /etc/postfix/sasl_passwd with following lines
[smtp.gmail.com]:587 gmail_username@gmail.com:gmail_password
Securing file
chmod 400 /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd
Using & validating CA certificate
touch /etc/postfix/cacert.pem cat /etc/ssl/certs/Equifax_Secure_CA.pem >> /etc/postfix/cacert.pem
Applying changes for postfix
/etc/init.d/postfix restart
Related content:
Thanks, that was very helpful. I’ve had issues with getting this to work before but your instructions worked perfectly.
Same as Darren!
Thanks a lot! I tried a lot of solutions but none of them worked for me! This effectively worked for me!
this doesnt work, at least anymore. Gmail will not accept the cert
Missing a step before
# postmap /etc/postfix/sasl_passwd
- postmap will error out if you don’t make sure you have an /etc/mailname file containing your “fully qualified domain name”, e.g.
# echo “myfully.qualifieddomain.name” > /etc/mailname
Also, it’d be nice to finish off with a test to confirm it works, like
# apt-get install mailutils
# echo “We rolling, yo” | mail -s “Check it out, homes” some@emailrecipient.com
Other than that, thanks!
Much quicker than the previous guide I used.
This is one of the easiest step by step tutorial. Thanks for sharing.
VERY IMPORTANT: Pay attention to the beginning of this blog.
And read about the missing step in the above comment (Daniel Smedegaard Buus).
Use no configuration – this way you can have a very basic set up.
Make adjustment to myhostname = vidyadhar.home.network use your own details.
If it does not work.
sudo apt-get purge postfix
sudo apt-get install postfix
Then try again it will work.
This may help – since google changed their CA to Equifax
sudo cat /etc/ssl/certs/Equifax_Secure_CA.pem >> sudo /etc/postfix/cacert.pem