一、配置發件服務器
1.1 根據現場IP,配置主機名
vi /etc/hosts
192.168.40.133 mail.test.com
將主機名更改為郵件服務器域名mail.test.com
1.2 關閉防火牆,禁止開機啟動
systemctl stop firewalld
systemctl disable firewalld
1.3 關閉selinux
vi /etc/selinux/config
將未注釋的SELINUX值改為disabled
1.4 安裝/配置postfix服務器
(1)檢查系統是否已經安裝了postfix服務器
rpm -q postfix
(2) 如果沒有就安裝,安裝了就跳過
yum -y install postfix
(3) 編輯postfix的配置文件,查找並修改對應配置項
vi /etc/postfix/main.cf
在文件最后添加如下內容
myhostname = mail.test.com
mydomain = test.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, $mydomain
home_mailbox = Maildir/
mynetworks = 0.0.0.0,127.0.0.0/8,60.60.60.0/24 // 網絡權限(根據現場IP配置,粘貼進去的時候去掉//后面的所有內容)
(4) 檢查配置文件是否有語法錯誤
postfix check
(5) 重新啟動postfix服務器
systemctl restart postfix
1.5 發件測試
(1) 添加郵件賬號組
groupadd mailusers
(2)添加郵箱賬號
useradd -g mailusers -s /sbin/nologin dkycs
passwd dkycs
useradd -g mailusers -s /sbin/nologin dfc
passwd dfc
(3) 安裝遠程登錄插件
yum install -y telnet
(4) 遠程登錄25端口,如報錯連接不上,重啟postfix
telnet mail.test.com 25
(確認現場25端口是否開放)
(5)測試郵件發送
[root@localhost new]# telnet mail.test.com 25 //
Trying 192.168.40.133...
Connected to mail.test.com.
Escape character is '^]'.
220 mail.test.com ESMTP Postfix
#顯示上面 表示telnet連接成功
mail from:<shaokang@test.com>
#郵件發送者
250 2.1.0 Ok
rcpt to:dfc@test.com
#郵件接收者
250 2.1.5 Ok
data
#data加回車開始編寫郵件
354 End data with <CR><LF>.<CR><LF>
Subject:test mail
#郵件主題
hello serva 3D_city_wprl^H
hello serva 3FD
hello 3D!thanks!
#郵件內容
.
#.表示編寫結束 發送郵件
250 2.0.0 Ok: queued as 21C5340F1992
#發送成功
quit
#退出telnet
221 2.0.0 Bye
Connection closed by foreign host.
如果報錯就修改下列文件:
vi /etc/postfix/main.cf
mynetworks = all
systemctl restart postfix
(6)接收查看郵件內容
cd /home/收件人/Maildir/new目錄下,所有新收的郵件都在這個下面:
二、配置收件服務器
2.1 安裝dovecot
yum -y install dovecot
安裝完,查看版本:
dovecot --version
2.2 修改配置文件
(1)執行vi /etc/dovecot/dovecot.conf
修改如下:
protocols = imap pop3
listen = *, ::
login_trusted_networks = 0.0.0.0,127.0.0.0/8,60.60.60.0/24 (根據現場配置填寫)
!include conf.d/*.conf
!include_try local.conf
(2)執行vi /etc/dovecot/conf.d/10-ssl.conf
修改如下:
ssl = no
(3)執行vi /etc/dovecot/conf.d/10-auth.conf
修改如下:
disable_plaintext_auth = no
auth_mechanisms = plain login
!include auth-system.conf.ext
(4)執行vi /etc/dovecot/conf.d/10-logging.conf
修改如下:
info_log_path = /var/log/dovecot_info.log
debug_log_path = /var/log/dovecot_debug.log
(5)執行vi /etc/dovecot/conf.d/10-mail.conf
修改如下:
mail_location = maildir:~/Maildir
2.3 啟動服務
systemctl start dovecot
systemctl enable dovecot
2.3 查看服務狀態
systemctl status dovecot
查看端口:
yum -y install net-tools
netstat -tlnp |grep dovecot
三、配置DNS
安裝:
yum install rng-tools -y
service rngd start
安裝/配置:
yum install bind-utils -y
yum install dnsmasq -y
vi /etc/hosts 添加 127.0.0.1 test.com
vi /etc/dnsmasq.conf
添加 address=/test.com/127.0.0.1, 添加 listen-address=127.0.0.1,192.168.40.133(本機ip)
service dnsmasq start
測試 nslookup
test.com
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: test.com
Address: 60.60.60.42
Name: test.com
Address: 127.0.0.1
四、配置Foxmail客戶端
Foxmail官方下載地址:http://fox.foxmail.com.cn/
賬號配置: