博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS 7.2 部署邮件服务器(Postfix)
阅读量:5302 次
发布时间:2019-06-14

本文共 8661 字,大约阅读时间需要 28 分钟。

转载原文地址:https://blog.csdn.net/wh211212/article/details/53040620

改天装系统搭建一下        

一、Postfix简介

  • Postfix 是一种电子邮件服务器,它是由任职于IBM华生研究中心(T.J. Watson Research Center)的荷兰籍研究员Wietse Venema为了改良sendmail邮件服务器而产生的。最早在1990年代晚期出现,是一个开放源代码的软件。
  • Postfix  官方网站:
  • Postfix  下载地址:

二、Postfix安装

  • 安装Postfix以配置SMTP服务器

     [1] 即使CentOS系统安装了[最小安装],也会安装Postfix,但如果Postfix不安装,请先安装它,如下所示。

[root@linuxprobe ~]# yum -y install postfix

     [2] 此示例显示配置SMTP-Auth以使用Dovecot的SASL函数。

1 [root@linuxprobe ~]# vi /etc/postfix/main.cf 2 # line 75: uncomment and specify hostname 3  4 myhostname = linuxprobe.srv.world 5 # line 83: uncomment and specify domain name 6  7 mydomain = srv.world 8 # line 99: uncomment 9 10 myorigin = $mydomain11 # line 116: change12 13 inet_interfaces = all14 # line 164: add15 16 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain17 # line 264: uncomment and specify your local network18 19 mynetworks = 127.0.0.0/8, 10.0.0.0/2420 # line 419: uncomment (use mailboxdir)21 22 home_mailbox = mailbox/23 # line 574: add24 25 smtpd_banner = $myhostname ESMTP26 # add follows to the end27 28 # limit an email size for 10M29 30 message_size_limit = 1048576031 32 # limit a mailbox for 1G33 34 mailbox_size_limit = 107374182435 # for SMTP-Auth36 37 smtpd_sasl_type = dovecot38 smtpd_sasl_path = private/auth39 smtpd_sasl_auth_enable = yes40 smtpd_sasl_security_options = noanonymous41 smtpd_sasl_local_domain = $myhostname42 smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject43 44 [root@linuxprobe ~]# systemctl restart postfix45 [root@linuxprobe ~]# systemctl enable postfix
View Code

     [3] 如果Firewalld正在运行,请允许SMTP服务。 SMTP使用25 / TCP。

1 [root@dlp ~]# firewall-cmd --add-service=smtp --permanent2 success3 [root@dlp ~]# firewall-cmd --reload4 success
View Code

三、Dovecot  安装

  • 安装Dovecot以配置POP / IMAP服务器

     [1] 安装Dovecot.

1 [root@linuxprobe ~]# yum -y install dovecot
View Code

     [2] 此示例显示配置为向Postfix提供SASL功能  .

1 [root@linuxprobe ~]# vi /etc/dovecot/dovecot.conf 2 # line 24: uncomment 3 protocols = imap pop3 lmtp 4 # line 30: uncomment and change ( if not use IPv6 ) 5 listen = * 6 [root@linuxprobe ~]# vi /etc/dovecot/conf.d/10-auth.conf 7 # line 10: uncomment and change ( allow plain text auth ) 8 disable_plaintext_auth = no 9 # line 100: add10 auth_mechanisms = plain login11 [root@linuxprobe ~]# vi /etc/dovecot/conf.d/10-mail.conf12 # line 30: uncomment and add13 mail_location = maildir:~/Maildir14 [root@linuxprobe ~]# vi /etc/dovecot/conf.d/10-master.conf15 # line 96-98: uncomment and add like follows16 # Postfix smtp-auth17 unix_listener /var/spool/postfix/private/auth {18     mode = 066619     user = postfix20     group = postfix21 }22 [root@linuxprobe ~]# vi /etc/dovecot/conf.d/10-ssl.conf23 # line 8: change (not require SSL)24 ssl = no25 26 [root@linuxprobe ~]# systemctl start dovecot27 [root@linuxprobe ~]# systemctl enable dovecot
View Code

     [3] 如果Firewalld正在运行,请允许POP / IMAP服务。 POP使用110 / TCP,IMAP使用143 / TCP.

1 [root@vdevops ~]# firewall-cmd --add-port={
110/tcp,143/tcp} --permanent2 success3 [root@vdevops ~]# firewall-cmd --reload4 success
View Code

 四、SSL设置

  • 配置SSL以加密连接

      [1] 首先创建证书,传送门:  

      [2] 为SSL配置Postfix和Dovecot。

1 # add to the end 2 smtpd_use_tls = yes 3 smtpd_tls_cert_file = /etc/pki/tls/certs/server.crt 4 smtpd_tls_key_file = /etc/pki/tls/certs/server.key 5 smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache 6 [root@linuxprobe ~]# vi /etc/postfix/master.cf 7 # line 26-28: uncomment 8 smtps       inet   n       -       n       -       -       smtpd 9   -o syslog_name=postfix/smtps10   -o smtpd_tls_wrappermode=yes11 [root@linuxprobe ~]# vi /etc/dovecot/conf.d/10-ssl.conf12 # line 8: change13 ssl = yes14 # line 14,15: specify certificates15 ssl_cert = 
View Code

      [3] 如果Firewalld正在运行,请允许SMTPS / POP3S / IMAPS服务。 SMTPS使用465 / TCP,POP3S使用995 / TCP,IMAPS使用993 / TCP。

