posfix郵件服務
準備兩臺虛擬機,均修改防火墻與主機名(可解析)
server0.example.com 172.25.0.11/24
desktop0.example.com 172.25.0.10/24
虛擬機server0:
# firewall-cmd --set-default-zone=trusted
# echo server0.example.com > /etc/hostname
# cat /etc/hostname
虛擬機desktop0:
# firewall-cmd --set-default-zone=trusted
# echo desktop0.example.com > /etc/hostname
# cat /etc/hostname
電子郵件服務器的基本功能
為用戶提供電子郵箱存儲空間(用戶名@郵件域名)
處理用戶發出的郵件 —— 傳遞給收件服務器
處理用戶收到的郵件 —— 投遞到郵箱
用戶發郵件的協議: SMTP 端口25
用戶收郵件的協議: pop3 端口110 IMAP 端口143
##########################################################################################
虛擬機server0
搭建基本郵件服務器
1. 安裝postfix服務端程序
[root@server0 ~]# rpm -q postfix
postfix-2.10.1-6.el7.x86_64
2.配置postfix服務,修改配置文件
[root@server0 ~]# vim /etc/postfix/main.cf
83 mydomain = example.com #主要參數--指定域名 如該服務器的郵件就是*@example.com
116 inet_interfaces = all #主要參數--允許所有客戶端
164 mydestination = example.com #主要參數--判斷郵件後綴只有域名是@example.com的郵件才會被接收到
99 myorigin = example.com #默認補全的郵件後綴 不寫地址發郵件會補上@example.com 不配置該參數且發郵件不寫對域名@example.com 無法收到郵件
76 myhostname = server0.example.com #指定主機名 DNS可解析的郵件服務器域名
3.重起postfix服務,設置為開機自起
# systemctl restart postfix
# systemctl enable postfix
4. 測試郵件的收發
[root@server0 ~]# useradd student
[root@server0 ~]# echo 123 | passwd --stdin student
[root@server0 ~]# useradd test
[root@server0 ~]# echo 123 | passwd --stdin test
mail 發信操作
mail -s ‘郵件標題‘ -r 發件人 收件人
mail 收信操作
mail [-u 用戶名]
[root@server0 ~]# mail -s ‘for test‘ -r test student
一行中只有一個 “.” 的時候,代表結束
[root@server0 ~]# mail -u student #輸入郵件編號 1 查看郵件 quit 退出
##########################################################################################
nullclient郵件服務
空客戶端
nullclient,空客戶端
不提供任何郵箱賬號,因此不需要投遞郵件
但是可以為用戶代發郵件
一、配置desktop為郵件服務器
1.配置postfix服務,修改配置文件
[root@desktop0 ~]# vim /etc/postfix/main.cf
99 myorigin = desktop.example.com
116 inet_interfaces = all
164 mydestination = desktop.example.com
[root@desktop0 ~]# systemctl restart postfix
[root@desktop0 ~]# systemctl enable postfix
二、配置server為空客戶端郵件服務器
[root@server0 ~]# vim /etc/postfix/main.cf
99 myorigin = desktop0.example.com
116 inet_interfaces = localhost
164 mydestination = #不寫相當於不收郵件
317 relayhost = [172.25.0.10] #交給指定郵件服務器IP地址,也就是指定服務器的myhostname的地址 DNS解析出來的IP地址
[root@server ~]# systemctl restart postfix
三、測試
虛擬機server上
# echo ‘for test1‘ | mail -s ‘Test1‘ -r test student
虛擬機desktop上
# mail -u student
posfix郵件服務