1, install mail
[root@zabbix alertscripts]# yum install mailx -y
2, edit the configuration file to add the last line
[root@zabbix alertscripts]# vim /etc/mail.rc
set bsdcompat
set sendcharsets=iso-8859-1,utf-8
set from=邮箱
set smtp=smtp://smtp.exmail.qq.com
set smtp-auth-user=邮箱
set smtp-auth-password=邮箱密码
set smtp-auth=login
3, send a test message is normal
[root@zabbix alertscripts]# echo "zabbix test mail" |mail -s "zabbix" 邮箱
4, write e-mail script
[root@zabbix alertscripts]# cd /usr/lib/zabbix/alertscripts
[root@zabbix alertscripts]# vi mailx.sh#!/bin/bash
#send mailmessages=
echo $3 | tr '\r\n' '\n'
subject=echo $2 | tr '\r\n' '\n'
echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1
5, modify the permissions
touch /tmp/mailx.log
chown -R zabbix.zabbix /tmp/mailx.log
chmod +x /usr/lib/zabbix/alertscripts/mailx.sh
chown -R zabbix.zabbix /usr/lib/zabbix/
6, the test script to send mail
[Root @ zabbix alertscripts] # echo "hello world" | mail -s "testmail" Your mailbox
7, zabbix configuration web page
to add a script three parameters
{ALERT.SENDTO}
{ALERT.SUBJECT}
{} ALERT.MESSAGE
. 8, user configuration
9, the operation of the configuration
failure {TRIGGER.STATUS}, the server name: {HOSTNAME1} occur: { TRIGGER.NAME} fault!
Alarm Host: {HOSTNAME}
trap host IP address: {HOST.IP}
alert time: {EVENT.DATE} {EVENT.TIME}
Alarm Level: {TRIGGER.SEVERITY}
alarm information: {TRIGGER.NAME}
Alarm items: {TRIGGER .KEY1}
issue details: {iTEM.NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {EVENT.ID}
recovery {TRIGGER.STATUS}, server name: { hOSTNAME1}: {TRIGGER.NAME} has been restored!
Alarm Host: {HOSTNAME}
trap host IP address: {HOST.IP}
alert time: {EVENT.DATE} {EVENT.TIME}
Alarm Level: {TRIGGER.SEVERITY}
alarm information: {TRIGGER.NAME}
Alarm items: {TRIGGER .KEY1}
issue details: {iTEM.NAME}: {ITEM.VALUE}
current status: {TRIGGER.STATUS}: {ITEM.VALUE1}
event ID: {} EVENT.ID
10, to complete the test
test send message content