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

[经验分享] Postfix+dovecot+saslauth

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-21 08:38:54 | 显示全部楼层 |阅读模式
环境:Centos 6.4


关闭防火墙和selinux
1
2
3
[iyunv@localhost ~]# postconf mail_version
mail_version = 2.6.6
[iyunv@localhost ~]#



1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@localhost ~]# yum -y install postfix dovecot cyrus* openssl openssl-devel
[iyunv@localhost ~]# sed -i '/host\.domain\.tld/imyhostname \= mail\.com' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/^#mydomain \=/imydomain \= mail\.com' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/myorigin \= \$mydomain/s/^#//g' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/inet_interfaces \= all/s/^#//g' /etc/postfix/main.cf
[iyunv@localhost ~]# grep 'inet_protocols = all' /etc/postfix/main.cf
inet_protocols = all
[iyunv@localhost ~]# sed -i '/inet\_interfaces \= localhost/s/inet\_interfaces/#inet\_interfaces/g' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/^mydestination/s/localhost/localhost\, \$mydomain/g' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/127\.0\.0\.0/imynetworks \= 0\.0\.0\.0\/0' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/^#mynetworks_style = subnet/s/^#//g' /etc/postfix/main.cf
[iyunv@localhost ~]# sed -i '/^#relay_domains/irelay_domains \= \$mydomain' /etc/postfix/main.cf



让其支持smtps

生成证书:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@localhost ~]# cd /etc/pki/tls/certs/
[iyunv@localhost certs]# make postfix.pem
[iyunv@localhost ~]# echo '#smtpd-tls' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'smtpd_tls_key_file = /etc/pki/tls/certs/postfix.pem' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'smtpd_use_tls = yes' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'tls_random_source = dev:/dev/urandom' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'tls_daemon_random_source = dev:/dev/urandom' >> /etc/postfix/main.cf
[iyunv@localhost ~]# echo 'message_size_limit = 10240000' >> /etc/postfix/main.cf    //限制邮件大小
[iyunv@localhost ~]# sed -i '/smtps/s/^#//g' /etc/postfix/master.cf
[iyunv@localhost ~]# sed -i '/smtpd\_tls\_wrappermode/s/^#//g' /etc/postfix/master.cf
[iyunv@localhost ~]# sed -i "19s/^#//g" /etc/postfix/master.cf
[iyunv@localhost ~]# echo -e 'group:\tyfshare,bob' >> /etc/aliases
[iyunv@localhost ~]# newaliases



1
2
3
4
5
6
7
8
[iyunv@localhost ~]# /etc/init.d/postfix restart
[iyunv@localhost ~]# chkconfig postfix on
[iyunv@localhost ~]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.com ESMTP Postfix
···



配置DOVECOT:
1
2
3
4
5
6
7
8
[iyunv@localhost ~]# sed -i '/protocols/s/^#//g' /etc/dovecot/dovecot.conf
[iyunv@localhost ~]# sed -i '/login_trusted_networks/s/^#//g' /etc/dovecot/dovecot.conf
[iyunv@localhost ~]# sed -i '/login_trusted_networks/s/\=/\= 0\.0\.0\.0\/0/g' /etc/dovecot/dovecot.conf
[iyunv@localhost ~]# sed -i '/INBOX\=\/var\/mail/s/^#//g' /etc/dovecot/conf.d/10-mail.conf
[iyunv@localhost ~]# sed -i '/INBOX\=\/var\/mail/s/^[ \t]*//g' /etc/dovecot/conf.d/10-mail.conf
[iyunv@localhost ~]# sed -i '/#ssl = yes/s/^#//g' /etc/dovecot/conf.d/10-ssl.conf
[iyunv@localhost ~]# /etc/init.d/dovecot restart
[iyunv@localhost ~]# chkconfig dovecot on



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@localhost ~]# netstat -tunlp|grep 110
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      6272/dovecot         
tcp        0      0 :::110                      :::*                        LISTEN      6272/dovecot         
[iyunv@localhost ~]# netstat -tunlp|grep 995
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      6272/dovecot         
tcp        0      0 :::995                      :::*                        LISTEN      6272/dovecot         
[iyunv@localhost ~]# netstat -tunlp|grep 25
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      6519/master         
tcp        0      0 :::25                       :::*                        LISTEN      6519/master         
[iyunv@localhost ~]# netstat -tunlp|grep 465
tcp        0      0 0.0.0.0:465                 0.0.0.0:*                   LISTEN      6519/master         
tcp        0      0 :::465                      :::*                        LISTEN      6519/master         
[iyunv@localhost ~]# netstat -tunlp|grep 143
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      6272/dovecot         
tcp        0      0 :::143                      :::*                        LISTEN      6272/dovecot         
[iyunv@localhost ~]# netstat -tunlp|grep 993
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      6272/dovecot         
tcp        0      0 :::993                      :::*                        LISTEN      6272/dovecot         
[iyunv@localhost ~]#



