» Linux
Configure SMTP relay
This final step is optional and will be required only if you are going to use a webmail like Roundcube to access the emails stored in each user's account on the local server. If you are going to use an email client like Thunderbird/Outlook, you can continue using the email account's smtp server settings to send emails out. A webmail email client like Roundcube on the other hand, requires a SMTP relay if the users are going to send emails through it.
Log in as root to the local server and run the following command:
nano /etc/postfix/sasl_passwd
put the line below in that file. replace mail.yourdomain.com with your mail server hostname. Replace username:password with your email account's username and password to allow connection for SMTP
[mail.yourdomain.com]:587 username:password
Press CTRL + X and press y to save the file and exit from the editor.
Next, run the following command to generate a password db file that will be readable by the postfix mail transport agent.
postmap /etc/postfix/sasl_passwd
A password db file will be created at /etc/postfix/sasl_passwd.db . Secure that file using the commands below so that only the root user can access it.
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Configure postfix for SMTP relaying
Execute the following command so as to edit postfix's main configuration file:
nano /etc/postfix/main.cf
Put these lines in that file. replace mail.yourdomain.com with your mail server hostname. The relayhost line might already be in that file so find and edit it so that it looks like below.
relayhost = [mail.yourdomain.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
Press CTRL + X and press y to save the configuration file and exit the editor.
Finally, execute the command below to restart the postfix server.
service postfix restart
Now you can test the SMTP connection by sending an email through the Roundcube email client.