Postfix with relayhost and SASL client

This configuration was tested on Debian Linux Etch but should work on every system where Postfix can run.

This is a tipical situation when I have a personal mail server at home and I want to use it for sending email. This situation is a classic also in small office when there is a dynamic IP for the internet connection and often this IP is listed in more than one black list.

To enable SASL client in Postfix is really simple and can be done only add three line to the main.cf config file.

It is assumed that we have a running and well configured mail server

First of all we have to create the file that contain the SASL domain, user and password.

echo "mailrelay.tld         username:password" > /etc/postfix/sasl/sasl_passwd
chown root:root /etc/postfix/sasl/sasl_passwd && chmod 600 /etc/postfix/sasl/sasl_passwd
postmap /etc/postfix/sasl/sasl_passwd

now we should have two new files in the SASL directory

# ls -l /etc/postfix/sasl/
total 16
-rw------- 1 root root    82 2007-06-10 15:31 sasl_passwd
-rw------- 1 root root 12288 2007-06-10 15:31 sasl_passwd.db

the two next and last step is to edit main.cf and restart postfix:

cd /etc/postfix
vi main.cf

add the following lines to the opened file:

# SASL Section
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_type = cyrus
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = !gssapi, !external, static:all

don't forget to set the relayhost, always in main.cf

relayhost = mailrelay.tld

now you can restart your postfix server

postfix reload

or

/etc/init.d/postfix restart

or

/etc/rc.d/rc.postfix restart

or .... depending on your distro

and test the system sending an email through your new relay host

mail -s "Hello World" myemail@address.tld

That's all. I hope it help you. In case of problems see the next section for a first help.

Troubleshooting

If in your log you see something like:

Jun 10 15:01:31 bufera postfix/smtp[5834]: 16AEE40028: to=<abcd@domain.tld>, relay=mailrelay.tld[192.168.111.22]:25, delay=2.3, delays=0.15/0.16/2/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server mailrelay.tld[192.168.111.22]: no mechanism available)

is possible that you don't have the "libsasl2-modules" installed. If you run GNU/Linux Debian install this library with:

apt-get install libsasl2-modules

to avoid the problem.

If after doing that, you still don't have a functional system try to check where the file `libsasl2.so.2.0.22` is and where postfix searches for it.

If the problem persist check the log again, probably you need other libs. Remember that the log files is your best friend to check the system, then look at the links in the "external references" section.

External references

 
postfix_relayhost_sasl_client.txt · Last modified: 2007/06/11 04:43 by lorenzo
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki