Relay SMTP usually used by mail server with dynamic IP address. In this guide, I will show how to setup relay SMTP on Postfix.
- Postfix installed on Ubuntu
- SMTP server (you can use ISP’s SMTP)
- email address and password to login to SMTP server
- Create password map file
$ sudo nano /etc/postfix/sasl_passwd
Type in your SMTP server, username (email address), and password into the file:
- Set permission to password map file, so it cannot be read by other user.
$ sudo chown root:root /etc/postfix/sasl_passwd
$ sudo chmod 600 /etc/postfix/sasl_passwd
- Create hash from map file (remember to do it each time you change your map file):
$ postmap /etc/postfix/sasl_passwd
- Edit Postfix config file
$ sudo nano /etc/postfix/main.cf
And make sure the following lines are exist.
relayhost = smtp.colekcolek.com
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
If your ISP blocks outgoing port 25, you can choose to use alternative ports by modifying this line:
relayhost = [smtp.colekcolek.com]:26
- Restart Postfix
$ sudo /etc/init.d/postfix restart