设为首页 收藏本站
查看: 2114|回复: 0

[经验分享] 邮件系统服务器搭建记录(二)(Postfix+Cyrus-sasl+Courier-authlib+Dovecot+ExtMail+MySQL)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-7 08:50:11 | 显示全部楼层 |阅读模式
5. 通过yum安装dovecot和配置dovecot
第4节中介绍了postfix的配置,并测试了postfix的发送邮件功能。你可以在服务器上使用mail命令来接受发送到本机域名用户邮箱中的邮件。但是你如果想使用MUA远程来接收邮件,那么则需要使用一个支持POP3/IMAP的服务来帮助MUA将邮箱中的邮件拉取到本地,比如dovecot。
1
[iyunv@mail ~]# yum install dovecot



编辑/etc/dovecot/dovecot.conf文件,修改以下行:
1
2
[iyunv@mail ~]# vi /etc/dovecot/dovecot.conf
protocols = pop3



如果想使用操作系统账号对收件人进行验证,则编辑/etc/dovecot/conf.d/10-auth.conf,修改以下行:
1
2
[iyunv@mail conf.d]# vi /etc/dovecot/conf.d/10-auth.conf
auth_mechanisms = plain login



如果需要远程使用MUA(如Outlook,Foxmail)来测试dovecot的收件功能,则需要配置/etc/dovecot/conf.d/10-auth.conf的如下行:
1
2
[iyunv@mail conf.d]# vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no



否则,用远程服务器登录到接收邮件服务器时,MUA会弹出如下错误:
1
登录到接收邮件服务器(POP3): 由于其他电子邮件正被传送到你的邮箱,或者其他邮件应用程序正在访问它,你的邮箱暂时不可用。  响应服务器: -ERR [IN-USE] Couldn't open INBOX: Internal error occurred. Refer to server log for more information. [2016-01-05 11:23:21]



同时还要注意/etc/dovecot/conf.d/10-mail.conf中mail_location所指的路径对应的权限问题,如果对于MUA所使用的用户没有权限访问或者修改该目录内容的话,在使用MUA登录到接收邮件服务器时,MUA也会弹出如下错误:
1
登录到接收邮件服务器(POP3): 由于其他电子邮件正被传送到你的邮箱,或者其他邮件应用程序正在访问它,你的邮箱暂时不可用。  响应服务器: -ERR [IN-USE] Couldn't open INBOX: Internal error occurred. Refer to server log for more information. [2016-01-05 11:23:21]



maillog中也会有如下错误打印:
1
2
3
4
[iyunv@mail ~]# tail -f /var/log/maillog
Jan  5 11:23:21 mail dovecot: pop3(mailtest): Error: mkdir(/home/mailtest/mail/.imap/INBOX) failed: Operation not permitted
Jan  5 11:23:21 mail dovecot: pop3(mailtest): Error: Couldn't open INBOX: Internal error occurred. Refer to server log for more information. [2016-01-05 11:23:21]
Jan  5 11:23:21 mail dovecot: pop3(mailtest): Couldn't open INBOX top=0/0, retr=0/0, del=0/0, size=0



配置完成后,启动dovecot,由于配置dovecot支持pop3协议,dovecot运行时将监听在110(pop3)和 995(pop3s)端口:
1
2
3
4
5
[iyunv@mail conf.d]# service dovecot start
Starting Dovecot Imap:                                     [  OK  ]
[iyunv@mail conf.d]# netstat -tunlp | grep dovecot
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      21883/dovecot      
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      21883/dovecot



使用telnet访问110端口以及通过openssl访问995端口来测试dovecot是否可以接收邮件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[iyunv@mail ~]# telnet 127.0.0.1 110
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
+OK Dovecot ready.
USER mailtest
+OK
PASS mailtest
+OK Logged in.
LIST
+OK 4 messages:
1 623
2 623
3 623
4 623.
RETR 1
+OK 623 octets
Return-Path: <mailtest@asika.com>
X-Original-To: mailtest@asika.com
Delivered-To: mailtest@asika.com
...
QUIT
+OK Logging out.
Connection closed by foreign host.
[iyunv@mail home]# openssl s_client -connect 127.0.0.1:995
...
+OK Dovecot ready.
USER mailtest
+OKPASS mailtest
+OK Logged in.
LIST
+OK 4 messages:
1 623
2 623
3 623
4 623
...



也可以通过MUA进行远程收件测试。

6. 配置cyrus-sasl来支持对postfix的收件人验证

第4节中通过对postfix配置实现了postfix的发件功能,但是此时postfix无法对收件人进行验证,因此本文使用了cyrus-sasl来帮助postfix实现对收件人的验证。
RHEL6.5上默认安装了cyrus-sasl,要启用sasl对smtpd的支持,则要在/usr/lib64/sasl2/下新建smtpd.conf文件,并进行如下编辑:
1
2
3
[iyunv@mail sasl2]# vi smtpd.conf
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN



编辑/etc/postfix/main.cf,加入如下配置参数:
1
2
3
4
5
6
7
8
[iyunv@mail postfix]# vi main.cf
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_path = smtpd



如果要使用验证/etc/passwd和/etc/shadow的方式,即通过系统用户的登录密码来进行验证,则要编辑/etc/sysconfig/saslauthd的MECH参数(注:原有的PAM算法未验证):
1
2
[iyunv@mail sysconfig]# vi saslauthd
MECH=shadow



重启postfix和cyrus-sasl,对postfix的收件进行验证:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[iyunv@mail sysconfig]# service saslauthd restart
Stopping saslauthd:                                        [  OK  ]
Starting saslauthd:                                        [  OK  ]
[iyunv@mail sysconfig]# postfix stop
postfix/postfix-script: stopping the Postfix mail system
[iyunv@mail sysconfig]# postfix start
postfix/postfix-script: starting the Postfix mail system
[iyunv@mail sysconfig]# telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.asika.com ESMTP Postfix
ehlo localhost
250-mail.asika.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH LOGIN
334 VXNlcm5hbWU6    #Username base64位编码
bWFpbHRlc3Q=    #mailtest base64位编码
334 UGFzc3dvcmQ6    #Password base64位编码
bWFpbHRlc3Q=
235 2.7.0 Authentication successful
quit
221 2.0.0 Bye
Connection closed by foreign host.



下一篇文章将介绍编译安装courier-authlib,并配置其通过cyrus-sasl库访问mysql。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-161204-1-1.html 上篇帖子: 邮件系统服务器搭建记录(一)(Postfix+Cyrus-sasl+Courier-authlib+Dovecot+ExtMail+MySQL) 下篇帖子: 邮件系统服务器搭建记录(三)(Postfix+Cyrus-sasl+Courier-authlib+Dovecot+ExtMail+MySQL) 服务器 邮件系统 记录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表