我在 centos5.6 上使用 exim 的自定义版本(与 afterlogic pro mailsuite 捆绑在一起)。系统无法发送到 yahoo 或 gmail 等远程邮件服务器,并出现此错误:
[email protected] R=dnslookup defer (-1): host lookup did not complete
我可以使用 dig 命令查找 gmail.com dns 记录:
#dig mx gmail.com
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-16.P1.el5 <<>> mx gmail.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2234
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;gmail.com. IN MX
;; ANSWER SECTION:
gmail.com. 3600 IN MX 30 alt3.gmail-smtp-in.l.google.com.
gmail.com. 3600 IN MX 20 alt2.gmail-smtp-in.l.google.com.
gmail.com. 3600 IN MX 5 gmail-smtp-in.l.google.com.
gmail.com. 3600 IN MX 10 alt1.gmail-smtp-in.l.google.com.
gmail.com. 3600 IN MX 40 alt4.gmail-smtp-in.l.google.com.
;; Query time: 16 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Mar 16 16:23:27 2012
;; MSG SIZE rcvd: 150
我使用 exim 运行了调试命令,结果如下:
#bin/exim -bt -d-resolver [email protected]
Exim version 4.76 uid=0 gid=0 pid=2368 D=fbb95cfd
Berkeley DB: Berkeley DB 5.2.36: (September 14, 2011)
Support for: crypteq iconv() OpenSSL Content_Scanning DKIM
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch dbm dbmnz mysql
Authenticators: cram_md5 plaintext spa
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir autoreply pipe smtp
Fixed never_users: 0
Size of off_t: 8
Compiler: GCC [4.1.2 20080704 (Red Hat 4.1.2-51)]
Library version: OpenSSL: Compile: OpenSSL 1.0.0e 6 Sep 2011
Runtime: OpenSSL 1.0.0e 6 Sep 2011
Library version: PCRE: Compile: 8.13
Runtime: 8.13 2011-08-16
Total 7 lookups
Library version: MySQL: Compile: 5.1.56 [Source distribution]
Runtime: 5.1.56
WHITELIST_D_MACROS unset
TRUSTED_CONFIG_LIST unset
changed uid/gid: forcing real = effective
uid=0 gid=0 pid=2368
auxiliary group list: <none>
seeking password data for user "exim": cache not available
getpwnam() succeeded uid=3000 gid=3000
seeking password data for user "root": cache not available
getpwnam() succeeded uid=0 gid=0
configuration file is /usr/mailsuite/etc/exim
log selectors = 0000cefe 00233821
trusted user
admin user
seeking password data for user "exim": cache not available
getpwnam() succeeded uid=3000 gid=3000
seeking password data for user "exim": using cached result
getpwnam() succeeded uid=3000 gid=3000
seeking password data for user "exim": using cached result
getpwnam() succeeded uid=3000 gid=3000
originator: uid=0 gid=0 login=root name=root
sender address = [email protected]
Address testing: uid=0 gid=3000 euid=0 egid=3000
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Testing [email protected]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Considering [email protected]
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
routing [email protected]
--------> dnslookup router <--------
local_part=someuser domain=gmail.com
checking domains
search_open: mysql "NULL"
search_find: file="NULL"
key="SELECT name FROM awm_domains WHERE name = 'gmail.com' AND is_internal = 1 " partial=-1 affix=NULL starflags=0
LRU list:
internal_search_find: file="NULL"
type=mysql key="SELECT name FROM awm_domains WHERE name = 'gmail.com' AND is_internal = 1 "
database lookup required for SELECT name FROM awm_domains WHERE name = 'gmail.com' AND is_internal = 1
MySQL query: SELECT name FROM awm_domains WHERE name = 'gmail.com' AND is_internal = 1
MYSQL new connection: host=localhost port=0 socket=/usr/mailsuite/tmp/mysql.sock database=exim user=root
MYSQL: no data found
lookup failed
gmail.com in ""? no (end of list)
gmail.com in "! +local_domains"? yes (end of list)
calling dnslookup router
dnslookup router called for [email protected]
domain = gmail.com
DNS lookup of gmail.com (MX) succeeded
DNS lookup of gmail-smtp-in.l.google.com (A) succeeded
DNS lookup of alt1.gmail-smtp-in.l.google.com (A) succeeded
DNS lookup of alt2.gmail-smtp-in.l.google.com (A) succeeded
DNS lookup of alt3.gmail-smtp-in.l.google.com (A) succeeded
DNS lookup of alt4.gmail-smtp-in.l.google.com (A) succeeded
fully qualified name = gmail.com
host_find_bydns yield = HOST_FOUND (2); returned hosts:
gmail-smtp-in.l.google.com 209.85.225.27 MX=5
alt1.gmail-smtp-in.l.google.com 173.194.76.27 MX=10
alt2.gmail-smtp-in.l.google.com 74.125.115.27 MX=20
alt3.gmail-smtp-in.l.google.com 173.194.67.26 MX=30
alt4.gmail-smtp-in.l.google.com 173.194.65.26 MX=40
set transport remote_smtp
queued for remote_smtp transport: local_part = someuser
domain = gmail.com
errors_to=NULL
domain_data=NULL localpart_data=NULL
routed by dnslookup router
envelope to: [email protected]
transport: remote_smtp
host gmail-smtp-in.l.google.com [209.85.225.27] MX=5
host alt1.gmail-smtp-in.l.google.com [173.194.76.27] MX=10
host alt2.gmail-smtp-in.l.google.com [74.125.115.27] MX=20
host alt3.gmail-smtp-in.l.google.com [173.194.67.26] MX=30
host alt4.gmail-smtp-in.l.google.com [173.194.65.26] MX=40
[email protected]
router = dnslookup, transport = remote_smtp
host gmail-smtp-in.l.google.com [209.85.225.27] MX=5
host alt1.gmail-smtp-in.l.google.com [173.194.76.27] MX=10
host alt2.gmail-smtp-in.l.google.com [74.125.115.27] MX=20
host alt3.gmail-smtp-in.l.google.com [173.194.67.26] MX=30
host alt4.gmail-smtp-in.l.google.com [173.194.65.26] MX=40
search_tidyup called
close MYSQL connection: localhost:(/usr/mailsuite/tmp/mysql.sock)/exim/root
我真的很茫然,如果能提供任何帮助我都会感激不尽。
答案1
事实证明,MTA 无法通过外部 DNS 解析器解析 DNS 记录。我在本地服务器中安装了 dnsmasq,并将其作为 /etc/resolv.conf 中的第一个条目,exim 和 postfix 都能够发送到远程服务器。
答案2
Exim 不会以 的身份运行root
。它使用的默认非 root 用户 ID 是作为构建的一部分进行硬编码的。在您的情况下,它似乎是exim
。添加一个exim
具有组的用户 ID exim
,它应该可以运行。
编辑:日志上的滚动条不见了。Exim 似乎选择了正确的路由器,DNS 查找成功。但是,没有迹象表明正在与远程服务器建立连接。尝试使用 telnet 连接到一个或多个 IP,看看是否可以连接到 SMTP 端口。命令
telnet 209.85.225.27 25
应产生如下结果:
Trying 209.85.225.27...
Connected to 209.85.225.27.
Escape character is '^]'.
220 mx.google.com ESMTP el4si7116293icb.3
以 220 开头的行表示您已连接到服务器。如果成功,请键入QUIT
以关闭连接。如果没有成功,则可能是防火墙阻止了传出的 SMTP 连接。