https://blog.csdn.net/wh211212/article/details/53040620
https://blog.jjonline.cn/linux/185.html
一、首先关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
二、搭建postfix
[root@localhost ~]# yum install postfix
三、配置postfix
[root@localhost ~]# vi /etc/postfix/main.cf
myhostname = mail.test.com # 邮件服务器的主机名
mydomain = test.com # 邮件域
myorigin = $mydomain # 往外发邮件的邮件域
inet_interfaces = 10.0.2.115, 127.0.0.1 # 监听网卡
保存退出
[root@localhost ~]# postfix check # 检查语法错误
[root@localhost ~]# systemctl restart postfix # 重启postfix服务
[root@localhost ~]# postconf -n # 检查非默认的已生效配置
[root@localhost ~]# groupadd mailusers # 添加测试组
[root@localhost ~]# useradd -g mailusers -s /sbin/nologin steven # 添加测试用户
[root@localhost ~]# passwd steven
四、测试
[root@localhost ~]# telnet mail.test.com 25
helo mail.test.com # 声明本机的主机
mail from:steven@test.com # 声明发件人的
rcpt to:mxxx@163.com # 声明收件人的邮箱
data # 声明正文
i am steven # 正文内容
. # 结束正文
quit # 退出