linux命令 - 如何使用shell脚本向管理员发送通知电子邮件

时间:2016-12-28 16:10:02

标签: linux

如何使用shell脚本向Linux发送通知电子邮件给管理员 关于监视在运行时给出的给定站点/机器,如果任何站点/机器没有响应,则通过电子邮件通知管理员

1 个答案:

答案 0 :(得分:1)

在Linux中向管理员发送通知电子邮件(我假设:本地root帐户):

echo "simple ascii only message here" | mail -s "subject line" root

cat notification_file | mail -s "subject line"  root
#note: notification_file's content will be the "body" of your email. Not an attachment.
#It should contain only regular ASCII characters... ie, basically:
#  letters, numbers, punctuations, newlines, tabs, spaces.
#Anything else could be tricky. If you need more (unicode? attachments?),
#you should use a variant (ex: mutt ?) instead of the basic "mail" command

如果您指的是外部邮件,对于工作/个人电子邮件,您需要阅读一些有关邮件系统如何工作的信息,因为默认情况下它无法以正确的方式访问正确的smtp服务器。 ..