安裝mailx
[root@db ~]# yum install -y mailx [root@db ~]# vim /etc/mail.rc 設置發件人信息 ..... set from=yunwei@163.com set smtp=smtps://smtp.163.com:465 set smtp-auth-user=yunwei@163.com set smtp-auth-password=*** set smtp-auth=login set ssl-verify=ignore set nss-config-dir=/root/.certs set smtp=smtps:設置發送郵件的服務器端口,如果是企業郵箱加上exmail set smtp-auth-password:設置網易郵箱授權密碼 set ssl-verify:忽略ssl檢查 set nss-config-dir:指定證書所在的目錄
申請證書
[root@db ~]# mkdir .certs 向163郵箱申請證書 [root@db ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > .certs/163.crt [root@db ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt [root@db ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt 列出目錄下的證書 [root@db ~]# certutil -L -d ~/.certs/ [root@db ~]# cd .certs/ 標記證書 [root@db .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt
發送郵件
[root@db ~]# echo "test" | mail -s 'test' yunwei@163.com