CentOS 7.2部署邮件服务器(Postfix)
一、Postfix简介
Postfix是一种电子邮件服务器,它是由任职于IBM华生研究中心(T.J.WatsonResearchCenter)的荷兰籍研究员WietseVenema为了改良sendmail邮件服务器而产生的。最早在1990年代晚期出现,是一个开放源代码的软件。
Postfix官方网站:http://www.postfix.org/
Postfix下载地址:http://www.postfix.org/download.html
二、Postfix安装
安装Postfix以配置SMTP服务器
[1]即使CentOS系统安装了[最小安装],也会安装Postfix,但如果Postfix不安装,请先安装它,如下所示。
[root@linuxprobe~]#yum-yinstallpostfix
[2]此示例显示配置SMTP-Auth以使用Dovecot的SASL函数。
[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
[3]如果Firewalld正在运行,请允许SMTP服务。SMTP使用25/TCP。
[root@dlp~]#firewall-cmd--add-service=smtp--permanent success [root@dlp~]#firewall-cmd--reload success
三、Dovecot安装
安装Dovecot以配置POP/IMAP服务器
[1]安装Dovecot.
[root@linuxprobe~]#yum-yinstalldovecot
[2]此示例显示配置为向Postfix提供SASL功能.
[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
[3]如果Firewalld正在运行,请允许POP/IMAP服务。POP使用110/TCP,IMAP使用143/TCP.
[root@vdevops~]#firewall-cmd--add-port={110/tcp,143/tcp}--permanent success [root@vdevops~]#firewall-cmd--reload success
四、SSL设置
配置SSL以加密连接
[1]首先创建证书,传送门:https://www.nhooo.com/article/97434.htm
[2]为SSL配置Postfix和Dovecot。
#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=</etc/pki/tls/certs/server.crt ssl_key=</etc/pki/tls/certs/server.key [root@linuxprobe~]#systemctlrestartpostfixdovecot
[3]如果Firewalld正在运行,请允许SMTPS/POP3S/IMAPS服务。SMTPS使用465/
TCP,POP3S使用995/TCP,IMAPS使用993/TCP。
[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
邮件日志报告:pflogsumm
安装pflogsumm这是Postfix日志报告工具
[1]安装postfix-perl-scripts包.
[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 [root@linuxprobe~]#crontab-e #发送邮件日志摘要在AM每天1:00到根 0001***perl/usr/sbin/pflogsumm-e-dyesterday/var/log/maillog|mail-s'LogwatchforPostfix'root
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。