Sendmail+dovecot+saslauth+rainloop
環境:CentOS 6.4(最小化安裝)
關閉防火墻和selinux
Sendmail的配置文件
/etc/mail/sendmail.cf :Sendmail的主配置文件;
/etc/mail/access :中繼訪問控制;
/etc/mail/domaintable ;域名映射;
/etc/mail/local-host-names ;本地主機別名;
/etc/mail/mailertable :為特定的域指定特殊的路由規則;
/etc/mail/virtusertable :虛擬域配置
Sendmail為發送服務器
[root@localhost?~]#?yum?-y?install?sendmail?sendmail-cf?openssl-devel?dovecot?cyrus* [root@localhost?~]#?nslookup >?mail.com Server:?192.168.100.243 Address:192.168.100.243#53 Name:mail.com Address:?192.168.100.243 >?192.168.100.243 Server:?192.168.100.243 Address:192.168.100.243#53 243.100.168.192.in-addr.arpaname?=?com. 243.100.168.192.in-addr.arpaname?=?mail.com. 243.100.168.192.in-addr.arpaname?=?aa.com. >?exit [root@localhost?~]#或者
[root@localhost?~]#?tail?-1?/etc/hosts 192.168.100.243?mail.com?mail?mail.com.com?localhost?localhost.localdomain [root@localhost?~]# [root@localhost?~]#?sed?-i?'/^\:OUTPUT?ACCEPT/a\-A?INPUT?\-m?state?\-\-state?NEW?\-m?tcp?\-p?tcp?\-\-dport?25?\-j?ACCEPT'?/etc/sysconfig/iptables [root@localhost?~]#?sed?-i?'/^\:OUTPUT?ACCEPT/a\-A?INPUT?\-m?state?\-\-state?NEW?\-m?tcp?\-p?tcp?\-\-dport?110?\-j?ACCEPT'?/etc/sysconfig/iptables [root@localhost?~]#?/etc/init.d/iptables?restart iptables:?Flushing?firewall?rules:?????????????????????????[??OK??] iptables:?Setting?chains?to?policy?ACCEPT:?filter??????????[??OK??] iptables:?Unloading?modules:???????????????????????????????[??OK??] iptables:?Applying?firewall?rules:?????????????????????????[??OK??] [root@localhost?~]#?chkconfig?iptables?on [root@localhost?~]#?setenforce?0 [root@localhost?~]#?/etc/init.d/postfix?stop Shutting?down?postfix:?????????????????????????????????????[??OK??] [root@localhost?~]#?chkconfig?postfix?off[root@localhost?~]#?echo?'mail.com?RELAY'?>>/etc/mail/access [root@localhost?~]#?echo?'192.168.100.?RELAY'?>>/etc/mail/access [root@localhost?~]#?sed?-i?"/confCACERT_PATH/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confCACERT_PATH/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/ca-bundle.crt/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/ca-bundle.crt/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confSERVER_CERT/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confSERVER_CERT/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confSERVER_KEY/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confSERVER_KEY/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/TRUST_AUTH_MECH/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/TRUST_AUTH_MECH/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confAUTH_MECHANISMS/s/^dnl//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?"/confAUTH_MECHANISMS/s/^[?\t]//g"?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?'/^DAEMON_OPTIONS/s/127\.0\.0\.1/0\.0\.0\.0/g'?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?'/UUCP_MAILER_MAX/s/2/4/g'?/etc/mail/sendmail.mc??????//限制附件的大小 [root@localhost?~]#?cd?/etc/mail/ [root@localhost?mail]#?m4?sendmail.mc?>?sendmail.cf限制郵件的大小:
[root@localhost?~]#?sed?-i?'/MaxMessageSize/s/^#//g'?/etc/mail/sendmail.cf [root@localhost?~]#?sed?-i?'/MaxMessageSize/s/0/4000000/g'?/etc/mail/sendmail.cf配置DOVECOT:
[root@localhost?~]#?sed?-i?'/protocols/s/^#//g'?/etc/dovecot/dovecot.conf如果不做下面的操作,會報:-ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections錯誤
[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\=/s/^#//g'?/etc/dovecot/conf.d/10-mail.conf [root@localhost?~]#?sed?-i?'/INBOX\=/s/^[?\t]*//g'?/etc/dovecot/conf.d/10-mail.conf [root@localhost?~]#?echo?'mail.com'?>>?/etc/mail/local-host-names [root@localhost?~]#?sed?-i?'/MECH\=/s/pam/shadow/'?/etc/sysconfig/saslauthd [root@localhost?~]#?chkconfig?sendmail?on [root@localhost?~]#?chkconfig?dovecot?on [root@localhost?~]#?chkconfig?saslauthd?on [root@localhost?~]#?/etc/init.d/sendmail?restart [root@localhost?~]#?/etc/init.d/dovecot?restart [root@localhost?~]#?/etc/init.d/saslauthd?restart如果報-ERR [IN-USE] Couldn't open INBOX: Internal error occurred. Refer to server log for more information. 錯誤則
[yfshare@aa?~]$?mkdir?-p?/home/yfshare/mail/.imap/INBOX即可在這里添加上即可(執行上面腳本也可):
[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?~]#[root@localhost?~]#?useradd?yfshare [root@localhost?~]#?useradd?bob [root@localhost?~]#?useradd?jerry [root@localhost?~]#?passwd?yfshare [root@localhost?~]#?passwd?bob [root@localhost?~]#?passwd?jerry[root@localhost?~]#?echo?-e?"group1:\tyfshare,bob"?>>/etc/aliases [root@localhost?~]#?newaliases /etc/aliases:?77?aliases,?longest?11?bytes,?782?bytes?total [root@localhost?~]#?/etc/init.d/sendmail?restart Shutting?down?sm-client:???????????????????????????????????[??OK??] Shutting?down?sendmail:????????????????????????????????????[??OK??] Starting?sendmail:?????????????????????????????????????????[??OK??] Starting?sm-client:????????????????????????????????????????[??OK??] [root@localhost?~]#[root@localhost?~]#?saslauthd?-v????????????????//查看是否支持pam或shadow saslauthd?2.1.23 authentication?mechanisms:?getpwent?kerberos5?pam?rimap?shadow?ldap [root@localhost?~]#?testsaslauthd?-u?yfshare?-p?wang1024** 0:?OK?"Success." [root@localhost?~]#?testsaslauthd?-u?bob?-p?wang1024** 0:?OK?"Success." [root@localhost?~]#?testsaslauthd?-u?jerry?-p?wang1024** 0:?OK?"Success." [root@localhost?~]# 如果顯示0:?OK?“Success.”則表明saslauthd工作正常 [root@localhost?~]#?mailq?????????????//查看sendmail隊列 /var/spool/mqueue?is?emptyTotal?requests:?0 [root@localhost?~]# [root@localhost?~]#?mailstats????????//查看郵件系統的狀態 Statistics?from?Wed?Sep??9?17:41:02?2015M???msgsfr??bytes_from???msgsto????bytes_to??msgsrej?msgsdis?msgsqur??Mailer =====================================================================T????????0??????????0K????????0??????????0K????????0???????0???????0C????????0????????????????????0????????????????????0 [root@localhost?~]#驗證:
[root@localhost?~]#?telnet?mail.com?25 Trying?192.168.100.243... Connected?to?mail.com. Escape?character?is?'^]'. 220?aa.com?ESMTP?Sendmail?8.14.4/8.14.4;?Thu,?10?Sep?2015?14:03:34?+0800 mail?from:yfshare@mail.com 250?2.1.0?yfshare@mail.com...?Sender?ok rcpt?to:bob@mail.com 250?2.1.5?bob@mail.com...?Recipient?ok data 354?Enter?mail,?end?with?"."?on?a?line?by?itself this?is?test?mail~~~!! . 250?2.0.0?t8A63Yf6002353?Message?accepted?for?delivery quit 221?2.0.0?aa.com?closing?connection Connection?closed?by?foreign?host. [root@localhost?~]#[bob@aa?~]$?mail Heirloom?Mail?version?12.4?7/29/08.??Type???for?help. "/var/spool/mail/bob":?1?message >???1?yfshare@mail.com??????Thu?Sep?10?14:05??13/471?? &注:如果用IMAP來接收郵件,在郵件帳號里面直接寫用戶名,不加@mail.com
上面搭建的郵件服務器是使用明文傳輸的,不安全。
下面給郵件服務器弄個SSL:(dovecot默認就支持pop3s和imaps)
pop3 | 110 | pop3s | 995 |
smtp | 25 | smtps | 465 |
imap | 143 | imaps | 993 |
生成sendmail.pem文件?
[root@localhost?~]#?cd?/etc/pki/tls/certs/ [root@localhost?certs]#?make?sendmail.pem開啟SMTPS:
[root@localhost?~]#?sed?-i?'/TLSMTA/s/^dnl//g'?/etc/mail/sendmail.mc [root@localhost?~]#?sed?-i?'/TLSMTA/s/^[?\t]*//g'?/etc/mail/sendmail.mc [root@localhost?~]#?cd?/etc/mail/ [root@localhost?mail]#?cp?sendmail.cf?sendmail.cf.bak [root@localhost?mail]#?m4?sendmail.mc?>?sendmail.cf [root@localhost?~]#?yum?-y?install?xinetd [root@localhost?~]#?/etc/init.d/xinetd?restart [root@localhost?~]#?ll?/etc/pki/tls/certs/sendmail.pem -rw-------?1?root?root?2913?Sep?10?11:45?/etc/pki/tls/certs/sendmail.pem [root@localhost?~]# [root@localhost?~]#?/etc/init.d/sendmail?restart Shutting?down?sm-client:???????????????????????????????????[??OK??] Shutting?down?sendmail:????????????????????????????????????[??OK??] Starting?sendmail:?????????????????????????????????????????[??OK??] Starting?sm-client:????????????????????????????????????????[??OK??] [root@localhost?~]# [root@localhost?~]#?/etc/init.d/dovecot?restart Stopping?Dovecot?Imap:?????????????????????????????????????[??OK??] Starting?Dovecot?Imap:?????????????????????????????????????[??OK??] [root@localhost?~]# [root@localhost?~]#?/etc/init.d/saslauthd?restart Stopping?saslauthd:????????????????????????????????????????[??OK??] Starting?saslauthd:????????????????????????????????????????[??OK??] [root@localhost?~]#[root@localhost?~]#?netstat?-anp|grep?dovecot|head?-n?4 tcp????????0??????0?0.0.0.0:110?????????????????0.0.0.0:*???????????????????LISTEN??????2642/dovecot???????? tcp????????0??????0?0.0.0.0:143?????????????????0.0.0.0:*???????????????????LISTEN??????2642/dovecot???????? tcp????????0??????0?0.0.0.0:993?????????????????0.0.0.0:*???????????????????LISTEN??????2642/dovecot???????? tcp????????0??????0?0.0.0.0:995?????????????????0.0.0.0:*???????????????????LISTEN??????2642/dovecot???????? [root@localhost?~]# [root@localhost?~]#?netstat?-anp|grep?sendmail tcp????????0??????0?0.0.0.0:465?????????????????0.0.0.0:*???????????????????LISTEN??????2621/sendmail??????? tcp????????0??????0?0.0.0.0:25??????????????????0.0.0.0:*???????????????????LISTEN??????2621/sendmail??????? unix??2??????[?]?????????DGRAM????????????????????15538??2629/sendmail:?Queu unix??2??????[?]?????????DGRAM????????????????????15523??2621/sendmail?????? [root@localhost?~]#測試成功:a/b/c三個用戶,group包含a/b用戶,c給a發送郵件并抄送給group,這時a只會收到一封郵件,Sendmail會過濾掉相同mailID的郵件。而Postfix則會給a發送兩封一模一樣的郵件
[root@localhost?~]#?mailstats Statistics?from?Thu?Sep?10?14:05:06?2015M???msgsfr??bytes_from???msgsto????bytes_to??msgsrej?msgsdis?msgsqur??Mailer4????????4?????????12K????????0??????????0K????????0???????0???????0??esmtp9???????10?????????27K???????16?????????40K????????3???????0???????0??local =====================================================================T???????14?????????39K???????16?????????40K????????3???????0???????0C???????16????????????????????0????????????????????3 [root@localhost?~]#
如果把這行注釋掉,Sendmail就不支持smtp發送郵件了,只支持smtps發送郵件
安裝rainloop:
[root@localhost?~]#?yum?-y?install?php* [root@localhost?~]#?unzip?rainloop-latest.zip??-d?/var/www/html/ [root@localhost?~]#?chown?apache:apache?/var/www/html/*?-R [root@localhost?~]#?sed?-i?'/^DirectoryIndex/s/html/html?index.php/g'?/etc/httpd/conf/httpd.conf [root@localhost?~]#?sed?-i?'/post_max_size/s/8/4/g'?/etc/php.ini [root@localhost?~]#?sed?-i?'/upload_max_filesize/s/2/3/g'?/etc/php.ini [root@localhost?~]#?/etc/init.d/httpd?restart Stopping?httpd:????????????????????????????????????????????[??OK??] Starting?httpd:????????????????????????????????????????????[??OK??] [root@localhost?~]#?chkconfig?httpd?on訪問:http://192.168.100.243/?admin進入后臺管理
不允許用戶添加其他的賬戶
添加個性化標題:
訪問:http://192.168.100.243進入web mail
如果出現無法載入郵件,把下面這個改成off,保存配置后再登錄即可
[root@localhost?~]#?grep?autocreate_system_folders?/var/www/html/data/_data_/_default_/configs/application.ini autocreate_system_folders?=?On [root@localhost?~]#你應該知道的最好Webmail郵件客戶端
Postfix+dovecot+saslauth
轉載于:https://blog.51cto.com/yfshare/1696591
總結
以上是生活随笔為你收集整理的Sendmail+dovecot+saslauth+rainloop的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springMvc解决json中文乱码
- 下一篇: 如何有效地记录 Java SQL 日志(