Centos7下使用mail发送邮件

首先检测相关服务是否已安装
[root@ProxyServer ~]# rpm -qa|grep mail

libreport-plugin-mailx-2.0.9-19.el6.x86_64

mailx-12.4-7.el6.x86_64

procmail-3.22-25.1.el6.x86_64

mailcap-2.1.31-2.el6.noarch

sendmail-8.14.4-8.el6.x86_64

若服务未安,则执行以下命令进行服务安装
[root@ProxyServer ~]# yum install sendmail

[root@ProxyServer ~]# yum install mailx –y

[root@ProxyServer ~]# yum update libreport-plugin-mailx

[root@ProxyServer ~]# yum -y install sharutils

[root@ProxyServer ~]# yum install mutt

修改配置文件,配置邮件相关内容(追加到配置文件末尾)
[root@ProxyServer ~]# vi /etc/mail.rc

set from=lvyf0802@163.com #之前设置好的邮箱地址

set smtp=smtp.163.com #邮件服务器

set smtp-auth-user=lvyf0802@163.com #之前设置好的邮箱地址

set smtp-auth-password=lvyf0802 #授权码

set smtp-auth=login  #默认login

邮箱开启smtp服务(这里以163邮箱为例)

 

 

 


检测服务是否安装成功
[root@ProxyServer ~]# touch /usr/mail.txt

[root@ProxyServer ~]# mail -s "theme" test@163.com < /usr/mail.txt

//使用上面的命令就可把mail.txt文件的内容发给 test@163.com(-s “theme” 为邮件的主题)

为了防止垃圾邮件泛滥,阿里云服务器已不再开放smtp邮件的25端口,现在需要使用465端口进行smtp邮件发送。
生成密钥
[root@ProxyServer ~]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 163.crt

certutil -L -d /root/.certs

    2.配置密钥(红色代表修改内容)

[root@ProxyServer ~]# vi /etc/mail.rc

set bsdcompat

set from=lvyf0802@163.com #之前设置好的邮箱地址

set smtp=smtps://smtp.163.com #邮件服务器

set smtp-auth-user=lvyf0802@163.com #之前设置好的邮箱地址

set smtp-auth-password=lvyf0802 #授权码

set smtp-auth=login  #默认login

set ssl-verify=ignore #ssl认证方式

set nss-config-dir=/root/.certs #证书所在目录
---------------------
作者:万一起飞了呢
来源:CSDN
原文:https://blog.csdn.net/lyf844692713/article/details/81479066
版权声明:本文为博主原创文章,转载请附上博文链接!

转载于:https://www.cnblogs.com/xy51/p/10905652.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值