Centos7配置163郵件服務併發送郵件

 

0.環境準備

修改hosts文件

127.0.0.1 localhost.localdomain localhost 主機名

127.0.0.1 主機名

 

1.需要用到的軟件包:sendmail,mailx

兩者直接用yum安裝即可

    

yum -y install sendmail mailx
yum -y install postfix

 

2.開啓163郵箱smtp服務,設置授權碼

 

3.配置mailx配置文件,直接在尾部加入配置

vi /eta/mail.rc

set [email protected]    #設置發件人,這個可以隨意填寫,建議和郵箱一致

set smtp=smtps://smtp.163.com:465    

set [email protected]    #設置郵箱

set smtp-auth-password=xxx        #設置授權碼

set smtp-auth=login                    

set nss-config-dir=/root/.certs/

set ssl-verify=ignore

 

4.配置證書

mkdir -p /root/.certs/

echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt

certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt

certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt

certutil -L -d /root/.certs

cd /root/.certs/

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt

返回如下提示即可:

Notice: Trust flag u is set automatically if the private key is present.

 

5.啓動服務,發送郵件

systemctl start sendmail

echo 內容 | mailx -s '標題' 接收人郵箱

 

注意!!

mailx -v 選項可以查看執行過程,對排錯很有用!
 

發佈了8 篇原創文章 · 獲贊 20 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章