1 [root@vdevops ~]# firewall-cmd --add-service={pop3s,imaps} --permanent2 success3 [root@vdevops ~]# firewall-cmd --add-port=465/tcp --permanent4 success5 [root@vdevops ~]# firewall-cmd --reload6 success
View Code

邮件日志报告:pflogsumm

  • 安装pflogsumm这是Postfix日志报告工具

      [1] 安装postfix-perl-scripts包。

1 [root@linuxprobe ~]# yum -y install postfix-perl-scripts  2 # generate log summary for yesterday  3 [root@linuxprobe ~]# perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog  4 Postfix log summaries for Jul 14  5 Grand Totals  6 ------------  7 messages  8       2   received  9       5   delivered 10       0   forwarded 11       0   deferred 12       0   bounced 13       0   rejected (0%) 14       0   reject warnings 15       0   held 16       0   discarded (0%) 17  18    2879   bytes received 19    6572   bytes delivered 20       1   senders 21       1   sending hosts/domains 22       2   recipients 23       2   recipient hosts/domains 24 Per-Hour Traffic Summary 25 ------------------------ 26     time          received  delivered   deferred    bounced     rejected 27     -------------------------------------------------------------------- 28     0000-0100           0          0          0          0          0 29     0100-0200           0          0          0          0          0 30     0200-0300           0          0          0          0          0 31     0300-0400           0          0          0          0          0 32     0400-0500           0          0          0          0          0 33     0500-0600           0          0          0          0          0 34     0600-0700           0          0          0          0          0 35     0700-0800           0          0          0          0          0 36     0800-0900           0          0          0          0          0 37     0900-1000           0          0          0          0          0 38     1000-1100           2          5          0          0          0 39     1100-1200           0          0          0          0          0 40     1200-1300           0          0          0          0          0 41     1300-1400           0          0          0          0          0 42     1400-1500           0          0          0          0          0 43     1500-1600           0          0          0          0          0 44     1600-1700           0          0          0          0          0 45     1700-1800           0          0          0          0          0 46     1800-1900           0          0          0          0          0 47     1900-2000           0          0          0          0          0 48     2000-2100           0          0          0          0          0 49     2100-2200           0          0          0          0          0 50     2200-2300           0          0          0          0          0 51     2300-2400           0          0          0          0          0 52  53 Host/Domain Summary: Message Delivery 54 -------------------------------------- 55  sent cnt  bytes   defers   avg dly max dly host/domain 56  -------- -------  -------  ------- ------- ----------- 57       3     4119        0     0.4 s    0.8 s  srv.world 58       2     2453        0     0.1 s    0.1 s  mail.srv.world 59  60 Host/Domain Summary: Messages Received 61 --------------------------------------- 62  msg cnt   bytes   host/domain 63  -------- -------  ----------- 64       2     2879   mail.srv.world 65  66 Senders by message count 67 ------------------------ 68       2   cent@mail.srv.world 69  70 Recipients by message count 71 --------------------------- 72       3   redhat@srv.world 73       2   cent@mail.srv.world 74  75 Senders by message size 76 ----------------------- 77    2879   cent@mail.srv.world 78  79 Recipients by message size 80 -------------------------- 81    4119   redhat@srv.world 82    2453   cent@mail.srv.world 83  84 message deferral detail: none 85 message bounce detail (by relay): none 86 message reject detail: none 87 message reject warning detail: none 88 message hold detail: none 89 message discard detail: none 90 smtp delivery failures: none 91 Warnings 92 -------- 93   tlsmgr (total: 6) 94          3   redirecting the request to postfix-owned data_directory /var/li... 95          3   request to update table btree:/etc/postfix/smtpd_scache in non-... 96  97 Fatal Errors: none 98 Panics: none 99 Master daemon messages100 ----------------------101       4   daemon started -- version 2.10.1, configuration /etc/postfix102       3   terminating on signal 15103       1   reload -- version 2.10.1, configuration /etc/postfix104 105 [root@linuxprobe ~]# crontab -e106 # 发送邮件日志摘要在AM每天1:00到根107 00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Logwatch for  Postfix' root
View Code

 

转载于:https://www.cnblogs.com/skyliao/p/8794669.html

你可能感兴趣的文章
Hyper-V虚拟机上安装一个图形界面的Linux系统
查看>>
微信小程序之随笔
查看>>
每秒处理10万高并发订单的乐视集团支付系统架构分享
查看>>
Lua_02
查看>>
ios蓝牙详解
查看>>
安装MySQL5.7.18遇到的坑
查看>>
React Native在Android平台运行gif的解决方法转载
查看>>
Mybatis RowBounds 是逻辑分页
查看>>
Nginx缩略图和Fastdfs整合以及image_filter配置,7点经验结论和5个参考资料
查看>>
hdu 3341(ac自动机+状态压缩)
查看>>
hdu 1565(状态压缩基础题)
查看>>
51单片机之蓝牙遥控小车_效果展示+单片机知识+完整蓝牙电车代码
查看>>
使用WNMP时报的错
查看>>
扩展Django内置的auth模块代码示例
查看>>
Sql Server中REPLACE函数的使用
查看>>
hdu 5614
查看>>
SqlServerl的行转列
查看>>
《信息安全系统设计基础》第三周问题总结
查看>>
nextInt()和nextLine()一起使用时的注意点
查看>>
java如何获取一个对象的大小【转】
查看>>