配置本地邮件服务需求:
这些系统不接受外部发送来的邮件;
本地发送的任何邮件都会自动路由到 mail.group8.example.com;
在这些系统上发送的邮件显示来自于 server.group8.example.com;
system1 | 192.168.1.151 |
system2 | 192.168.1.152 |
os | rhel 7.2 |
[root@system1 ~]# systemctl status postfix #查看Postfix状态
postfix.service -Postfix Mail Transport Agent
Loaded: loaded(/usr/lib/systemd/system/postfix.service; enabled)
Active: active (running) since Tue2017-01-24 14:08:33 CST; 2 weeks 5 days ago
[root@system1 ~]# postconf -e"inet_interfaces = loopback-only" #修改配置文件,邮件只本地接受
[root@system1 ~]# postconf -e "mydestination = " #发送出去邮件的其他目的地都为空
[root@system1 ~]# postconf -e "local_transport = error: localonly" #只本地传输,并定义报错信息
[root@system1 ~]# postconf -e "relayhost =[mail.group8.example.com]" #本地发送的邮件自动路由到mail,group8.example.com
[root@system1 ~]# postconf -e "myorigin =server.group8.example.com" #设置显示的邮件来源
[root@system1 ~]# systemctl restart postfix #重新启动邮件服务
[root@system1 ~]# echo "hello" | mail -s "hellosystem1" dave #发送测试邮件,邮件标题是hello system1,内容是hello,发送给本地用户dave
[root@system1 ~]# curl http://server.group8.example.com/pub/received_mail/8 #查看邮件,完成之后记得在system2上做相同配置
Fromroot@server.group8.example.com Mon Feb13 11:36:38 2017
Return-Path:<root@server.group8.example.com>
X-Original-To:dave@server.group8.example.com
Delivered-To:dave@server.group8.example.com
Received: fromsystem1.group8.example.com (system1.group8.example.com [172.24.8.11])
by server.group8.example.com (Postfix)with ESMTP id 0D9783089EFB
for<dave@server.group8.example.com>; Mon, 13 Feb 2017 11:36:37 +0800 (CST)
Received: bysystem1.group8.example.com (Postfix, from userid 0)
id 3481822ED50F; Mon, 13 Feb 201711:36:36 +0800 (CST)
Date: Mon, 13 Feb2017 11:36:36 +0800
To:dave@server.group8.example.com
Subject: hellosystem1
User-Agent: Heirloommailx 12.5 7/5/10
MIME-Version: 1.0
Content-Type:text/plain; charset=us-ascii
Content-Transfer-Encoding:7bit
Message-Id:<20170213033637.3481822ED50F@system1.group8.example.com>
From:root@server.group8.example.com (root)
hello