centos7利用mailx发送邮件

1.安装mailx

yum install mailx -y

2.修改配置文件/etc/mail.rc,可以使用外部SMTP服务器

set from=xxxooo@aliyun.com
set smtp=smtps://smtp.mxhichina.com:465
set smtp-auth-user=xxxooo@aliyun.com
set smtp-auth-password=你的密码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs #/etc/pki/nssdb/

3、证书配置

mkdir -p /root/.certs/
echo -n | openssl s_client -connect smtp.mxhichina.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/mxhichina.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/mxhichina.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/mxhichina.crt
certutil -L -d /root/.certs

进入存放证书的目录,执行

cd  /root/.certs
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i mxhichina.crt

4、使用三种方式发送邮件
命令行: mail -s “theme” addressee,回车后输入内容按Ctrl+D发送邮件.
管道符: echo “mail main content” | mail -s “theme” addressee
文件内容作为邮件内容: mail -s “theme” addressee < /tmp/t.txt

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部