使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的:
# /usr/sbin/postconf -a
cyrus
dovecot
编辑postfix配置文件:
#vim /etc/postfix/main.cf
添加以下内容:
############################CYRUS-SASL############################
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
# vim /usr/lib/sasl2/smtpd.conf
添加如下内容:
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
让postfix重新启动:
#service postfix restart
发邮件测试:
[root@mail ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 Welcome to our mail.linuxidc.com ESMTP,Warning: Version not Available!
ehlo mail.linuxidc.com
250-mail.linuxidc.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN 出现这两行则成功
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
这时候只有通过如下认证后,才能使用postfix发送邮件:
把我们的系统用户lee和其密码用base64编码:(用户lee的密码为RedHat)
[root@mail ~]# echo -n "lee" | openssl base64
bGVl
[lee@mail ~]$ echo -n "redhat" | openssl base64
cmVkaGF0
测试:
[root@mail ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 Welcome to our mail.linuxidc.com ESMTP,Warning: Version not Available!
auth login
334 VXNlcm5hbWU6
bGVl
334 UGFzc3dvcmQ6
cmVkaGF0
235 2.7.0 Authentication successful
mail from:root@126.com
250 2.1.0 Ok
rcpt to:lee@linuxidc.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject:hello
s;ldkfj;ds
.
250 2.0.0 Ok: queued as 30DFF5D3C53
quit
221 2.0.0 Bye
如果你先前定义的有别名,则发给lee用户的邮件被root接收:
[root@mail ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@126.com Sun Mar 18 12:25 14/463 "hello"
&
