Hi folks and bots, this time I will show you how to configure posftix to authenticate with a external smtp server.
First, packages:
Remove exim and sendmail:
~# apt-get remove exim4
~# apt-get remove sendmail
Install postfix and cyrus-sasl
~# apt-get install postfix libgsasl7 libsasl2-2 libsasl2-modules chkconfig
Backup your main.cf
~# if [ -f /etc/postfix/main.cf ]; then cp -v /etc/postfix/main.cf /etc/postfix/main.cf.backup; fi
Dowload this main.cf or copy to your main.cf file:
~#vim /etc/postfix/main.cf
mydomain = local.domain
myhostname = host.local.domain
relayhost = yourisp.smtp.servername:25
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = smtpd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_type = cyrus
smtp_sasl_auth_enable = yes
smtp_cname_overrides_servername = no
smtp_sasl_security_options = noanonymous
Edit things like your domain and your smtp server and port.
Now, the auth:
~# vim /etc/postfix/sasl_passwd and insert this line (changing your data of course):
yourisp.smtp.servername:25 username:password
Then, postfix config:
~# postmap hash:/etc/postfix/sasl_passwd
~# postmap -q yourisp.smtp.servername:25 /etc/postfix/sasl_passwd
~# rm -rf /etc/postfix/sasl_passwd
~# chkconfig --add postfix
~# /etc/init.d/postfix start
Now, we need to test the mail:
~# sendmail email@example.com
Hello World!
.
Don’t forget that dot! It’s marking the end of the email.
That’s all, now you can send emails properly.
You can check the log if you have any problems:
~# tail -f /var/log/mail.log
Regards





