仅当使用 `mail` 命令时,Postfix 才会“使用我自己的主机名问候我”,通过 smtp 可以正常工作

仅当使用 `mail` 命令时,Postfix 才会“使用我自己的主机名问候我”,通过 smtp 可以正常工作

编辑:请注意与许多其他类似问题不同,当消息为通过 smtp 接收. 问题只在于当它通过mail命令发送。virtual_alias_domains 和 DNS 似乎配置正确,并记录如下。

我正在运行 Postfix 3.1.1,我刚刚发现 Postfix 无法传递通过mail服务器上的命令发送的任何本地消息,但通过 smtpd 可以正常工作。

如果消息通过 smtp 到达,则以下是日志记录:

2020-02-02 23:06:34.048389+1000 0x72d3b  Info  25056  smtpd: 0BB1614AB18E: client=office.sendingdomain.com.au[203.2.2.2]
2020-02-02 23:06:34.066985+1000 0x72ee4  Info  25072  cleanup: 0BB1614AB18E: message-id=<[email protected]>
2020-02-02 23:06:34.068755+1000 0x722f6  Info  24886  qmgr: 0BB1614AB18E: from=<[email protected]>, size=889, nrcpt=1 (queue active)
2020-02-02 23:06:34.084680+1000 0x72d3b  Info  25056  smtpd: disconnect from office.sendingdomain.com.au[203.2.2.2] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
2020-02-02 23:06:36.482250+1000 0x72f12  Info  25079  smtpd: connect from localhost[127.0.0.1]
2020-02-02 23:06:36.489399+1000 0x72f12  Info  25079  smtpd: 774C714AB19C: client=localhost[127.0.0.1]
2020-02-02 23:06:36.492067+1000 0x72ee4  Info  25072  cleanup: 774C714AB19C: message-id=<[email protected]>
2020-02-02 23:06:36.493066+1000 0x72f12  Info  25079  smtpd: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
2020-02-02 23:06:36.493595+1000 0x722f6  Info  24886  qmgr: 774C714AB19C: from=<[email protected]>, size=1585, nrcpt=1 (queue active)
2020-02-02 23:06:36.531628+1000 0x72ee7  Info  25073  smtp: 0BB1614AB18E: to=<[email protected]>, orig_to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=2.9, delays=0.45/0.09/0.04/2.3, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 774C714AB19C)

如果我以 root 身份登录,从邮件服务器上的命令行执行操作,则会出现下面的日志记录:mail [email protected]

2020-02-02 23:08:56.102815+1000 0x732a3    Info        0x0                  25116  cleanup: 118E214AB263: message-id=<[email protected]>
2020-02-02 23:08:56.103991+1000 0x732a1    Info        0x0                  25115  qmgr: 118E214AB263: from=<[email protected]>, size=338, nrcpt=1 (queue active)
2020-02-02 23:08:56.155341+1000 0x72d3b    Info        0x0                  25056  smtpd: connect from home.mydomain.com[10.0.5.201]
2020-02-02 23:08:56.156441+1000 0x732a7    Default     0x0                  25118  smtp: warning: host home.mydomain.com[10.0.5.201]:25 greeted me with my own hostname home.mydomain.com
2020-02-02 23:08:56.157154+1000 0x732a7    Default     0x0                  25118  smtp: warning: host home.mydomain.com[10.0.5.201]:25 replied to HELO/EHLO with my own hostname home.mydomain.com
2020-02-02 23:08:56.186791+1000 0x732a7    Info        0x0                  25118  smtp: 118E214AB263: to=<[email protected]>, relay=home.mydomain.com[10.0.5.201]:25, delay=0.76, delays=0.7/0.03/0.02/0, dsn=5.4.6, status=bounced (mail for mydomain.com loops back to myself)
2020-02-02 23:08:56.187402+1000 0x72d3b    Info        0x0                  25056  smtpd: disconnect from home.mydomain.com[10.0.5.201] ehlo=1 quit=1 commands=2
2020-02-02 23:08:56.189190+1000 0x732a3    Info        0x0                  25116  cleanup: 2DF3614AB265: message-id=<[email protected]>
2020-02-02 23:08:56.190087+1000 0x732a1    Info        0x0                  25115  qmgr: 2DF3614AB265: from=<>, size=2383, nrcpt=1 (queue active)
2020-02-02 23:08:56.190987+1000 0x732a1    Info        0x0                  25115  qmgr: 118E214AB263: removed
2020-02-02 23:08:56.221747+1000 0x732a3    Info        0x0                  25116  cleanup: 35E4B14AB266: message-id=<[email protected]>
2020-02-02 23:08:56.222627+1000 0x732b0    Info        0x0                  25120  local: 2DF3614AB265: to=<[email protected]>, relay=local, delay=0.03, delays=0/0.03/0/0, dsn=2.0.0, status=sent (forwarded as 35E4B14AB266)
2020-02-02 23:08:56.222654+1000 0x732a1    Info        0x0                  25115  qmgr: 35E4B14AB266: from=<>, size=2533, nrcpt=1 (queue active)
2020-02-02 23:08:56.223659+1000 0x732a1    Info        0x0                  25115  qmgr: 2DF3614AB265: removed
2020-02-02 23:08:56.237912+1000 0x72d3b    Info        0x0                  25056  smtpd: connect from home.mydomain.com[10.0.5.201]
2020-02-02 23:08:56.238780+1000 0x732a7    Default     0x0                  25118  smtp: warning: host home.mydomain.com[10.0.5.201]:25 greeted me with my own hostname home.mydomain.com
2020-02-02 23:08:56.239572+1000 0x732a7    Default     0x0                  25118  smtp: warning: host home.mydomain.com[10.0.5.201]:25 replied to HELO/EHLO with my own hostname home.mydomain.com
2020-02-02 23:08:56.240770+1000 0x732a7    Info        0x0                  25118  smtp: 35E4B14AB266: to=<[email protected]>, orig_to=<[email protected]>, relay=home.mydomain.com[10.0.5.201]:25, delay=0.02, delays=0/0/0.02/0, dsn=5.4.6, status=bounced (mail for mydomain.com loops back to myself)
2020-02-02 23:08:56.241401+1000 0x72d3b    Info        0x0                  25056  smtpd: disconnect from home.mydomain.com[10.0.5.201] ehlo=1 quit=1 commands=2
2020-02-02 23:08:56.242120+1000 0x732a1    Info        0x0                  25115  qmgr: 35E4B14AB266: removed

