Postfix+dovecot+saslauth 素颜马尾好姑娘i 2022-01-17 08:31 189阅读 0赞 环境:Centos 6.4 关闭防火墙和selinux [root@localhost ~]# postconf mail_version mail_version = 2.6.6 [root@localhost ~]# [root@localhost ~]# yum -y install postfix dovecot cyrus* openssl openssl-devel [root@localhost ~]# sed -i '/host\.domain\.tld/imyhostname \= mail\.com' /etc/postfix/main.cf [root@localhost ~]# sed -i '/^#mydomain \=/imydomain \= mail\.com' /etc/postfix/main.cf [root@localhost ~]# sed -i '/myorigin \= \$mydomain/s/^#//g' /etc/postfix/main.cf [root@localhost ~]# sed -i '/inet_interfaces \= all/s/^#//g' /etc/postfix/main.cf [root@localhost ~]# grep 'inet_protocols = all' /etc/postfix/main.cf inet_protocols = all [root@localhost ~]# sed -i '/inet\_interfaces \= localhost/s/inet\_interfaces/#inet\_interfaces/g' /etc/postfix/main.cf [root@localhost ~]# sed -i '/^mydestination/s/localhost/localhost\, \$mydomain/g' /etc/postfix/main.cf [root@localhost ~]# sed -i '/127\.0\.0\.0/imynetworks \= 0\.0\.0\.0\/0' /etc/postfix/main.cf [root@localhost ~]# sed -i '/^#mynetworks_style = subnet/s/^#//g' /etc/postfix/main.cf [root@localhost ~]# sed -i '/^#relay_domains/irelay_domains \= \$mydomain' /etc/postfix/main.cf 让其支持smtps 生成证书: [root@localhost ~]# cd /etc/pki/tls/certs/ [root@localhost certs]# make postfix.pem [root@localhost ~]# echo '#smtpd-tls' >> /etc/postfix/main.cf [root@localhost ~]# echo 'smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem' >> /etc/postfix/main.cf [root@localhost ~]# echo 'smtpd_tls_key_file = /etc/pki/tls/certs/postfix.pem' >> /etc/postfix/main.cf [root@localhost ~]# echo 'smtpd_use_tls = yes' >> /etc/postfix/main.cf [root@localhost ~]# echo 'tls_random_source = dev:/dev/urandom' >> /etc/postfix/main.cf [root@localhost ~]# echo 'tls_daemon_random_source = dev:/dev/urandom' >> /etc/postfix/main.cf [root@localhost ~]# echo 'message_size_limit = 10240000' >> /etc/postfix/main.cf //限制邮件大小 [root@localhost ~]# sed -i '/smtps/s/^#//g' /etc/postfix/master.cf [root@localhost ~]# sed -i '/smtpd\_tls\_wrappermode/s/^#//g' /etc/postfix/master.cf [root@localhost ~]# sed -i "19s/^#//g" /etc/postfix/master.cf [root@localhost ~]# echo -e 'group:\tyfshare,bob' >> /etc/aliases [root@localhost ~]# newaliases [root@localhost ~]# /etc/init.d/postfix restart [root@localhost ~]# chkconfig postfix on [root@localhost ~]# telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 mail.com ESMTP Postfix ··· 配置DOVECOT: [root@localhost ~]# sed -i '/protocols/s/^#//g' /etc/dovecot/dovecot.conf [root@localhost ~]# sed -i '/login_trusted_networks/s/^#//g' /etc/dovecot/dovecot.conf [root@localhost ~]# sed -i '/login_trusted_networks/s/\=/\= 0\.0\.0\.0\/0/g' /etc/dovecot/dovecot.conf [root@localhost ~]# sed -i '/INBOX\=\/var\/mail/s/^#//g' /etc/dovecot/conf.d/10-mail.conf [root@localhost ~]# sed -i '/INBOX\=\/var\/mail/s/^[ \t]*//g' /etc/dovecot/conf.d/10-mail.conf [root@localhost ~]# sed -i '/#ssl = yes/s/^#//g' /etc/dovecot/conf.d/10-ssl.conf [root@localhost ~]# /etc/init.d/dovecot restart [root@localhost ~]# chkconfig dovecot on [root@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 [root@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 [root@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 [root@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 [root@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 [root@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 [root@localhost ~]# [root@localhost ~]# tail -n 5 /etc/skel/.bashrc |head -n 3 if [ ! -d ~/mail/.imap/INBOX ];then mkdir -p ~/mail/.imap/INBOX fi [root@localhost ~]# ![useradd.sh][] [root@localhost ~]# useradd yfshare [root@localhost ~]# useradd bob [root@localhost ~]# useradd tom [root@localhost ~]# echo '123456' |passwd yfshare --stdin [root@localhost ~]# echo '123456' |passwd bob --stdin [root@localhost ~]# echo '123456' |passwd tom --stdin [root@localhost ~]# mkdir -p /home/yfshare/mail/.imap/INBOX && chown yfshare:yfshare /home/yfshare/mail -R [root@localhost ~]# mkdir -p /home/bob/mail/.imap/INBOX && chown bob:bob /home/bob/mail -R [root@localhost ~]# mkdir -p /home/tom/mail/.imap/INBOX && chown tom:tom /home/tom/mail -R 配置saslauth: [root@localhost ~]# sed -i '/MECH\=/s/pam/shadow/' /etc/sysconfig/saslauthd [root@localhost ~]# /etc/init.d/saslauthd restart [root@localhost ~]# chkconfig saslauthd on [root@localhost ~]# saslauthd -v saslauthd 2.1.23 authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap [root@localhost ~]# testsaslauthd -u yfshare -p 123456 0: OK "Success." [root@localhost ~]# testsaslauthd -u bob -p 123456 0: OK "Success." [root@localhost ~]# testsaslauthd -u tom -p 123456 0: OK "Success." [root@localhost ~]# 注:selinux会影响testsaslauthd使用shadow认证,如果不想关闭selinux,执行: [root@localhost ~]# setsebool -P allow_saslauthd_read_shadow 1 <table> <tbody> <tr> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">pop3</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">110</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">pop3s</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">995</span></p></td> </tr> <tr> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">smtp</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">25</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">smtps</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">465</span></p></td> </tr> <tr> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">imap</span></p></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">143</span></p></td> <td><span style="font-size:18px;font-family:'宋体', SimSun;">imaps</span></td> <td><p><span style="font-size:18px;font-family:'宋体', SimSun;">993</span></p></td> </tr> </tbody> </table> Postfix当bob用户给yfshare发送邮件并抄送给group,且yfshare在group里,这时yfshare用户会收到两封一模一样的邮件,这是Postfix的BUG [![wKioL1X-zxDQAXF-AAHpXv0pXTw210.jpg][]][wKioL1X-zxDQAXF-AAHpXv0pXTw210.jpg]SSL加密发送邮件:(IMAPS+SMTPS) [![wKiom1X-zPLQ6KSAAALHRkwAHXU659.jpg][]][wKiom1X-zPLQ6KSAAALHRkwAHXU659.jpg]SSL加密发送邮件:(POP3S+SMTPS) [![wKioL1X-z0\_A9c4OAAKJaP543f4508.jpg][wKioL1X-z0_A9c4OAAKJaP543f4508.jpg]][wKioL1X-z0_A9c4OAAKJaP543f4508.jpg] [root@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 [root@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 [root@localhost ~]# [![wKioL1X-z4PyJIKvAATn9Q5xwNU563.jpg][]][wKioL1X-z4PyJIKvAATn9Q5xwNU563.jpg] [![wKiom1X-zUejMiEPAAFbJiWMa2E413.jpg][]][wKiom1X-zUejMiEPAAFbJiWMa2E413.jpg] [**Sendmail+dovecot+saslauth+rainloop**][Sendmail_dovecot_saslauth_rainloop] 转载于:https://blog.51cto.com/yfshare/1696596 [useradd.sh]: [wKioL1X-zxDQAXF-AAHpXv0pXTw210.jpg]: /images/20220117/434328ca1b17454dae256e9ba9f39595.png [wKiom1X-zPLQ6KSAAALHRkwAHXU659.jpg]: /images/20220117/bc8bc7fdca784a158f4d237d5d83620b.png [wKioL1X-z0_A9c4OAAKJaP543f4508.jpg]: /images/20220117/6021fe6da87646f6bd95a07caac53780.png [wKioL1X-z4PyJIKvAATn9Q5xwNU563.jpg]: /images/20220117/c7db35627aa347f397dc32c3640a523b.png [wKiom1X-zUejMiEPAAFbJiWMa2E413.jpg]: /images/20220117/52b31caeb410454e9cfb55a8b2b3fe29.png [Sendmail_dovecot_saslauth_rainloop]: http://yfshare.blog.51cto.com/8611708/1696591
还没有评论,来说两句吧...