首先檢測相關服務是否已安裝
[root@ProxyServer ~]# rpm -qa|grep mail
libreport-plugin-mailx-2.0.9-19.el6.x86_64
mailx-12.4-7.el6.x86_64
procmail-3.22-25.1.el6.x86_64
mailcap-2.1.31-2.el6.noarch
sendmail-8.14.4-8.el6.x86_64
若服務未安,則執行以下命令進行服務安裝
[root@ProxyServer ~]# yum install sendmail
[root@ProxyServer ~]# yum install mailx –y
[root@ProxyServer ~]# yum update libreport-plugin-mailx
[root@ProxyServer ~]# yum -y install sharutils
[root@ProxyServer ~]# yum install mutt
修改配置文件,配置郵件相關內容(追加到配置文件末尾)
[root@ProxyServer ~]# vi /etc/mail.rc
set from=lvyf0802@163.com #之前設置好的郵箱地址
set smtp=smtp.163.com #郵件服務器
set smtp-auth-user=lvyf0802@163.com #之前設置好的郵箱地址
set smtp-auth-password=lvyf0802 #授權碼
set smtp-auth=login #默認login
郵箱開啟smtp服務(這里以163郵箱為例)
檢測服務是否安裝成功
[root@ProxyServer ~]# touch /usr/mail.txt
[root@ProxyServer ~]# mail -s "theme" test@163.com < /usr/mail.txt
//使用上面的命令就可把mail.txt文件的內容發給 test@163.com(-s “theme” 為郵件的主題)
為了防止垃圾郵件泛濫,阿里雲服務器已不再開放smtp郵件的25端口,現在需要使用465端口進行smtp郵件發送。
生成密鑰
[root@ProxyServer ~]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 -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/./ -i 163.crt
certutil -L -d /root/.certs
2.配置密鑰(紅色代表修改內容)
[root@ProxyServer ~]# vi /etc/mail.rc
set bsdcompat
set from=lvyf0802@163.com #之前設置好的郵箱地址
set smtp=smtps://smtp.163.com #郵件服務器
set smtp-auth-user=lvyf0802@163.com #之前設置好的郵箱地址
set smtp-auth-password=lvyf0802 #授權碼
set smtp-auth=login #默認login
set ssl-verify=ignore #ssl認證方式
set nss-config-dir=/root/.certs #證書所在目錄
---------------------
作者:萬一起飛了呢
來源:CSDN
原文:https://blog.csdn.net/lyf844692713/article/details/81479066
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!