该服务器的唯一 IP 地址是 10.0.5.201,因此我不明白它为什么要打开到自身的 SMTP 连接。当我查询 DNS 时,一切都正确解析为该 IP:

这是 DNS 解析配置

# cat /etc/resolv.conf 
search home.mydomain.com mydomain.com
nameserver 10.0.5.1

以下是针对该名称服务器的 MX 主机的查询:

# host -t mx mydomain.com 10.0.5.1
Using domain server:
Name: 10.0.5.1
Address: 10.0.5.1#53
Aliases: 

mydomain.com mail is handled by 50 internet.mydomain.com.
mydomain.com mail is handled by 10 home.mydomain.com.

最后,这是对该主机的 A 记录的查询。

# host home.mydomain.com 10.0.5.1
Using domain server:
Name: 10.0.5.1
Address: 10.0.5.1#53
Aliases: 

home.mydomain.com has address 10.0.5.201

因此,DNS对我来说看起来非常干净。

由于问题仅在使用命令时发生mail,那么问题是否出在 master.cf 的某个地方?

smtp      inet  n       -       n       -       1       postscreen
smtpd     pass  -       -       n       -       -       smtpd
dnsblog   unix  -       -       n       -       0       dnsblog
tlsproxy  unix  -       -       n       -       0       tlsproxy
submission inet n       -       n       -       -       smtpd
  -o smtpd_tls_security_level=encrypt
  -o smtpd_enforce_tls=yes
  -o smtpd_sasl_auth_enable=yes
  -o content_filter=
  -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
smtp      unix  -       -       n       -       -       smtp

proxywrite unix -       -       n       -       1       proxymap

pickup    fifo  n       -       n       60      1       pickup
  -o content_filter=smtp-amavis:[127.0.0.1]:10024
cleanup   unix  n       -       n       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
sacl-cache unix -       -       n       -       1       sacl-cache
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       n       -       -       smtp
    -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache

dovecot   unix  -       n       n       -       25      pipe
  flags=DRhu user=_dovecot:mail argv=/Applications/Server.app/Contents/ServerRoot/usr/libexec/dovecot/dovecot-lda -d ${user}

policy    unix  -       n       n       -       -       spawn
  user=nobody:mail argv=/usr/bin/perl /Applications/Server.app/Contents/ServerRoot/usr/libexec/postfix/greylist.pl

smtp-amavis unix -      -       y       -       2       smtp
   -o smtp_data_done_timeout=1200
   -o smtp_send_xforward_command=yes
   -o disable_dns_lookups=yes
   -o max_use=20

127.0.0.1:10025 inet n  -       y       -       -       smtpd
   -o content_filter=
   -o smtpd_tls_security_level=none
   -o smtpd_delay_reject=no
   -o smtpd_client_restrictions=permit_mynetworks,reject
   -o smtpd_helo_restrictions=
   -o smtpd_sender_restrictions=
   -o smtpd_recipient_restrictions=permit_mynetworks,reject
   -o smtpd_data_restrictions=reject_unauth_pipelining
   -o smtpd_end_of_data_restrictions=
   -o smtpd_restriction_classes=
   -o mynetworks=127.0.0.0/8
   -o smtpd_error_sleep_time=0
   -o smtpd_soft_error_limit=1001
   -o smtpd_hard_error_limit=1000
   -o smtpd_client_connection_count_limit=0
   -o smtpd_client_connection_rate_limit=0
   -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters
   -o local_header_rewrite_clients=
   -o smtpd_milters=
   -o local_recipient_maps=
   -o relay_recipient_maps=

