首先介绍下sendMail
About SendEmail
SendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to learn and use.
[Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]
http://caspian.dotconf.net/menu/Software/SendEmail/
下载解压后就能使用命令行工具了。或者:
安装方法:
1) Extract the package
tar -zxvf sendEmail-v1.XX.tar.gz
2) Copy the sendEmail script to /usr/local/bin
cp -a sendEmail-v1.XX/sendEmail /usr/local/bin
3) Make sure its executable
chmod +x /usr/local/bin/sendEmail
4) Run it
sendEmail
or
/usr/local/bin/sendEmail
部分参数如下:
-f 表示from,发件人地址
-t 表示to,收件人地址
-s mail服务器域名
-u 主题
-xu 用户名(@之前的)
-xp 用户密码
-m 纯文本信息
-o message-file=/root/.. 发送文件中的内容
-a 发送附件 (-m,-o,-a可以同时使用)
例如:
[root@blog sendEmail-v1.56]# ./sendEmail -f aaaa@163.com -t bbbb@163.com -s smtp.163.com -xu aaaa -xp password -u test -m testeamil
Apr 10 10:09:16 blog sendEmail[8861]: Email was sent successfully!
问题:
1·如果出现如下提示
Jan 30 10:06:15 ora01 sendEmail[8704]: ERROR => Connection attempt to localhost:25 failed: IO::Socket::INET: connect: Connection refused
是没有指定-s参数,邮件服务器域名。
shell脚本监测:
http://blog.chinaunix.net/uid-7589639-id-3018209.html
大多数邮件服务都有短信通知服务,比如sina的就有每个月50条免费短信用,对于个人来说,够用了。