Postfix 查找失败:从本地主机工作,而不是在 LAN 中的其他节点上

Postfix 查找失败:从本地主机工作,而不是在 LAN 中的其他节点上

当我尝试使用 Postfix 和 Gmail 从同一网络上的主机以外的机器发送电子邮件时,收件人地址的查找暂时失败。在 Postfix 主机上测试时,它工作正常。 编辑:我在同一 LAN 上有一个客户端节点,请求此 Postfix 服务器为其发送电子邮件。服务器拒绝了,理由是临时查找失败。

为了达到我的目的,我遵循了以下说明:
https://rtcamp.com/tutorials/linux/ubuntu-postfix-gmail-smtp/
然后,我改变了 mynetworks 参数以包含我们 LAN 的 .3 子网上的任何节点。

我尝试修复该问题的方法:
1)为特定电子邮件地址添加别名,然后运行 ​​newaliases
2)将 Relay_domains 添加到 main.cf
3)将 sasl_passwd 文件更改为包含:smtp.gmail.com 或 COMPANYNAME.com
4)在 main.cf 中将 Relay_host 的值更改为 smtp.gmail.com 或 smtp.COMPANYNAME.com
5)在 main.cf 中更改 mydestinations 的值

这是我的 main.cf:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = hans
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = smtp.COMPANYNAME.com, COMPANYNAME.com, smtp.gmail.com, localhost.localdomain,     localhost
relayhost = [smtp.gmail.com]:587
relay_domains = COMPANYNAME.com, gmail.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, 192.168.3.0/255
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

更新:这是我的 mail.log,我正在修复网络掩码问题。仍然不知道如何修复临时查找问题。

Jan 30 15:42:07 hans postfix/smtpd[10994]: NOQUEUE: reject: RCPT from unknown[192.168.3.3]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<[email protected]> proto=SMTP helo=<localhost>  
Jan 30 15:42:07 hans postfix/smtpd[10994]: warning: bad net/mask pattern: "192.168.3.0/255"  

更新 2:我对 main.cf 做了很多更改。这是最新的。

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = hans
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = hans, localhost.localdomain, localhost
relayhost = [smtp.gmail.com]:587
relay_transport = relay
relay_domains = mail.companyname.com, companyname.com, gmail.com
mynetworks_style = subnet
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 [192.168.3.0]/255
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
smtp_sasl_tls_security_options = noanonymous
smtp_connection_cache_destinations = smtp.gmail.com

smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_mynetworks,
permit_auth_destination,
reject_unauth_destination

smtpd_sender_restrictions =
permit_mynetworks,
check_relay_domains  

最新错误日志:

这些是最新消息,但我已经对其进行了充分修复,以至于它不再具有相关性。

Feb  3 15:10:17 hans postfix/smtpd[18037]: fatal: parameter "smtpd_recipient_restrictions": specify at least one working instance of: check_relay_domains, reject_unauth_destination, reject, defer or defer_if_permit  

其他人的建议:有人告诉我,我需要在客户端和 Postfix 服务器之间使用正确的 DNS。显然,在我的配置中列出的子网中是不够的。我不确定这是否相关,因为关键是 Postfix 不应该进行本地查找,而应该将电子邮件发送到 Gmail。我错了吗?

答案1

Postfix 本身有关于如何调试当出现问题时。对于调试 postfix 进程,maillog 是你的好朋友。调试的第一步是发出此命令

egrep '(warning|error|fatal|panic):' /some/log/file | more

从邮件日志中我们可以看到 postfix 抱怨bad net/mask pattern: "192.168.3.0/255"。从您的main.cf,我们可以确认 (192.168.3.0/255) 处的一个 IP 地址的mynetworks模式错误。也许您的意思是 192.168.3.0/32。

好的,但是为什么在本地主机上有效,而在 LAN 中的其他节点上无效,

一些推测性的答案:

  • 您使用mail命令从本地主机发送电子邮件。使用此模式,postfix 甚至不必使用mynetworks参数。
  • 您使用 smtpd 发送电子邮件(通过telnet localhost 25)。使用此模式,postfix 仅检查第一个条目mynetworks(即 127.0.0.0/8)并发现客户端与此条目匹配,因此 postfix 甚至不会费心检查条目列表的其余部分mynetworks

相关内容