Configure SMTP AUTH for mail servers

Create a text file as follows:
# P=/etc/postfix/password
# vi $P

The format of the client password file is as follows:

#smtp.isp.com       username:password
smtp.vsnl.in         [email protected]:mySecretePassword

Save and close the file. Set permissions:
# chown root:root $P
# chmod 0600 $P
# postmap hash:$P

Enable SMTP AUTH

Open main.cf file, enter:
# vi /etc/postfix/main.cf
Append following config directives:

 relayhost = smtp.vsnl.in
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/password
smtp_sasl_security_options =

Where,

  • relayhost = smtp.vsnl.in : Rely all mail via smtp.vsnl.in ISP mail server.
  • smtp_sasl_auth_enable = yes : Cyrus-SASL support for authentication of mail servers.
  • smtp_sasl_password_maps = hash:/etc/postfix/password : Set path to sasl_passwd.
  • smtp_sasl_security_options = : Finally, allow Postfix to use anonymous and plaintext authentication by leaving it empty.

Save and close the file. Restart Postfix:
# /etc/init.d/postfix reload
Test your setup by sending a text email:
$ echo 'This is a test.' > /tmp/test
$ mail -s 'Test' [email protected]