mail(exim4)发邮件没反应
从新搭建的 Nagios 服务器,该监控的业务服务都添加了内存,磁盘I/O,nginx 连接的监控,今天测试了一下邮件报警,居然不报警,查看 nagios.log 日志 有这样的错误:
[1279598130] SERVICE NOTIFICATION: eric;fms;int_net;UNKNOWN;notify-service-by-email;ERROR: Description table : The requested table is empty or does not exist.
[1279598130] Warning: Attempting to execute the command “/usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: PROBLEM\n\nService: int_net\nHost: fms-server\nAddress: 219.232.237.166\nState: UNKNOWN\n\nDate/Time: Tue Jul 20 11:55:30 CST 2010\n\nAdditional Info:\n\nERROR: Description table : The requested table is empty or does not exist.” | /bin/mail -s “** PROBLEM Service Alert: fms-server/int_net is UNKNOWN **” eric@nginxs.com” resulted in a return code of 127. Make sure the script or binary you are trying to execute actually exists…
“Make sure the script or binary you are trying to execute actually exists…” 提示的 mail 命令不存在
nagios $> whereis mail
mail: /usr/bin/mail /etc/mail.rc /usr/share/man/man1/mail.1.gz
路径果然 不是 /bin/mail
修改 commands.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$
}
改过之后,还不行·那就直接用系统自带的 命令 mail 发送email
nagios $> mail -s "test" eric@nginxs.com < /root/test
没有返回任何东西。那就加上-v参数打印他的行踪
nagios $> mail -v -s "test" eric@nginxs.com < /root/test
LOG: MAIN <= root@fms U=root P=local S=5703 root@fms:/usr/local/nagios/etc/objects# delivering 1ObWQb-0002nV-BI R: system_aliases for test@fms LOG: MAIN ** test@fms: Unrouteable address R: nonlocal for eric@nginxs.com LOG: MAIN ** eric@nginxs.com R=nonlocal: Mailing to remote domains not supported LOG: MAIN <= <> R=1ObWQb-0002nV-BI U=Debian-exim P=local S=6505 delivering 1ObWQb-0002nX-EQ R: system_aliases for root@fms R: system_aliases for eric@fms R: userforward for eric@fms R: procmail for eric@fms R: maildrop for eric@fms R: lowuid_aliases for eric@fms (UID 1000) R: local_user for eric@fms T: appendfile for eric@fms LOG: MAIN Completed LOG: MAIN => eric <root@fms> R=local_user T=mail_spool LOG: MAIN Completed
没有验证远程 email 服务器,发现他用的 debian-exim 去发的,于是看的它的配置文件:
nagios $> vim /etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype='local'
dc_other_hostnames='fms'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
注意红字部分,他指定的是本地,google 查明想往外发就要改为:
dc_eximconfig_configtype='internet'
也顺便伪造一下,发件人的地址与名字
nagios $> vim /etc/email-addresses
在最后添加:
eric:eric@tuokou.com
重启服务:
nagios $> /etc/init.d/exim4 restart
测试发送 email
nagios $>mail -v -s "test" eric@nginxs.com < /root/test
LOG: MAIN
<= root@fms U=root P=local S=5703
root@fms:/usr/local/nagios/etc/objects# delivering 1ObWX9-0002zu-5r
R: system_aliases for test@fms
LOG: MAIN
** test@fms: Unrouteable address
R: dnslookup for eric@nginxs.com
T: remote_smtp for eric@nginxs.com
Connecting to mxdomain.qq.com [119.147.10.120]:25 ... connected
SMTP<< 220 newmx42.qq.com MX QQ Mail Server
SMTP>> EHLO fms
SMTP<< 250-newmx42.qq.com
250-SIZE 73400320
250 OK
SMTP>> MAIL FROM:<root@fms> SIZE=6936
SMTP<< 250 Ok
SMTP>> RCPT TO:<eric@nginxs.com>
SMTP<< 250 Ok
SMTP>> DATA
SMTP<< 354 End data with <CR><LF>.<CR><LF>
SMTP>> writing message and terminating "."
SMTP<< 250 Ok: queued as
SMTP>> QUIT
LOG: MAIN
=> eric@nginxs.com R=dnslookup T=remote_smtp H=mxdomain.qq.com [119.147.10.120 ]
LOG: MAIN
<= <> R=1ObWX9-0002zu-5r U=Debian-exim P=local S=6424
delivering 1ObWXF-000304-Jo
R: system_aliases for root@fms
R: system_aliases for eric@fms
R: userforward for eric@fms
R: procmail for eric@fms
R: maildrop for eric@fms
R: lowuid_aliases for eric@fms (UID 1000)
R: local_user for eric@fms
T: appendfile for eric@fms
LOG: MAIN
Completed
LOG: MAIN
=> eric <root@fms> R=local_user T=mail_spool
LOG: MAIN
Completed
注意红字部分,发送成功了··
登录邮箱,收到了用户 eric 地址为eric@nginxs.com 发来的了。
转载请注明:文章转载自:Eric's linux and nginx! (http://www.nginxs.com)
本文地址:http://www.nginxs.com/linux/201.html
你好,请问nginx的 ngx_http_perl_module 、 with-mail 和 with-mail_ssl_module 这三个模块有什么用? 在什么情况下需要用到他们?