postfix:不断将域名附加到发件人

postfix:不断将域名附加到发件人

我有两台设置相同的服务器。第一台可以正常发送邮件,另一台则无法发送邮件。问题似乎出在发件人身上。当我使用以下命令发送本地邮件时:

echo 'Message' | mailx -s 'Test' [email protected]

在 Postfix 日志中它将读取:

from=<[email protected]>

而在第一台服务器上,它正确读取:

from=<[email protected]>

我已检查/etc/hostname、,并用验证了和的/etc/hosts正确性。 的输出完全相同:mydomainmyhostnamepostconfigpostconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
relayhost = [host.relay.com]:587
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_use_tls = yes
unknown_local_recipient_reject_code = 550

mail.cf除添加中继主机和 SASL 内容外,所有设置均设置为默认设置。

我尝试在 中明确设置mydomain和,但这似乎被忽略了,就像输入然后执行并重新启动 postfix 不会改变任何东西一样。myhostmain.cfroot: [email protected]/etc/aliasesnewaliases

我也尝试过使用 PHP 脚本发送电子邮件,没有什么区别。

服务器main.cf1 与服务器 2 完全相同,它们都运行相同的系统 (CentOS 7) 和软件。唯一的区别是它们位于不同的域上(即 subdomain.domain1.com 和 subdomain.domain2.com),所以这可能是一种可能性,但似乎有些牵强。

mailx但是,服务器 1 可以使用上述命令以及前面提到的 PHP 脚本(这只不过是一个简单的mail()命令)完美地发送邮件。

什么原因可能导致 postfix 显然忽略域/主机设置,但选择正确的值但坚持将域添加到发件人地址?

答案1

答案是DNS

第一个线索是在日志中,我注意到实际上是 sendmail 而不是 postfix 首先提到了错误的地址。

通过谷歌搜索,我发现 sendmail 在解析域名时遇到错误,它显然会使用主机 + 域名组合。检查我的 DNS 配置时,我注意到 2 件事:我还没有配置反向 DNS,我没有指定AAAA 记录 (IPv6)用于服务器使用的子域。

添加此项后,sendmail 和 postfix 都使用正确的地址,而无需添加域。

相关内容