1
2
3
4
5
[iyunv@localhost ~]# tail -n 5 /etc/skel/.bashrc |head -n 3
if [ ! -d ~/mail/.imap/INBOX ];then
        mkdir -p ~/mail/.imap/INBOX
fi
[iyunv@localhost ~]#



spacer.jpg
1
2
3
4
5
6
7
8
9
[iyunv@localhost ~]# useradd yfshare
[iyunv@localhost ~]# useradd bob
[iyunv@localhost ~]# useradd tom
[iyunv@localhost ~]# echo '123456' |passwd yfshare --stdin
[iyunv@localhost ~]# echo '123456' |passwd bob --stdin
[iyunv@localhost ~]# echo '123456' |passwd tom --stdin
[iyunv@localhost ~]# mkdir -p /home/yfshare/mail/.imap/INBOX && chown yfshare:yfshare /home/yfshare/mail -R
[iyunv@localhost ~]# mkdir -p /home/bob/mail/.imap/INBOX && chown bob:bob /home/bob/mail -R
[iyunv@localhost ~]# mkdir -p /home/tom/mail/.imap/INBOX && chown tom:tom /home/tom/mail -R



配置saslauth:

1
2
3
4
5
6
7
8
9
10
11
12
13
[iyunv@localhost ~]# sed -i '/MECH\=/s/pam/shadow/' /etc/sysconfig/saslauthd
[iyunv@localhost ~]# /etc/init.d/saslauthd restart
[iyunv@localhost ~]# chkconfig saslauthd on
[iyunv@localhost ~]# saslauthd -v
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
[iyunv@localhost ~]# testsaslauthd -u yfshare -p 123456
0: OK "Success."
[iyunv@localhost ~]# testsaslauthd -u bob -p 123456
0: OK "Success."
[iyunv@localhost ~]# testsaslauthd -u tom -p 123456
0: OK "Success."
[iyunv@localhost ~]#



注:selinux会影响testsaslauthd使用shadow认证,如果不想关闭selinux,执行:
1
[iyunv@localhost ~]# setsebool -P allow_saslauthd_read_shadow 1



pop3
110
pop3s
995
smtp
25
smtps
465
imap
143
imaps
993

Postfix当bob用户给yfshare发送邮件并抄送给group,且yfshare在group里,这时yfshare用户会收到两封一模一样的邮件,这是Postfix的BUG
QQ截图20150921083725.png SSL加密发送邮件:(IMAPS+SMTPS)

QQ截图20150921083737.png SSL加密发送邮件:(POP3S+SMTPS)
QQ截图20150921083745.png
1
2
3
4
5
6
7
8
9
10
[iyunv@localhost ~]# ll /home/yfshare/mail/.imap/INBOX/
total 20
-rw-rw----. 1 yfshare mail 16384 Sep 18 17:34 dovecot.index.cache
-rw-rw----. 1 yfshare mail  1668 Sep 18 17:34 dovecot.index.log
[iyunv@localhost ~]# ll /var/mail/
total 16
-rw-rw----. 1 bob     mail 7071 Sep 18 17:34 bob
-rw-rw----. 1 tom     mail    0 Sep 18 17:10 tom
-rw-rw----. 1 yfshare mail 6955 Sep 18 17:34 yfshare
[iyunv@localhost ~]#




QQ截图20150921083808.png
QQ截图20150921083845.png

Sendmail+dovecot+saslauth+rainloop



运维网声明 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-116454-1-1.html 上篇帖子: Postfix+Sasl+Courier-authlib+Dovecot+MySQL+extmail实现WebMail 下篇帖子: Sendmail+dovecot+saslauth+rainloop
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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