Chinaunix首页 | 论坛 | 博客
  • 博客访问: 377834
  • 博文数量: 114
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1219
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-07 21:23
文章分类

全部博文(114)

文章存档

2018年(1)

2017年(5)

2016年(87)

2015年(21)

我的朋友

分类: 系统运维

2016-01-16 16:55:01

1、安装cyrus-sasl
删除系统的cyrus-sasl:
shell
# rpm -e cyrus-sasl --nodeps
安装新的支持authdaemon的软件包
shell
# yum install cyrus-sasl
2、配置main.cf文件
Postfix的SMTP认证需要透过Cyrus-SASL,连接到authdaemon获取认证信息。
编辑main.cf
shell
# vi /etc/postfix/main.cf
增加如下内容:
  1. # smtpd related config
  2. smtpd_recipient_restrictions =
  3.         permit_mynetworks,
  4.         permit_sasl_authenticated,
  5.         reject_non_fqdn_hostname,
  6.         reject_non_fqdn_sender,
  7.         reject_non_fqdn_recipient,
  8.         reject_unauth_destination,
  9.         reject_unauth_pipelining,
  10.         reject_invalid_hostname,


  11. # SMTP sender login matching config
  12. smtpd_sender_restrictions =
  13.         permit_mynetworks,
  14.         reject_sender_login_mismatch,
  15.         reject_authenticated_sender_login_mismatch,
  16.         reject_unauthenticated_sender_login_mismatch


  17. smtpd_sender_login_maps =
  18.         mysql:/etc/postfix/mysql_virtual_sender_maps.cf,
  19.         mysql:/etc/postfix/mysql_virtual_alias_maps.cf
  20.   
  21. # SMTP AUTH config here
  22. broken_sasl_auth_clients = yes
  23. smtpd_sasl_auth_enable = yes
  24. smtpd_sasl_local_domain = $myhostname
  25. smtpd_sasl_security_options = noanonymous
3、编辑smtpd.conf文件
shell
# vi /usr/lib/sasl2/smtpd.conf
确保其内容为:
  1. pwcheck_method: authdaemond
  2. log_level: 3
  3. mech_list: PLAIN LOGIN
  4. authdaemond_path:/var/spool/authdaemon/socke
重新启动postfix:
shell
# service postfix start
4、测试SMTP认证
通过以下命令获得postmaster@extmail.org的用户名及密码的BASE64编码:
shell
# perl -e 'use MIME::Base64; print encode_base64("postmaster\@extmail.org")'
内容如下:
  1. cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
  2. shell
  3. # perl -e 'use MIME::Base64; print encode_base64("extmail")'
内容如下:

  1. ZXh0bWFpbA==
  2. 然后本机测试:
  3. shell
  4. # telnet localhost 25
  5. 其过程如下:
  6. Trying 127.0.0.1...
  7. Connected to localhost.localdomain (127.0.0.1).
  8. Escape character is '^]'.
  9. 220 mail.extmail.org ESMTP Postfix - by extmail.org
  10. ehlo demo.domain.tld << 输入内容
  11. 250-mail.extmail.org
  12. 250-PIPELINING
  13. 250-SIZE 10240000
  14. 250-VRFY
  15. 250-ETRN
  16. 250-AUTH LOGIN PLAIN
  17. 250-AUTH=LOGIN PLAIN
  18. 250-ENHANCEDSTATUSCODES
  19. 250-8BITMIME
  20. 250 DSN
  21. auth login << 输入内容
  22. 334 VXNlcm5hbWU6
  23. cG9zdG1hc3RlckBleHRtYWlsLm9yZw== << 输入内容
  24. 334 UGFzc3dvcmQ6
  25. ZXh0bWFpbA== << 输入内容
  26. 235 2.0.0 Authentication successful
  27. quit << 输入内容
  28. 221 2.0.0 Bye
最后出现235 Authentication Successful 表明认证成功了。

1、安装Courier-imap
默认的courier-authlib及courier-imap都会增加系统自启动设置,因此下一次服务器启动将自动启动相应的authlib及POP3服务
shell
# yum install courier-imap
配置courier-imap
由于Courier-imap的IMAP目录是按UTF-7编码的,ExtMail目前还没有正式支持IMAP目录,因此需要屏蔽IMAP,只提供pop3服务。而就目前的使用情况来看,IMAP使用的非常少,绝大部分OutLook/Foxmail用户都习惯使用POP3而非IMAP。
shell
# vi /usr/lib/courier-imap/etc/imapd
修改内容如下:
  1. IMAPDSTART=NO
  2. shell
  3. # vi /usr/lib/courier-imap/etc/imapd-ssl
修改内容如下:
IMAPDSSLSTART=NO 
然后重新启动courier-imap:
shell
# service courier-imap start
测试POP3 请按如下步骤输入pop3命令测试其是否正常工作,注意蓝色的信息是我们输入到POP3服务器的(请首先登录extman自行建立test@extmail.org用户,密码:extmail)
shell
# telnet localhost 110
其过程如下:

  1. Trying 127.0.0.1...
  2. Connected to localhost.localdomain (127.0.0.1).
  3. Escape character is '^]'.
  4. +OK Hello there.
  5. user test@extmail.org << 输入内容
  6. +OK Password required.
  7. pass extmail << 输入内容
  8. +OK logged in.
  9. list << 输入内容
  10. +OK POP3 clients that break here, they violate STD53.
  11. .
  12. quit << 输入内容
  13. +OK Bye-bye.
  14. Connection closed by foreign host.



阅读(999) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~