zabbix告警使用sendEmail

时间:2024-01-19 14:10:02

1sendmail介绍

详细介绍见官网:http://caspian.dotconf.net/menu/Software/SendEmail/

2使用sendEmail

sendEmail是个十分优秀的发邮件的小工具,比起sendmail强了百倍,我在本地测试zabbix报警的时候,刚开始使用的是sendmail来发送邮件,在测试过程中发现,有时候死活收不到邮件,有时候收到邮件了,但是延迟特别大,要么在垃圾箱里面,很是苦恼.

所以我最后使用了sendEmail工具,感觉特别好用。只要配置正确,邮件就能够及时到达。不说了。直接进入正题

安装:

  wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz //下载1.56版本
tar -xzvf sendEmail-v1..tar.gz //解压后就可以使用了
mv sendEmail /usr/local/bin/

一个实例:

 /usr/local/bin/sendEmail -f [发送者地址] -t "接收者" -s [你的smtp服务器地址] -u "发送的主题" -xu [smtp验证登陆名(邮箱名字)] -xp [你在后台获取的登录密码(一般不是邮箱密码)] -m "邮件内容"
实例
/usr/local/bin/sendEmail -f 5712xx@qq.com -t 18387xxx@.com -s smtp.qq.com -u "我是主题" -o message-charset=utf-8 -xu 5712xx@qq.com -xp airjyrcdzjtbbdbf -m "我是邮 件内容"

简单说下“  -xp [你在后台获取的登录密码(一般不是邮箱密码) ”哪里获取     以qq邮箱为例

第一步:进入qq邮箱,点击设置,然后账户

zabbix告警使用sendEmail

第二步:点击开启

zabbix告警使用sendEmail

第三步:

zabbix告警使用sendEmail

最后:按照提示复制授权码

zabbix告警使用sendEmail

具体详细使用可以看帮助:

 [root@iZ940ao463eZ alertscripts]# /usr/local/bin/sendEmail help
Oct :: iz940ao463ez sendEmail[]: Error: "help" is not a recognized option! sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net> Synopsis: sendEmail -f ADDRESS [options] Required:
-f ADDRESS from (sender) email address
* At least one recipient required via -t, -cc, or -bcc
* Message body required via -m, STDIN, or -o message-file=FILE Common:
-t ADDRESS [ADDR ...] to email address(es)
-u SUBJECT message subject
-m MESSAGE message body
-s SERVER[:PORT] smtp mail relay, default is localhost: Optional:
-a FILE [FILE ...] file attachment(s)
-cc ADDRESS [ADDR ...] cc email address(es)
-bcc ADDRESS [ADDR ...] bcc email address(es)
-xu USERNAME username for SMTP authentication
-xp PASSWORD password for SMTP authentication Paranormal:
-b BINDADDR[:PORT] local host bind address
-l LOGFILE log to the specified file
-v verbosity, use multiple times for greater effect
-q be quiet (i.e. no STDOUT output)
-o NAME=VALUE advanced options, for details try: --help misc
-o message-content-type=<auto|text|html>
-o message-file=FILE -o message-format=raw
-o message-header=HEADER -o message-charset=CHARSET
-o reply-to=ADDRESS -o timeout=SECONDS
-o username=USERNAME -o password=PASSWORD
-o tls=<auto|yes|no> -o fqdn=FQDN Help:
--help the helpful overview you're reading now
--help addressing explain addressing and related options
--help message explain message body input and related options
--help networking explain -s, -b, etc
--help output explain logging and other output options
--help misc explain -o options, TLS, SMTP auth, and more

你喜欢的话试试吧,极力推荐,不要再使用sendmail了