共计 1309 个字符,预计需要花费 4 分钟才能阅读完成。
导读 | postfix 是一个流行的 smtp 服务器。smtp 服务器默认端口是 25(不采用 ssl/tls 加密的情况)。下面介绍如何在 CentOS6 上安装 postfix。 |
1 . CentOS6 默认安装了 postfix. 如果系统没有 postfix, 可以用以下命令安装。
[root@mail ~]# yum -y install postfix
2 . 配置 postfix 的 main.cf,配置 smtp-auth 采用 dovecot 的 sasl 功能。
[root@mail ~]# vi /etc/postfix/main.cf | |
# 第 75 行: 去掉注释,并设置主机名。myhostname = mail.opsky.top | |
# 第 83 行: 去掉注释,并设置域名。mydomain = opsky.top | |
# 第 99 行: 去掉注释。myorigin = $mydomain | |
# 第 116 行: | |
inet_interfaces = all | |
# 第 119 行: 如果只使用 ipv4,那么设置如下。inet_protocols = ipv4 | |
# 第 164 行: 配置可接收邮件的域名。mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain | |
# 第 264 行: 去掉注释,并设置本地网络号段. | |
mynetworks = 127.0.0.0/8, 10.0.0.0/24 | |
# 第 419 行: 去掉注释,采用 Maildir 格式。home_mailbox = Maildir/ | |
# 第 571 行: | |
smtpd_banner = $myhostname ESMTP | |
# 添加如下配置到文件末尾 | |
# 一封邮件大小限制为 10M | |
message_size_limit = 10485760 | |
# 一个邮箱大小限制为 1G | |
mailbox_size_limit = 1073741824 | |
# 配置 SMTP-Auth 采用 dovecot 的 sasl 功能 | |
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 | |
main.cf 配置完毕后,启动 postfix,并设置自动启动。[root@mail ~]# /etc/rc.d/init.d/postfix start | |
Starting postfix: [OK] | |
[root@mail ~]# chkconfig postfix on |
3 . 如果 iptables 在开启状态,那么设置 iptables 开放 smtp 的 25 端口。
[root@dlp ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
正文完
星哥玩云-微信公众号
