trt4324 发表于 2014-5-14 22:28:21

SendEmail 安装发邮件通知

实验目的:
时时监控公司网络,获取公网IP,每天早上发邮件到139邮箱提醒。

下载:
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

安装:
#tar -zxvf sendEmail-v1.56.tar.gz
#cp -a sendEmail-v1.56/sendEmail /usr/bin
#chmod +x /usr/bin/sendEmail

常用参数:
-f 发送方
-t 接收方
-s SMTP服务器的域名或者ip
-u 邮件主题
-m 邮件内容
-a 添加附件
-cc 副本
-xu smtp验证用户
-xp 密码
-v 详细输出
-o message-file=/file.txt 正文从文件内读取
-o tls=yes

Shell脚本:
#!/bin/bash
#获取公网IP地址发邮件通知
#执行者:XXX
#日期:2014/05/14

ip=`curl http://members.3322.org/dyndns/getip`

#内网邮件通知
/usr/bin/sendEmail -s xxx.xxx.xxx.xxx:25 -xu test@internal.com -xp 123456-f yanghw@internal.com -tyanghw@internal.com-u "IP地址" -o message-content-type=html -o message-charset=utf-8 -m "您的IP是:[$ip]来自:广东省深圳市 电信"

#139邮箱通知
/usr/bin/sendEmail -s mail.139.com -xu 189xxxxxxxx@139.com -xp xxxxxx-f 189xxxxxxxx@139.com -t189xxxxxxxx@139.com-u "IP地址" -o message-content-type=html -o message-charset=utf-8 -m "您的IP是:[$ip]来自:广东省深圳市 电信"

添加权限:
# chmod +x /opt/shell/ip.sh

任务计划:
crontab -e
#每天早上06:30发139邮箱通知网络情况
#执行者:XXX
30 06 * * * /opt/shell/ip.sh

页: [1]
查看完整版本: SendEmail 安装发邮件通知