Centos7使用sendmail发送邮件

实验环境

系统版本:centos7x3.10.0-514.el7.x86_64

sendmail:sendmail.x86_64 0:8.14.7-5.el7

mailx版本:mailx.x86_64 0:12.5-19.el7

一、安装

1、安装sendmail yum -y install sendmail

Centos7使用sendmail发送邮件
Centos7使用sendmail发送邮件

2、安装mailx yum -y install mailx

Centos7使用sendmail发送邮件
Centos7使用sendmail发送邮件

二、测试

1、通过文件内容发送

1)创建报警文件 vi test.txt
Centos7使用sendmail发送邮件

2)发送测试邮件 mail -s '主题' 邮箱 < test.txt
Centos7使用sendmail发送邮件
注:文件需要提前创建,内容就是报警提示,必须是文件的绝对路径!

3)查看邮箱是否收到测试邮件
Centos7使用sendmail发送邮件

2、通过管道符直接发送

1)echo '报警提示' | mail -s '主题' 邮箱
Centos7使用sendmail发送邮件

2)查看邮箱是否收到测试邮件
Centos7使用sendmail发送邮件

猜你喜欢

转载自blog.51cto.com/13043516/2139030