1、安装软件
yum install mailx
yum install sendmail
2、配置
vim /etc/mail.rc在文件最后加上如下内容:
set smtp=smtps://smtp.exmail.qq.com:465 #邮箱服务器地址
set from=xxxx@xxx.com #发送邮件的来源
set smtp-auth-user=xxxx@xxx.com #用户名set smtp-auth-password=xxxx #密码set nss-config-dir=/etc/pki/nssdb/ #证书位置set ssl-verify=ignoreset smtp-auth=login3、配置证书
mkdir -p /etc/pki/nssdb/
cd /etc/pki/nssdb#生成证书echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/pki/nssdb/qq.crt certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt certutil -L -d /etc/pki/nssdb/ certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt #认证
4、测试发送邮件
echo "this email come from centos"|mail -v -s "zabbix" xxx@xxx.com