#CentOS
yum update -y && yum upgrade -y
yum install postfix -y
#Debian / Ubuntu
apt update && apt upgrade -y
apt install postfix -y
Make sure the libsasl2-modules package is installed and up to date:
apt-get install libsasl2-modules -y
Once the installation is finished, open the /etc/postfix/main.cf
file with your favourite text editor:
nano /etc/postfix/main.cf
Check for the hostname. It should be your fqdn.nano /etc/postfix/main.cf
Open or create the /etc/postfix/sasl_passwd
file, using your favorite text editor:
nano /etc/postfix/sasl_passwd
Add your destination (SMTP Host), username, and password in the following format:
/etc/postfix/sasl_passwd
[mail.isp.example]:587 username:password
Create the hash db file for Postfix by running the postmap
command:
postmap /etc/postfix/sasl_passwd
If all went well, you should have a new file named sasl_passwd.db
in the /etc/postfix/
directory.
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Open the /etc/postfix/main.cf
file with your favorite text editor:
nano /etc/postfix/main.cf
Setup Relayhost
# specify SMTP relay host
relayhost = [mail.isp.example]:587
At the end of the file, add the following parameters to enable authentication:
# enable SASL authentication
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
To change the system user full name.. Please change the name here
/etc/passwd
root:x:0:0:System - Jetztrufen:/root:/bin/bash
To merge FROM Address into your define email ID.
In /etc/postfix/main.cf
add this line at the bottom.
smtp_generic_maps = hash:/etc/postfix/generic
And then in /etc/postfix/generic
. Add the line for the originating email address, and the email address you want it to appear to be from
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
and then run the following postmap command to re-generate the map:
postmap /etc/postfix/generic
At the end please remember to restart postfix.
service postfix restart