<p>一、Postfix简介</p><p>Postfix 是一种电子邮件服务器,它是由任职于IBM华生研究中心(T.J. Watson Research Center)的荷兰籍研究员Wietse Venema为了改良sendmail邮件服务器而产生的。最早在1990年代晚期出现,是一个开放源代码的软件。</p><p>Postfix 官方网站:http://www.postfix.org/</p><p>Postfix 下载地址:http://www.postfix.org/download.html</p><p>二、Postfix安装</p><p>安装Postfix以配置SMTP服务器</p><p>[1] 即使CentOS系统安装了[最小安装],也会安装Postfix,但如果Postfix不安装,请先安装它,如下所示。</p><p>[root@linuxprobe ~]# yum -y install postfix</p><p>1</p><p>[2] 此示例显示配置SMTP-Auth以使用Dovecot的SASL函数。</p><pre class="brush:bash;toolbar:false">[root@linuxprobe~]#vi/etc/postfix/main.cf #line75:uncommentandspecifyhostname myhostname=linuxprobe.srv.world #line83:uncommentandspecifydomainname mydomain=srv.world #line99:uncomment myorigin=$mydomain #line116:change inet_interfaces=all #line164:add mydestination=$myhostname,localhost.$mydomain,localhost,$mydomain #line264:uncommentandspecifyyourlocalnetwork mynetworks=127.0.0.0/8,10.0.0.0/24 #line419:uncomment(usemailboxdir) home_mailbox=mailbox/ #line574:add smtpd_banner=$myhostnameESMTP #addfollowstotheend #limitanemailsizefor10M message_size_limit=10485760 #limitamailboxfor1G mailbox_size_limit=1073741824 #forSMTP-Auth smtpd_sasl_type=dovecot smtpd_sasl_path=private/auth smtpd_sasl_auth_enable=yes smtpd_sasl_security_options=noanonymous smtpd_sasl_local_domain=$myhostname smtpd_recipient_restrictions=permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject [root@linuxprobe~]#systemctlrestartpostfix [root@linuxprobe~]#systemctlenablepostfix</pre><p>[3]如果Firewalld正在运行,请允许SMTP服务。 SMTP使用25 / TCP。</p><pre class="brush:bash;toolbar:false">[root@dlp~]#firewall-cmd--add-service=smtp--permanent success [root@dlp~]#firewall-cmd--reload success</pre><p>三、Dovecot 安装</p><p>安装Dovecot以配置POP / IMAP服务器</p><p>[1] 安装Dovecot.</p><p>[root@linuxprobe ~]# yum -y install dovecot</p><p>1</p><p>[2] 此示例显示配置为向Postfix提供SASL功能 .</p><pre class="brush:bash;toolbar:false">[root@linuxprobe~]#vi/etc/dovecot/dovecot.conf #line24:uncomment protocols=imappop3lmtp #line30:uncommentandchange(ifnotuseIPv6) listen=* [root@linuxprobe~]#vi/etc/dovecot/conf.d/10-auth.conf #line10:uncommentandchange(allowplaintextauth) disable_plaintext_auth=no #line100:add auth_mechanisms=plainlogin [root@linuxprobe~]#vi/etc/dovecot/conf.d/10-mail.conf #line30:uncommentandadd mail_location=maildir:~/Maildir [root@linuxprobe~]#vi/etc/dovecot/conf.d/10-master.conf #line96-98:uncommentandaddlikefollows #Postfixsmtp-auth unix_listener/var/spool/postfix/private/auth{ mode=0666 user=postfix group=postfix } [root@linuxprobe~]#vi/etc/dovecot/conf.d/10-ssl.conf #line8:change(notrequireSSL) ssl=no [root@linuxprobe~]#systemctlstartdovecot [root@linuxprobe~]#systemctlenabledovecot</pre><p>[3] 如果Firewalld正在运行,请允许POP / IMAP服务。 POP使用110 / TCP,IMAP使用143 / TCP.</p><pre class="brush:bash;toolbar:false">[root@vdevops~]#firewall-cmd--add-port={110/tcp,143/tcp}--permanent success [root@vdevops~]#firewall-cmd--reload success</pre><p>四、SSL设置</p><p>配置SSL以加密连接</p><p>[1] 首先创建证书,传送门:http://blog.csdn.net/wh211212/article/details/52982917</p><p>[2] 为SSL配置Postfix和Dovecot。</p><pre class="brush:bash;toolbar:false">#addtotheend smtpd_use_tls=yes smtpd_tls_cert_file=/etc/pki/tls/certs/server.crt smtpd_tls_key_file=/etc/pki/tls/certs/server.key smtpd_tls_session_cache_database=btree:/etc/postfix/smtpd_scache [root@linuxprobe~]#vi/etc/postfix/master.cf #line26-28:uncomment smtpsinetn-n--smtpd -osyslog_name=postfix/smtps -osmtpd_tls_wrappermode=yes [root@linuxprobe~]#vi/etc/dovecot/conf.d/10-ssl.conf #line8:change ssl=yes #line14,15:specifycertificates ssl_cert=&lt;/etc/pki/tls/certs/server.crt ssl_key=&lt;/etc/pki/tls/certs/server.key [root@linuxprobe~]#systemctlrestartpostfixdovecot</pre><p>[3] 如果Firewalld正在运行,请允许SMTPS / POP3S / IMAPS服务。 SMTPS使用465 /</p><p>TCP,POP3S使用995 / TCP,IMAPS使用993 / TCP。</p><pre class="brush:bash;toolbar:false">[root@vdevops~]#firewall-cmd--add-service={pop3s,imaps}--permanent success [root@vdevops~]#firewall-cmd--add-port=465/tcp--permanent success [root@vdevops~]#firewall-cmd--reload success</pre><p>邮件日志报告:pflogsumm</p><p>安装pflogsumm这是Postfix日志报告工具</p><p>[1] 安装postfix-perl-scripts包 .</p><pre class="brush:bash;toolbar:false">[root@linuxprobe~]#yum-yinstallpostfix-perl-scripts #generatelogsummaryforyesterday [root@linuxprobe~]#perl/usr/sbin/pflogsumm-dyesterday/var/log/maillog PostfixlogsummariesforJul14 GrandTotals ------------ messages 2received 5delivered 0forwarded 0deferred 0bounced 0rejected(0%) 0rejectwarnings 0held 0discarded(0%) 2879bytesreceived 6572bytesdelivered 1senders 1sendinghosts/domains 2recipients 2recipienthosts/domains Per-HourTrafficSummary ------------------------ timereceiveddelivereddeferredbouncedrejected -------------------------------------------------------------------- 0000-010000000 0100-020000000 0200-030000000 0300-040000000 0400-050000000 0500-060000000 0600-070000000 0700-080000000 0800-090000000 0900-100000000 1000-110025000 1100-120000000 1200-130000000 1300-140000000 1400-150000000 1500-160000000 1600-170000000 1700-180000000 1800-190000000 1900-200000000 2000-210000000 2100-220000000 2200-230000000 2300-240000000 Host/DomainSummary:MessageDelivery -------------------------------------- sentcntbytesdefersavgdlymaxdlyhost/domain ----------------------------------------------- 3411900.4s0.8ssrv.world 2245300.1s0.1smail.srv.world Host/DomainSummary:MessagesReceived --------------------------------------- msgcntbyteshost/domain -------------------------- 22879mail.srv.world Sendersbymessagecount ------------------------ 2cent@mail.srv.world Recipientsbymessagecount --------------------------- 3redhat@srv.world 2cent@mail.srv.world Sendersbymessagesize ----------------------- 2879cent@mail.srv.world Recipientsbymessagesize -------------------------- 4119redhat@srv.world 2453cent@mail.srv.world messagedeferraldetail:none messagebouncedetail(byrelay):none messagerejectdetail:none messagerejectwarningdetail:none messageholddetail:none messagediscarddetail:none smtpdeliveryfailures:none Warnings -------- tlsmgr(total:6) 3redirectingtherequesttopostfix-owneddata_directory/var/li... 3requesttoupdatetablebtree:/etc/postfix/smtpd_scacheinnon-... FatalErrors:none Panics:none Masterdaemonmessages ---------------------- 4daemonstarted--version2.10.1,configuration/etc/postfix 3terminatingonsignal15 1reload--version2.10.1,configuration/etc/postfix</pre><p>[root@linuxprobe ~]# crontab -e</p><p># 发送邮件日志摘要在AM每天1:00到根</p><p>00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s &#39;Logwatch for Postfix&#39; root</p>
T:0.004381s,M:243.72 KB
返回顶部 留言