Centos7下使用mail发送邮件
[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 [email protected] #之前设置好的邮箱地址
set smtp=smtp.163.com #邮件服务器
set [email protected] #之前设置好的邮箱地址
set smtp-auth-password=lvyf0802 #授权码
set smtp-auth=login #默认login
[root@ProxyServer ~]# touch /usr/mail.txt
[root@ProxyServer ~]# mail -s "theme" [email protected] < /usr/mail.txt
//使用上面的命令就可把mail.txt文件的内容发给 [email protected](-s “theme” 为邮件的主题)
[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 [email protected] #之前设置好的邮箱地址
set smtp=smtps://smtp.163.com #邮件服务器
set [email protected] #之前设置好的邮箱地址
set smtp-auth-password=lvyf0802 #授权码
set smtp-auth=login #默认login
set ssl-verify=ignore #ssl认证方式
set nss-config-dir=/root/.certs #证书所在目录