1. 程式人生 > >阿里雲伺服器上用465埠傳送郵件

阿里雲伺服器上用465埠傳送郵件

第一步:安裝mailx郵箱伺服器

yum -y install mailx

第二步:在mailx配置檔案裡新增使用者名稱,密碼。mailx的配置檔案是/etc/mail.rc這個檔案。

set ssl-verify=ignore                                ###   啟用證書
set nss-config-dir=/root/.certs                      ###   證書存放的位置
set from="[email protected]"                      ###   郵箱
set smtp="
smtps://smtp.163.com:465" ### 郵箱伺服器地址 set [email protected]163.com ### 郵箱 set smtp-auth-password=xxxxxxxxxxxxxx ### 郵箱授權碼(不是郵箱登入密碼,不知道的話自己上去開通)set smpt-auth=login ### 啟用自動連線登入,就是傳送郵件的時候自動連線到163伺服器幫你傳送郵件

第三步:既然要用到證書,那我們還得在163的伺服器上申請一個證書。。證書名字自己定義(我這裡命令為163.crt

mkdir -p /root/.certs/                                        ###    證書存放位置
cd /root/.certs
###下面這幾條命令每一條我也不是太明白,我只知道生成了證書和證書檔案,和啟用的證書!
echo -n |openssl s_client -connect smtp.163.com:465 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >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
certutil -L -d /root/.certs

這樣就可以通過465的郵箱傳送郵件了!!下面我們就來驗證一下是否能傳送郵件吧!

echo "郵件正文" | mail -s "這是真的可以傳送郵件了哦" [email protected]