阿里云服务器发送邮件(二)

版权声明:可以转载,请注明链接出处 https://blog.csdn.net/xihuanyuye/article/details/82584955

一、配置邮件服务器
邮件发送是通过软件将邮件发送到邮件服务器,再通过邮件服务器推送到目的邮箱,因此需要在自己的邮箱做相关的设置。请读者自行搜索相关参考资料。
这里采用的是126邮箱。
126邮箱发送 邮件配置
二、mailx配置
发送服务器的参数要在这里提前配置好
1、SSL(阿里云用的)
生成证书

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

说明:本机器最初没有certutil命令,可以进行相关包的安装
修改配置文件
在/etc/mail.rc配置文件中,在最后面输入以下内容

set from=xxxooo@126.com
set smtp=smtps://smtp.126.com:465
set smtp-auth-user=xxxooo@126.com
set smtp-auth-password=邮箱设置的授权码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs

发送测试邮件
echo “mail main content” | mail -s “theme” [email protected]
2、没有禁用25端口时
这时候就不需要相关证书的配置了
修改配置文件

非云主机

set from="[email protected]"
set smtp=smtp.126.com
set smtp-auth-user=xxx
set smtp-auth-password=邮箱设置的授权码

云主机

set from=xxxx@qq.com   qq邮箱或者其他邮箱
set smtp=smtp.qq.com   smtp地址  
set smtp-auth-user=xxx@qq.com                                  
set smtp-auth-password=邮箱设置的授权码
set smtp-auth=login

具体云主机和非云主机的区别暂未探究
参考文献
centos7 利用mailx发送邮件

猜你喜欢

转载自blog.csdn.net/xihuanyuye/article/details/82584955
今日推荐