$ yum install mailx
配置:
$ vim /etc/mailx.rc #在结尾追加配置
set [email protected] #发送服务器
set smtp=smtps://smtp.163.com:465 #smtp服务器地址,如果不使用ssl方式,可写成:set smtp=smtp.qq.com:25
set [email protected] #发送者邮件名称
set smtp-auth-password=************** #密码,非邮箱登陆密码
set smtp-auth=login #发送邮件时的登陆方式
set ssl-verify=ignore #启用ssl,如果不使用ssl,则注释当前及最后一行配置即可
set nss-config-dir=/root/.certs #证书配置路径,普通用户需要有访问权限才能发送邮件
配置ssl生成证书:
$ 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 ~/.certs/163.crt
$ certutil -L -d /root/.certs
测试效果:
$ echo "正文" | mail -s ‘标题‘ [email protected]
原文:https://www.cnblogs.com/cx558/p/12009075.html