Configure Postfix For Relaying
To configure our Postfix server for relaying emails through smtp.example.com, we run :
# postconf -e 'relayhost = smtp.example.com'
# postconf -e 'smtp_sasl_auth_enable = yes'
# postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
# postconf -e 'smtp_sasl_security_options ='
Our username (nagios) and password (password) for smtp.example.com must be stored in /etc/postfix/sasl_passwd, therefore we do this:
# echo "smtp.example.com nagios:password" > /etc/postfix/sasl_passwd
/etc/postfix/sasl_passwd must be owned by root, and none else should have read access to that file, so we do this:
# chown root:root /etc/postfix/sasl_passwd
# chmod 600 /etc/postfix/sasl_passwd
Now we must convert /etc/postfix/sasl_passwd into a format that Postfix can read:
# postmap /etc/postfix/sasl_passwd
This will create the file /etc/postfix/sasl_passwd.db.
# echo "smtp.example.com " > /etc/postfix/sasl_passwd
Change name from :
# echo "nagios nagios@exemple.com" > /etc/postfix/canonical
# echo "canonical_maps = hash:/etc/postfix/canonical" >> /etc/postfix/main.cf
Now we must convert /etc/postfix/canonical into a format that Postfix can read:
# postmap /etc/postfix/canonical
All that is left to do is restart Postfix:
#/etc/init.d/postfix restart