Thursday, 26 September 2013

Postfix: релей через EXIM с шифрованием и авторизацией


Имеется:
- свежеустановленный centos 6.4 и нетронутый postfix на нем,
- почтовый сервер (mail.example.ru) с настроенным exim с авторизацией через TLS-сессию.

Нужно научить postfix отправлять письма через exim, удостоверяя себя логином/паролем, передаваемым только в зашифрованном виде через TLS-соединение.

Настраиваем /etc/postfix/main.cf:

/usr/sbin/postconf -e 'smtp_sasl_type = cyrus'
/usr/sbin/postconf -e 'smtp_sasl_security_options = noanonymous, noplaintext'
/usr/sbin/postconf -e 'smtp_sasl_tls_security_options = noanonymous'
/usr/sbin/postconf -e 'smtp_sasl_mechanism_filter = plain, login'

/usr/sbin/postconf -e 'relayhost = [mail.example.ru]:587'
/usr/sbin/postconf -e 'smtp_sasl_auth_enable = yes'
/usr/sbin/postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd'
/usr/sbin/postconf -e 'smtp_tls_security_level = encrypt'

пишем логин/пароль в /etc/postfix/sasl_passwd:
echo -e '[mail.example.ru]:587 \t username@example.ru:yourpassword' > /etc/postfix/sasl_passwd
chown root.root /etc/postfix/sasl_passwd
chmod 640 /etc/postfix/sasl_passwd
postmap hash:/etc/postfix/sasl_passwd

service postfix restart

P.S. Если вы видете в логах postfix'а строку
(SASL authentication failed; cannot authenticate to server no mechanism available)
значит нужно доставить пакет cyrus-sasl-plain:

yum install cyrus-sasl-plain

No comments:

Post a Comment