(1)CentOS 7版本默认安装Postfix,检测是否安装Postfix:
#rpm -q postfix
如果没有安装,输入如下命令:
- List item
yum -y install postfix
(2)检查Postfix是否支持cyrus dovecot功能:
#postconf -a
cyrus
Dovecot
(3)编辑Postfix的配置文件,查找并修改对应配置项:
#vi /etc/postfix/main.cf
myhostname = mail.testmail.com //本机主机名
mydomain = testmail.com //服务器域名
myorigin = $mydomain //初始域名
mail_owner = postfix
inet_interfaces = all //监听接口
inet_protocols = all //监听网络版本
mydestination = myhostname,localhost.myhostname, localhost.myhostname,localhost.mydomain, localhost //目标域
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.100.0/24, 127.0.0.0/8 //修改可接收邮件的主机名和域名,可被中继的主机192.168.100.0为我自己定义的网段
home_mailbox = Maildir/ //邮件目录,在用户家目录下
mynetworks_style = host //指定信任网段类型
relay_domains = $mydestination //指定允许中转邮件的域名
(4)检查配置文件是否有语法错误
#postfix check //没有输出错误,证明配置文件没有问题
其他Postfix运维命令:
● newaliases:重建别名数据库。
● postalias /etc/postfix/aliases:创建或查询别名数据库。
● postcat:显示队列文件内容。
● postconf:修改main.cf配置文档。
● postqueue:査看postfix队列。
● postsuper:管理员管理postfix队列。
● postmap:创建查询表的DB数据库或查询查询表内容。
(5)重启服务:
#systemctl restart postfix
(6)检测服务进程以及端口是否正常:
#netstat -lntp | grep 25
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 10405/master
tcp6 0 0 ::1:25 ::: * LISTEN 10405/master
#ps -ef | grep postfix | grep -v grep
root 10405 1 0 11:13 ? 00:00:00 /usr/libexec/postfix/master -w
postfix 10406 10405 0 11:13 ? 00:00:00 pickup -l -t unix -u
postfix 10407 10405 0 11:13 ? 00:00:00 qmgr -l -t unix -u