搭建邮件服务器,在foxmail上使用xiaoming@example.com给wuneng@ceshi.com用户发一封邮件,内容为biechile。
1.首先装包
[root@localhost ~]# yum install postfix -y
[root@localhost ~]# yum install dovecot -y
[root@localhost ~]# yum install mailx -y
[root@localhost ~]# yum install cyrus-sasl* -y
2.然后配置文件
[root@localhost ~]# vim /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination =
m
y
h
o
s
t
n
a
m
e
,
l
o
c
a
l
h
o
s
t
.
myhostname, localhost.
myhostname,localhost.mydomain, localhost, $mydomain
mynetworks = 127.0.0.0/8,192.168.136.0/24
relay_domains = $mydestination
broken_sasl_auth_clients=yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
[root@localhost ~]# vim /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp submission
login_trusted_networks =192.168.136.0/24
[root@localhost ~]# vim /etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u
3.然后关闭防火墙,selinux,启动服务
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart postfix
[root@localhost ~]# systemctl restart dovecot
[root@localhost ~]# systemctl restart saslauthd
4.添加用户xiaoming并修改权限
[root@localhost ~]# useradd xiaoming
[root@localhost ~]# passwd xiaoming
[root@localhost ~]# chmod 600 /var/spool/mail/*
5.又在另一台虚拟机上添加相同的服务,不需要添加认证
6.添加用户wuneng并修改权限
[root@client ~]# useradd wuneng
[root@client ~]# passwd wuneng
[root@client ~]# chmod 600 /var/spool/mail/*
7.然后进行dns配置
先装包
[root@client ~]# yum -y install bind
[root@client named]# yum -y install bind-utlis
编辑dns配置
[root@client ~]# vim /etc/named.conf
options {
directory “/var/named”;
};
zone "ceshi.com" IN {
type master;
file "ceshi.named";
};
zone “example.com” IN {
type master;
file “example.named”;
};
启动服务
[root@client named]# systemctl restart named
在两台主机上添加域名解析
[root@client ~]# vim /etc/resolv.conf
nameserver 192.168.136.144
[root@localhost ~]# vim /etc/resolv.conf
nameserver 192.168.136.144
然后打开Foxmail测试,添加账号信息后发送邮件测试