Chinaunix首页 | 论坛 | 博客
  • 博客访问: 22616
  • 博文数量: 5
  • 博客积分: 260
  • 博客等级: 二等列兵
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-20 21:32
文章分类
文章存档

2011年(1)

2010年(1)

2009年(2)

2008年(1)

我的朋友
最近访客

分类: 系统运维

2011-09-30 09:54:52

mail发送邮件问题解决
在服务的机器上,增加监控,要给自己发送邮件,邮件怎么也发送不出来。

进行检查: 用mail -v self@XXX.com 进行检查:

用 sendmail -q -v 可以看到 Name server timeout
Transient parse error -- message queued for future delivery

# mail -v self@XXX.com
Subject: test
test
Cc:
XXX.com: Name server timeout
self@XXX.com... Transient parse error -- message queued for future delivery
self@XXX.com... queued

查看mail log: /var/log/maillog
Dec 28 15:33:05 testmachine sendmail[19124]: nBS7X4Qn019124: from=root, size=44, class=0, nrcpts=1, msgid=<200912280733.nBS7X4Qn019124@localhost.localdomain>, relay=root@localhost
Dec 28 15:33:05 newlido363 sendmail[19124]: nBS7X4Qn019124: to=self@XXX.com, delay=00:00:01, mailer=esmtp, pri=30044, dsn=4.4.3, stat=queued

在 /var/spool/clientmqueue/目录中,多了个未发送邮件
#ls
dfnBS7aN0W019327
qfnBS7aN0W019327

# cat qfnBS7aN0W019327
V8
T1261985783
K1261985784
N1
P30044
Mhost map: lookup (XXX.com): deferred
Fbs
$_root@localhost
${daemon_flags}c u
Sroot
Aroot@localhost.localdomain
rRFC822; self@XXX.com
RPFD:self@XXX.com
H?P?Return-Path:
H??Received: (from root@localhost)
        by localhost.localdomain (8.13.1/8.13.1/Submit) id nBS7aN0W019327
        for self@XXX.com; Mon, 28 Dec 2009 15:36:23 0800
H?D?Date: Mon, 28 Dec 2009 15:36:23 0800
H?F?From: root
H?x?Full-Name: root
H?M?Message-Id: <200912280736.nBS7aN0W019327@localhost.localdomain>
H??To: self@XXX.com
H??Subject: test
.

(要求:本机不配置DNS,也应该能够发送邮件)
------------
查资料:
1. DNS配的问题:
  在/etc/hosts中加入了 mail.XXX.com的解析。
  在/etc/host.conf中,检查了先hosts,再resolve
  还是无用

2. 查资料:
  上面写着有一个文件:/etc/mail/service.switch,原文贴出来:
问题解决了,果然就是service.switch的问题!

这个邮件发不出去的linux主机上没有这个文件,sendmail.cf里有:
# service switch file (name hardwired on Solaris, Ultrix, OSF/1, others)
#O ServiceSwitchFile=/etc/mail/service.switch

我登陆另一台也是要求不能使用dns解析,但能够正常收发邮件的主机(HPUX机器)上查了一下,它的/etc/mail下有service.switch文件。

我截取了hpux上service.switch的一部分内容放到linux机器上新建的service.switch中:
引用:# This file contains the fallback mechanism used by sendmail
# when resolving hostnames and aliases. If this file does
# not exist, then the fallback is
#
#       hosts   dns nis files
#       aliases files nisplus nis
#
# The default fallback for this file is
#
#       hosts   dns files
#       aliases files
#
# Note that the format of entries in this file consists of the
# service name (either 'hosts' or 'aliases'), followed by white
# space or a tab, and the list of lookup sources as mentioned
# above (dns, nis, nisplus, files).
#
# If sendmail is running in a non-DNS and non-NIS environment, for
# example, the entry for hosts should be:
#
#hosts   files
#aliases files
#
# This means that hostnames will be resolved by referencing /etc/hosts
# and aliases will be resolved by referencing /etc/mail/aliases.
##

并把里面的
#hosts   files
#aliases files
的注释去掉:
hosts   files
aliases files

这样自己也修改一下,可以发送邮件了

另外还要注意 /etc/nsswitch.conf
hosts: files [NOTFOUND=return UNAVAIL=continue]
这个文件配置不当,也会出现 Transient parse error -- message queued for future delivery



-----------
说另一种方法:
Add "xxx.com"  keyword to /etc/mail/access and /etc/mail/local-host-names, then run "cd /etc/mail && make -C /etc/mail && /etc/init.d/sendmail restart" , and check it again.

阅读(2336) | 评论(0) | 转发(0) |
0

上一篇:oracle 自治事务的使用举例.

下一篇:没有了

给主人留下些什么吧!~~