如何减lessSendmail的DNS超时期限

尝试发送到具有DNS问题的电子邮件地址时,我遇到了sendmail DNS超时期限问题。 假设有问题的电子邮件地址是[email protected]

我可以看到这个域名有一个DNS问题:

>host -t mx example.com ;; connection timed out; no servers could be reached 

我可以使用以下方法testing并定时发送有问题的电子邮件地址的sendmail电话:

 > time echo "This is a test message" | /usr/lib/sendmail [email protected] [email protected] real 2m36.252s user 0m0.004s sys 0m0.005s 

目前,sendmail超时需要2分36秒! 这导致我们的PHP网页试图发送到这个电子邮件地址挂起,并最终返回一个错误的浏览器。

我的问题是:如何减less这种超时?

我见过几个sendmail相关的超时configuration:

 > grep resolver /etc/mail/sendmail.cf Timeout.resolver.retrans=5s Timeout.resolver.retry=4 

Sendmail似乎被设置为重试4次,每个重传5秒延迟。

但是我还没有find实际的DNS超时时间?

供参考:红帽企业Linux服务器版本5.2,sendmail 8.13.8,Linux内核:2.6.18,Apache版本:2.2.3,PHP版本:5.3.0发生这种情况注意:这个问题是Sendmail在一些电子邮件地址上的延迟

作为一个快速的解决方法,你可以摆弄你的/etc/resolv.conf。 当然,这会改变系统parsing器的工作方式,这完全不是sendmail特有的问题。

 timeout: n sets the amount of time the resolver will wait for a response from a remote name server before retrying the query via a different name server. Measured in seconds, the default is RES_TIMEOUT (see <resolv.h> ). attempts: n sets the number of times the resolver will send a query to its name servers before giving up and returning an error to the calling application. The default is RES_DFLRETRY (see <resolv.h> ). 

从长远来看,以上不是很好的解决办法。 您的DNS服务器设置已损坏,需要修复。 如果有一个关于不存在的MX /域的查询,服务器应该很快用NXDOMAIN做出响应。 它不应该等待很长时间,因为它通常会导致许多程序的各种问题(sendmail的初学者,但通常也是sshd和NFS)。