运维的同事需要一个预警的小程序,通过查找shell可以发邮件,过程如下:
首先在/etc/mail.rc里配置(有些系统使用/etc/nail.rc文件)发邮件的相关信息
set from=**@163.com
set smtp=smtp://smtp.163.com:25
set smtp-auth-user=***
set smtp-auth-password=***
在shell脚本里面
echo alarm |mailx -s "文本内容" *****@139.com
即可发送到邮箱,另外由于每个移动的手机号都有一个对应的邮箱地址,发送邮件到邮箱,手机也可接收到相关信息。
首先在/etc/mail.rc里配置(有些系统使用/etc/nail.rc文件)发邮件的相关信息
set from=**@163.com
set smtp=smtp://smtp.163.com:25
set smtp-auth-user=***
set smtp-auth-password=***
在shell脚本里面
echo alarm |mailx -s "文本内容" *****@139.com
即可发送到邮箱,另外由于每个移动的手机号都有一个对应的邮箱地址,发送邮件到邮箱,手机也可接收到相关信息。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28686045/viewspace-1436524/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28686045/viewspace-1436524/