Setting up Postfix with Gmail SMTP on Raspbian

Tags: Postfix, Raspbian, Linux, SMTP
Last update: Dec 2018

First we need to install packages:

sudo apt-get install postfix

Configuring Postfix:
– choose “satellite system”
– system mail name = computername

Edit Postfix config file:

sudo nano /etc/postfix/

and add the following:

#smtp_use_tls = yes #needed on ubuntu
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
smtp_tls_security_level = may

Providing authentication details by editing this file:

sudo nano /etc/postfix/sasl_password

and adding:


Secure the file with:

sudo chmod 600 /etc/postfix/sasl_password

and generate the database for it:

sudo postmap hash:/etc/postfix/sasl_password

Restarting Postfix and sending a test mail:

sudo service postfix restart
echo "test" | mailx -s "test"

You can also send a mail with attachment using mpack:

mpack -d yourmessagebody.txt -s "subject" file
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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