Chinaunix首页 | 论坛 | 博客
  • 博客访问: 282583
  • 博文数量: 87
  • 博客积分: 1206
  • 博客等级: 少尉
  • 技术积分: 725
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-16 00:12
个人简介

do the right things the right ways

文章分类

全部博文(87)

文章存档

2017年(5)

2016年(6)

2015年(1)

2012年(11)

2011年(64)

分类: LINUX

2012-08-10 15:58:49

在linux中,根据工作需要,利用脚本自动发送server的状态到邮箱中,能够很好的追踪server的状态,及时纠正错误。

使用命令,在Ubuntu下安装sendemail,执行以下命令:
【sendemail 的具体用法和参数,请参考 man 信息】
#sendemail -f senduser@foo.com -t receiveuser@foo.com -u 'message subject' -m 'message body' -cc otheruser@foo.com

如果出现以下错误信息
ERROR => Connection attempt to localhost:25 failed: IO::Socket::INET: connect: Connection refused

这说明sendemail不是完整的MTA[报文传输代理],需要安装 nullmailer 或者 postfix,安装完成后就可以成功发送邮件了。

但是由于公司的邮件服务器设置问题,发送到公司邮箱的邮件可能会失败,所以建议使用个人邮箱,例如:163或者是移动的139邮箱,在只能终端上就可以查看这些邮件,十分方便。

但是如果想向Gmail 和 yahoo发送邮件,我试了许多次也没有成功,但是Gmail和yahoo作为发送方是可以成功发出邮件的。若要发送到 Gmail 或 yahoo, 就需要安装 libio-socket-ssl-perl and libnet-ssleay-perl,然后执行如下: 

sendemail -f senduser@foo.com -t receiveruser@foo.com -u 'message subject' -m 'message body' -s yahoo.com:25 -xu username -xp password

阅读(883) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~