手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux下邮件服务Postfix的搭建

[日期:2012-07-09] 来源:Linux社区  作者:leejia [字体:大 中 小]
七、为postfix开启基于cyrus-sasl的认证功能
 
使用以下命令验正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"
& linux
相关资讯       Postfix 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款