centos mail命令 发送邮件

首先安装相关环境

yum -y install mailx
yum -y install sendmail
输入 /etc/init.d/sendmail start
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]

查看mail指令的详细信息

mail --help

测试mail命令

mail -s 'Test mail' [email protected] < /etc/test.txt

把test.txt的内容当做输入内容发送到目标邮箱里 标题是Test mail

1、通过文件内容发送邮件

mail -s 'Test mail' [email protected] < /etc/passwd

2、使用管道符直接发送邮件内容

echo "This is test mail" | mail -s 'Test mail' [email protected]

mail指令不仅可以发送文本格式的邮件,也可以发送HTML格式的邮件

猜你喜欢

转载自blog.csdn.net/q295657451/article/details/81004059