Linux下通过mail命令发送邮件

Linux下可以通过使用mail命令,利用外部的一个邮箱(比如xxx.163.com)发送邮件到另外一个邮箱(比如yyy.qq.com),这在某些情况下很有用,比如监测系统温度,当温度达到一定时就报警,向邮箱发送报警信息,提示管理员网络异常等。

Linux下通过mail命令发送邮件插图 image-20211130120943510

找到配置文件/etc/mail.rc添加如下行

# vi /etc/mail.rc  
set [email protected]
set smtp=smtp.qq.com  
set smtp-auth-user=123456
set smtp-auth-password=sbsbsbsb
set smtp-auth=login

通过以下命令发送邮件

echo  hello word | mail -s " title" [email protected] [email protected]

多个邮件地址使用空格分开

THE END