Home   Profile   Fun
#164 Linux  01.09.2008

Configure Postfix as a relay client


I assume here a standard Postfix installation on Debian and I will show only additional lines in the configuration files. In the file /etc/postfix/main.cf add these lines which specify the relay server and tell Postfix to use SMTP AUTH.
myhostname = yourserver.domain
smtp_helo_name = yourserver.domain
relayhost = [smtp.servername.of.your.provider]
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_mechanism_filter = plain, login
smtp_sasl_security_options = noanonymous
sender_canonical_maps = hash:/etc/postfix/sender_canonical

For the next step the data of the e-mail account you want to use for relaying mails is needed. Create the file /etc/postfix/sasl_passwd and add a line which contains the smtp server name in square brackets, the user name and the password of your mail account you want to use.
[smtp.servername.of.your.provider]  username:password

Then create the hash map
postmap hash:/etc/postfix/sasl_passwd

GMX for example allows relaying only if the sender e-mail address is equivalent to the e-mail address of the relay account. Hence you have to rewrite the sender address. Open /etc/postfix/sender_canonical and add the following line.
localuser@yourserver.domain emailaddressofrelayaccount

Generate the map and restart Postfix
postmap hash:/etc/postfix/sender_canonical
postfix reload