SHELL发送邮件
# yum install mailx
# vi /etc/mail.rc #添加邮件信息
set from=baojingtongzhi@163.com smtp=smtp.163.com
set smtp-auth-user=baojingtongzhi@163.com smtp-auth-password=123456
set smtp-auth=login
# echo "this is test mail." |mail -s "test mail" xxx@163.com
告警脚本:
# cat /usr/local/zabbix/share/zabbix/alertscripts/sendmail.sh
#!/bin/bash
to=$1
subject=$2
body=$3
FILE=/tmp/mail.tmp
echo "$body" > $FILE
dos2unix -k $FILE # 解决正文变成附件.bin
mail -s "$subject" "$to" < $FILE
Last updated