查看/var/log/maillog输出:这里我只截取一小段内容:
Nov 21 10:30:52 slave3 sendmail[11829]: qAL2Uq8o011829:
to=13601298217@139.com, ctladdr=nagios (504/505), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30334, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (qAL2Uqrl011837 Message accepted for delivery)
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Uqrl011837: to=13601298217@139.com>, ctladdr=nagios@nagios> (504/505), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120585, relay=mx1.mail.139.com. [221.176.9.178], dsn=5.0.0, stat=Service unavailable
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Uqrl011837: qAL2Urrl011839: DSN: Service unavailable
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Urrl011839: to=nagios@nagios>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31793, dsn=2.0.0, stat=Sent
Nov 21 10:49:53 slave3 sendmail[16229]: My unqualified host name (nagios) unknown; sleeping for retry
Nov 21 10:50:53 slave3 sendmail[16229]: unable to qualify my own domain name (nagios) -- using short name
Nov 21 10:50:53 slave3 sendmail[16229]: qAL2orML016229: from=nagios, size=271, class=0, nrcpts=1, msgid=201211210250.qAL2orML016229@nagios>, relay=nagios@localhost
Nov 21 10:50:53 slave3 sendmail[16275]: qAL2orKk016275: from=nagios@nagios>, size=522, class=0, nrcpts=1, msgid=201211210250.qAL2orML016229@nagios>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
网上查了查资料,大致步骤解决如下:
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Uqrl011837: to=13601298217@139.com>, ctladdr=nagios@nagios> (504/505), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120585, relay=mx1.mail.139.com. [221.176.9.178], dsn=5.0.0, stat=Service unavailable
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Uqrl011837: qAL2Urrl011839: DSN: Service unavailable
Nov 21 10:30:53 slave3 sendmail[11839]: qAL2Urrl011839: to=nagios@nagios>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31793, dsn=2.0.0, stat=Sent
Nov 21 10:49:53 slave3 sendmail[16229]: My unqualified host name (nagios) unknown; sleeping for retry
Nov 21 10:50:53 slave3 sendmail[16229]: unable to qualify my own domain name (nagios) -- using short name
Nov 21 10:50:53 slave3 sendmail[16229]: qAL2orML016229: from=nagios, size=271, class=0, nrcpts=1, msgid=201211210250.qAL2orML016229@nagios>, relay=nagios@localhost
Nov 21 10:50:53 slave3 sendmail[16275]: qAL2orKk016275: from=nagios@nagios>, size=522, class=0, nrcpts=1, msgid=201211210250.qAL2orML016229@nagios>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
网上查了查资料,大致步骤解决如下:
1、修改主机名,我把主机名修改为nagios.com
hostname nagios.com
2、修改/etc/sysconfig/network文件,也是将HOSTNAME那行改为nagios.com,目的是为了重启服务器生效!
3、再测试发一封邮件
echo "hello" | mail
13601298217@139.com
4、查看邮件和日志
正常收到了!
再查看日志
Nov 21 13:21:02 slave3 sendmail[17963]: qAL5L1rw017963: from=root, size=31, class=0, nrcpts=1, msgid=201211210521.qAL5L1rw017963@nagios.com>,
relay=root@localhostNov 21 13:21:02 slave3 sendmail[17964]: qAL5L2O0017964: from=root@nagios.com>, size=297, class=0, nrcpts=1, msgid=201211210521.qAL5L1rw017963@nagios.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]Nov 21 13:21:02 slave3 sendmail[17963]: qAL5L1rw017963:
to=13601298217@139.com, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=30031, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (qAL5L2O0017964 Message accepted for delivery)Nov 21 13:21:03 slave3 sendmail[17966]: qAL5L2O0017964: to=13601298217@139.com>, delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120297, relay=mx1.mail.139.com. [221.176.9.178], dsn=2.0.0, stat=Sent (ok)
Nov 21 13:21:28 slave3 sendmail[17977]: qAL5LSD6017977: from=nagios, size=271, class=0, nrcpts=1, msgid=201211210521.qAL5LSD6017977@nagios.com>, relay=nagios@localhostNov 21 13:21:29 slave3 sendmail[17978]: qAL5LSKr017978: from=nagios@nagios.com>, size=534, class=0, nrcpts=1, msgid=201211210521.qAL5LSD6017977@nagios.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]Nov 21 13:21:29 slave3 sendmail[17977]: qAL5LSD6017977: to=13601298217@139.com, ctladdr=nagios (504/505), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30271, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (qAL5LSKr017978 Message accepted for delivery)Nov 21 13:21:31 slave3 sendmail[17980]: qAL5LSKr017978: to=13601298217@139.com>, delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120534, relay=mx1.mail.139.com. [221.176.9.178], dsn=2.0.0, stat=Sent (ok)
日志也看到正常发送了!
Nov 21 13:21:28 slave3 sendmail[17977]: qAL5LSD6017977: from=nagios, size=271, class=0, nrcpts=1, msgid=201211210521.qAL5LSD6017977@nagios.com>, relay=nagios@localhostNov 21 13:21:29 slave3 sendmail[17978]: qAL5LSKr017978: from=nagios@nagios.com>, size=534, class=0, nrcpts=1, msgid=201211210521.qAL5LSD6017977@nagios.com>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]Nov 21 13:21:29 slave3 sendmail[17977]: qAL5LSD6017977: to=13601298217@139.com, ctladdr=nagios (504/505), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30271, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (qAL5LSKr017978 Message accepted for delivery)Nov 21 13:21:31 slave3 sendmail[17980]: qAL5LSKr017978: to=13601298217@139.com>, delay=00:00:02, xdelay=00:00:02, mailer=esmtp, pri=120534, relay=mx1.mail.139.com. [221.176.9.178], dsn=2.0.0, stat=Sent (ok)
日志也看到正常发送了!
总结:网上很多文档说要重启机器,重启sendmail啥的,我这里都没重启也可以收到!