Linux Centos配置邮件发送
这里使用的是外部发送邮件方式,也就是使用自己的账号发送
第一步
首先要开启STMP授权码,以QQ邮箱为例

配置文件
sh
vim /etc/mail.rc
找到之后在最下面添加如下
#邮箱
set [email protected]
#默认smtp发送,stmp发送需要在邮箱内配置,允许stmp发送
set smtp=smtp.qq.com
#邮箱
set [email protected]
#邮箱授权码
set smtp-auth-password=xkhqkjleqxewchhd
set smtp-auth=login
发送邮件-不带附件
sh
# 方式一
echo "This is the mail body" | mail -s "邮件标题" [email protected]
# 方式二,将文本内容放入邮件body中
mail -s "邮件标题" [email protected] < /etc/passwd
发送邮件-带附件
sh
mail -s "This is the mail body" -a /home/ttt.txt [email protected] < /etc/passwd