Centos7下使用mail发送邮件配置

  参考文档:https://blog.csdn.net/lyf844692713/article/details/81479066

  安装环境查看

  查看服务是否安装

rpm -qa|grep mail

  如果未安装则安装

yum -y install sendmail mailx libreport-plugin-mailx sharutils mutt

  修改配置文件/etc/mail.rc在尾部添加

set [email protected] #之前设置好的邮箱地址
set smtp=smtp.exmail.qq.com #邮件服务器
set [email protected] #之前设置好的邮箱地址
set smtp-auth-password=xxxxxxxx #授权码及密码
set smtp-auth=login  #默认login

  这里使用的邮箱客户端为腾讯企业邮箱,配置信息查看如下

  发送测试邮件

mail -s "theme" [email protected] < /etc/hosts

  -s 邮件主题为theme 

  [email protected]为需要发送的邮箱

  /etc/hosts为需要发送的内容,会把该文件的内容作为邮件内容发送

  发送附件测试

echo "test3"|mail -s "test" -a /etc/hosts [email protected]

  -a添加附件 

  后面可以接多个邮箱群发,邮箱间以空格分割

猜你喜欢

转载自www.cnblogs.com/minseo/p/10271220.html