Linode postfix guide for Gmail
How to rewrite outgoing address in Postfix
- ourserver.rules.com - for the server we are configuring. FQDN
- [email protected] - for our e-mail address.
- mail.awesomedomain.com - for our SMTP server.
- uLtraSecret#$@PassWord - for SMTP password.
Change the priority of asked question during the installation of packages. In the third dialog change priority to low.
sudo dpkg-reconfigure debconf
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install libsasl2-modules postfix
- In the first dialog select Internet Site
- In the second dialog write our server hostname: ourserver.rules.com
- In the third dialog don't change anything.
- In the fourth dialog we can enter our email address ([email protected]), but it is not mandatory.
- In the next 4-5 dialogs don't change anything.
sudo vim /etc/aliases
# See man 5 aliases for format
postmaster: root
root: [email protected]
sudo newaliases
sudo chfn -f 'root at ourserver.rules.com' root
sudo vim /etc/postfix/main.cf
- Change the row which contains
myhostname =
tomyhostname = ourserver.rules.com
- Change the row which contains
relayhost =
torelayhost = [mail.awesomedomain.com]:587
- Optionally change
inet_interfaces
toinet_interfaces = 127.0.0.1
to use postfix only localy. - Optionally change
inet_protocols
toinet_protocols = ipv4
. - At the end of the file append the following:
#Rewrite the sender of every mail
smtp_generic_maps = hash:/etc/postfix/generic
# Enable SASL authentication
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption
smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
- Save and exit
sudo vim /etc/postfix/sasl/sasl_passwd
Set the contents in the following format:
[mail.awesomedomain.com]:587 [email protected]:uLtraSecret#$@PassWord
Create the hash db file for Postfix by running the postmap
command:
sudo postmap /etc/postfix/sasl/sasl_passwd
Protect the files:
sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
sudo vim /etc/postfix/generic
Set the contents in the following format:
@rules.com [email protected]
Generate the Postfix DB file.
sudo postmap /etc/postfix/generic
sudo systemctl restart postfix
sendmail root
From: [email protected]
Subject: test
Testing postfix
.