sendmail的一些问题

刚刚通过mail命令发了一条邮件: mail -s “hello” xx@xx.com < a.txt ,但是就是收不到邮件。查看了一下sendmail的日志文件/var/log/maillog,

发现有报错信息:

sendmail[22803]: My unqualified host name (test) unknown; sleeping for retry
竟然是无法解析,有点意思,直接去ping test自然是没问题,突然想到好像FQDN里面规定域名必须用”.”结尾,难道是hosts里面少了一个”.”,尝试修改hosts文件:

Do not remove the following line, or various programs

that require network functionality will fail.

127.0.0.1 test.

::1 localhost6.localdomain6 localhost6
然后再尝试,发现日志中还有报错信息:
stat=Deferred: Connection refused by [127.0.0.1]
据此可以得出问题所在:连接被本地[127.0.0.1]拒绝,这就应该是hosts文件还有问题,继续修改hosts文件:

Do not remove the following line, or various programs

that require network functionality will fail.

127.0.0.1 test. test

::1 localhost6.localdomain6 localhost6
最后重启sendmail服务,邮件发送成功。