生活随笔
收集整理的這篇文章主要介紹了
云服务器如何发送邮件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在共有云上目前都是封鎖25端口的,也就是說想要在服務器上搭建SMTP是不可能的,除非申請解封25端口。 但是一般情況為了方便使用,可以直接選擇第三方的SMTP服務器,如163,qq等等,省去自建的麻煩。
操作如下:
進入云服務器,檢測是否安裝mailx,如果沒有則自行安裝。
[ root@VM-0-2-centos .certs
]
libreport-plugin-mailx-2.1.11-53.el7.centos.x86_64
mailx-12.5-19.el7.x86_64
這里我使用的是163郵箱的SMTP服務,進入配置文件,在最后寫入配置
set from
= xxxxxxx@163.com
set smtp
= smtps://smtp.163.com:465
set ssl-verify
= ignore
set nss-config-dir
= /root/.certs
set smtp-auth-user
= xxxxxx@163.com
set smtp-auth-password
= xxxxxx
set smtp-auth
= login
163郵箱的授權碼獲取方式
獲取證書
mkdir -p /root/.certs/
cd /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 -A -n “GeoTrust SSL CA - G3” -t “Pu,Pu,Pu” -d ~/.certs/./ -i 163.crt
chmod 777 * /root/.certs
[ root@VM-0-2-centos .certs
]
total 64
-rwxrwxrwx 1 root root 2415 Jan 27 14:01 163.crt
-rwxrwxrwx 1 root root 65536 Jan 27 13:54 cert8.db
-rwxrwxrwx 1 root root 16384 Jan 27 13:54 key3.db
-rwxrwxrwx 1 root root 16384 Jan 27 13:54 secmod.dbcertutil -L -d /root/.certs
測試郵件發送
echo "456" | mail -s
"test" XXXX@qq.com
如果發送未收到,檢查證書獲取是否有問題,重新獲取嘗試。
如果出現報錯如:Error in certificate: Peer’s certificate issuer is not recognized. 再執行一次 “certutil -A -n “GeoTrust SSL CA - G3” -t “Pu,Pu,Pu” -d ./ -i 163.crt”
如果發送郵件被扔到垃圾箱或還是無法收到,可以在收件人郵箱添加白名單測試。
總結
以上是生活随笔 為你收集整理的云服务器如何发送邮件 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。