输出如下postconf -n

alias_maps = hash:/Library/Server/Mail/Config/postfix/aliases hash:/Library/Server/Mail/Data/listserver/aliases/list_server_aliases
biff = no
command_directory = /Applications/Server.app/Contents/ServerRoot/usr/sbin
compatibility_level = 2
config_directory = /Library/Server/Mail/Config/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
daemon_directory = /Applications/Server.app/Contents/ServerRoot/usr/libexec/postfix
data_directory = /Library/Server/Mail/Data/mta
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
disable_vrfy_command = yes
dovecot_destination_recipient_limit = 1
enable_server_options = yes
header_checks = pcre:/Library/Server/Mail/Config/postfix/custom_header_checks
html_directory = /Applications/Server.app/Contents/ServerRoot/usr/share/doc/postfix/html
imap_submit_cred_file = /Library/Server/Mail/Config/postfix/submit.cred
inet_interfaces = all
inet_protocols = ipv4
mail_owner = _postfix
mailbox_size_limit = 0
mailbox_transport = dovecot
mailq_path = /Applications/Server.app/Contents/ServerRoot/usr/bin/mailq
manpage_directory = /Applications/Server.app/Contents/ServerRoot/usr/share/man
message_size_limit = 31457280
mydestination = home.mydomain.com, localhost
mydomain = home.mydomain.com
mydomain_fallback = localhost
myhostname = home.mydomain.com
mynetworks = 127.0.0.0/8, 10.0.5.1/32, 10.0.5.31/32, [::1]/128
newaliases_path = /Applications/Server.app/Contents/ServerRoot/usr/bin/newaliases
proxy_interfaces = 124.148.20.193
queue_directory = /Library/Server/Mail/Data/spool
readme_directory = /Applications/Server.app/Contents/ServerRoot/usr/share/doc/postfix
recipient_canonical_maps = hash:/Library/Server/Mail/Config/postfix/system_user_maps
recipient_delimiter = +
relayhost =
sample_directory = /Applications/Server.app/Contents/ServerRoot/usr/share/doc/postfix/examples
sendmail_path = /Applications/Server.app/Contents/ServerRoot/usr/sbin/sendmail
setgid_group = _postdrop
smtp_tls_CAfile = /Library/Server/Mail/Config/postfix/ca-certificates.pem
smtp_tls_loglevel = 1
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = may
smtpd_data_restrictions = reject_unauth_pipelining, permit
smtpd_enforce_tls = no
smtpd_helo_required = yes
smtpd_pw_server_security_options = cram-md5,digest-md5,gssapi,login,plain
smtpd_recipient_restrictions = permit_sasl_authenticated reject_non_fqdn_recipient check_recipient_access hash:/Library/Server/Mail/Config/postfix/access permit_mynetworks reject_unauth_destination reject_non_fqdn_sender check_sender_access hash:/Library/Server/Mail/Config/postfix/sender_access check_sender_access regexp:/Library/Server/Mail/Config/postfix/regexp_sender reject_non_fqdn_hostname reject_invalid_helo_hostname check_helo_access regexp:/Library/Server/Mail/Config/postfix/helo_access reject_rbl_client zen.spamhaus.org reject_rbl_client bl.spamcop.net permit
smtpd_require_virtual_map = yes
smtpd_sasl_auth_enable = yes
smtpd_tls_CAfile = /etc/certificates/home.mydomain.com.A892E14870AED314279463AACA7B5424BDA1C1D0.chain.pem
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/certificates/home.mydomain.com.A892E14870AED314279463AACA7B5424BDA1C1D0.cert.pem
smtpd_tls_ciphers = medium
smtpd_tls_exclude_ciphers = SSLv2, 3DES, aNULL, ADH, eNULL, EXPORT
smtpd_tls_key_file = /etc/certificates/home.mydomain.com.A892E14870AED314279463AACA7B5424BDA1C1D0.key.pem
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_use_pw_server = yes
smtpd_use_tls = yes
soft_bounce = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
use_sacl_cache = yes
virtual_alias_domains = $virtual_alias_maps hash:/Library/Server/Mail/Config/postfix/virtual_domains
virtual_alias_maps = $virtual_maps hash:/Library/Server/Mail/Config/postfix/virtual regexp:/Library/Server/Mail/Config/postfix/regexp_virtual hash:/Library/Server/Mail/Config/postfix/virtual_users hash:/Library/Server/Mail/Data/listserver/aliases/list_server_virtual

mydomain.com 在 vi​​rtual_domains 中定义:

mydomain.com            allow

[电子邮件保护]在virtual_users中定义:

[email protected]    jay

为什么 postfix 没有意识到通过此方式丢弃的消息mail是为了本地传送,并且没有像通过 smtp 接收消息时那样将其交给 dovecot?

相关内容