Postfix 不发送邮件,抱怨“找不到主机或域名”

Postfix 不发送邮件,抱怨“找不到主机或域名”

我跟着这些说明为了发送邮件,这是 Postfix 日志:

Sep 26 00:46:24 tshepang postfix/smtpd[5728]: 8EE2464931: client=localhost[127.0.0.1]
Sep 26 00:47:44 tshepang postfix/cleanup[5810]: 8EE2464931: message-id=<20110925224624.8EE2464931@tshepang>
Sep 26 00:47:44 tshepang postfix/qmgr[5772]: 8EE2464931: from=<[email protected]>, size=350, nrcpt=1 (queue active)
Sep 26 00:48:04 tshepang postfix/smtp[5859]: 8EE2464931: to=<[email protected]>, relay=none, delay=127, delays=107/0.01/20/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=gmail.com type=MX: Host not found, try again)
Sep 26 00:48:39 tshepang postfix/smtpd[5728]: disconnect from localhost[127.0.0.1]

另外,这可能是相关的(来自“/etc/postfix/main.cf”):

myhostname = tshepang
mydestination = tshepang, localhost
relayhost = 
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = all
inet_protocols = all

我在 Debian 6 上运行这个。

答案1

我曾经也遇到过同样的问题:

root@medusa:~# postqueue -p
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
079AC700080B      357 Wed Apr  3 13:47:47  [email protected]
(Host or domain name not found. Name service error for name=xxxx.cz type=MX: Host not found, try again)
                                         [email protected]

..

root@medusa:~# host -t MX xxxx.cz
xxxx.cz mail is handled by 10 e2sgw01.xxxx.cz.
xxxx.cz mail is handled by 10 e2sgw02.xxxx.cz.

..

root@medusa:~# telnet e2sgw01.xxxx.cz. 25
Trying 217.77.161.168...
Connected to e2sgw01.xxxx.cz.
Escape character is '^]'.
220 e2sgw01.xxxx.cz ESMTP Postfix

问题出在 /var/spool/postfix/etc/resolv.conf 文件(chroot 后的文件)中。看看它。

答案2

尝试禁用chroot属性,以便其不会更改/etc/postfix/master.cf记录中的根这里

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       n       -       -       smtpd

答案3

在安装 postfix 之后,我可以通过告诉 Postfix 使用 Google DNS 来解决这个问题:

echo 'nameserver 8.8.8.8' >> /var/spool/postfix/etc/resolv.conf

答案4

正如 @Shadur 指出的,此问题可能是由于您的 ISP(或安装服务器的网络)造成的。如果 SMTP 端口(端口号 25)存在安全限制,则无法通过此端口访问 MX 服务器。

您可以尝试改用 SMTP over SSL 端口(ssmtp,端口号 465)。为此,请编辑该/etc/postfix/master.cf文件,注释 smtp 行并添加 ssmtp 行:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
#smtp      inet  n       -       -       -       -       smtpd
ssmtp      inet  n       -       -       -       -       smtpd

要检查您的计算机上是否可以识别该帖子,您可以执行以下操作:

$>cat /etc/services | grep smtp
smtp        25/tcp      mail
ssmtp       465/tcp     smtps       # SMTP over SSL

相关内容