快速部署postfix邮件服务器


• 装包、配置、起服务
– 默认的标准配置即可为本机提供发/收邮件服务
– 若有必要,可扩大服务范围(邮件域)

前提:邮件服务器,必须为手工配置永久主机名
虚拟机server0
[root@server0 ~]# echo server0.example.com > /etc/hostname
[root@server0 ~]# cat /etc/hostname

虚拟机desktop0
[root@desktop0 ~]# echo desktop0.example.com > /etc/hostname
[root@desktop0 ~]# cat /etc/hostname


虚拟机server0:
1.装包
[root@server0 ~]# rpm -q postfix
postfix-2.10.1-6.el7.x86_64

2.修改配置文件
[root@server0 ~]# vim /etc/postfix/main.cf
99行 myorigin = server0.example.com #默认补全的域名结尾
116行 inet_interfaces = all #监听所有网络接口
164行 mydestination = server0.example.com #符合的判定为本域邮件

3.重起postfix
[root@server0 ~]# systemctl restart postfix

4.测试:
[root@server0 ~]# useradd yg
[root@server0 ~]# useradd xln
[root@server0 ~]# mail -s test01 -r yg xln
AAAAAAAAAAAAAAA
.
EOT
[root@server0 ~]# mail -u xln


• mail 发信操作
– mail -s '邮件标题' -r 发件人@邮件域名 收件人@邮件域名
• mail 收信操作
– mail [-u 用户名]

空客户端邮件服务器

• nullclient,空客户端
– 不提供任何邮箱账号,因此不需要投递邮件
– 但是可以为用户代发邮件

虚拟机desktop0:
[root@desktop0 ~]# lab smtp-nullclient setup #搭建邮件服务器脚本

虚拟机server0:邮件空客户端
1.修改配置文件
[root@server0 ~]# vim /etc/postfix/main.cf
99行 myorigin = desktop0.example.com #默认补全的域名结尾
116行 inet_interfaces = localhost #仅允许本机
164行 mydestination = #修改为空
317行 relayhost = [172.25.0.10] #将邮件交给172.25.0.10

3.重起postfix
[root@server0 ~]# systemctl restart postfix
4.发送邮件
[root@server0 ~]# echo 123 | mail -s test01 -r root student

虚拟机desktop0:[root@desktop0 ~]# mail -u student

猜你喜欢

转载自www.cnblogs.com/wwchihiro/p/9107452.html
今日推荐