yum install -y mailx
vim /etc/mail.rc
set from=bug@zhibo.tv smtp=smtp.exmail.qq.com
set smtp-auth-user=bug@zhibo.tv smtp-auth-password=xxx
set smtp-auth=login
/bin/cat /tmp/tongji.txt|mail -s "即时用户访问统计" 1@zhibo.tv,2@zhibo.tv
配置ssl发送邮件:
mkdir /etc/mail.rc_ssl.crt
cd /etc/mail.rc_ssl.crt
echo -n | openssl s_client -connect mail.xxx.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ./xxx.crt #生成证书文件
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i xxx.crt #导入证书到系统
vim /etc/mail.rc
set from=xxx@xxx.com
set smtp=mail.yonyou.com:465
set smtp-auth-user=xxx@xxx.com
set smtp-auth-password=xxx
set smtp-auth=login
set nss-config-dir=/etc/mail.rc_ssl.crt
set ssl-verify=ignore
mail命令:
mail -s 'xxx' #指定主题
mail > xx.txt #正文以文件内容发送
mail -a xx.txt #发送附件