Postfix-未找到主机或域

Postfix-未找到主机或域

我刚刚在本地网络上的 Ubuntu 上安装了 Postfix。

在这个网络上,我有一个 Exchange 服务器(使用域mail.example.com)。我在向本地地址发送电子邮件时遇到问题[email protected]

relay=none, delay=0.01, delays=0.01/0/0/0, dsn=4.3.5, status=deferred 
(Host or domain name not found. Name service error for name=example.com
type=AAAA: Host found but no data record of requested type)

relay_domain我使用Postfix解决了这个问题main.cf

relay_domains = example.com
transport_maps = hash:/etc/postfix/transport

在我的/etc/postfix/transport

example.com smtp:[mail.example.com]

现在我可以在 上发送邮件@example.com,并且我已经测试了一些主流网络邮件(Gmail、Yahoo、Hotmail……)。它可以正常工作。但是为什么我的地址会出现此错误@example.com?我如何确保在其他域名上不会遇到此错误?

我的 Postfix 配置是:

postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = SRVWEB, localhost.localdomain, localhost
myhostname = SRVWEB
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relay_domains = domain.com
relayhost =
smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
transport_maps = hash:/etc/postfix/transport

答案1

您的服务器尝试在发送邮件时使用 IPv6。由于mail.example.com没有 AAAA 记录(与 A 记录相同,但适用于 IPv6),因此无法正常工作。

如果你希望 Postfix绝不使用 IPv6,您可以在配置文件中更改它,如 postconf(5) 手册页中所述:

When IPv6 support is enabled via the inet_protocols parameter,  Post-
fix will do DNS type AAAA record lookups.

When  both IPv4 and IPv6 support are enabled, the Postfix SMTP client
will attempt to connect via IPv6 before attempting to use IPv4.

Examples:

inet_protocols = ipv4
inet_protocols = all (DEFAULT)
inet_protocols = ipv6
inet_protocols = ipv4, ipv6

如果您只想针对此域进行更改,请将您的传输图更改为

example.com smtp-ipv4:[mail.domain.com]

答案2

我可以通过在安装 postfix 后立即告诉 Postfix 使用 Google DNS 来解决此问题:

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

答案3

对我来说有用的简单 Postfix 配置。

/etc/postfix/main.cf

myhostname = localhost.testing.com
myorigin = testing.com
relayhost =
inet_protocols = ipv4
inet_interfaces = loopback-only
mydestination =

答案4

/etc/postfix/main.cf 中的以下更改为我解决了这个问题。

inet_protocols = ipv6 

将以上内容更改为

inet_protocols = all

相关内容