自动模拟邮箱登陆并发送邮件

1、yum 安装msmtp和mutt
yum install msmtp mutt


2、配置msmtp服务


touch /etc/msmtprc


# Set default values for all following accounts.
defaults
logfile /var/log/msmtp.log
account service
host mail.xxxx.com
#host smtp.xxxx.com
port 587
from [email protected]
auth login
tls on
tls_certcheck off
#user [email protected]
user [email protected]                申请的公共邮箱
password XXXXXXXXXXX                           密码
account default:service


3、配置mutt


vim /etc/Muttrc


结尾追加以下信息


#set sendmail=‘/usr/local/msmtp/bin/msmtp’                   根据msmtp   安装的位置进行配置
set sendmail='/usr/bin/msmtp --tls-certcheck=off'
set use_from=yes
set copy=no
set realname='[email protected]'
set from='[email protected]'
set envelope_from=yes


4、配置  zabbix 触发脚本


找到 zabbix  的 alertscript


[root@localhost alertscripts]# pwd
/usr/local/zabbix-server/share/zabbix/alertscripts
[root@localhost alertscripts]# cat sendalarmemail
#!/bin/bash
echo "$3" | mutt -s "$2" $1
[root@localhost alertscripts]#


5、测试
msmtp   -S   测试配置是否正确
msmtp   -P   测试配置文件路径


echo "testa   aaa" | mutt -s "wanghaoran aaaaa test" [email protected]

猜你喜欢

转载自blog.csdn.net/u013000139/article/details/51593728