使用 POSTFIX 转发电子邮件时出现问题

使用 POSTFIX 转发电子邮件时出现问题

我需要从外部电子邮件发送电子邮件(例如“用户@external_domain.com”),发送到我服务器上的电子邮件帐户(例如:“root@my_domain.com”),转发到另一个外部地址(例如:“[电子邮件受保护]“)。但它不起作用,并且日志文件上没有错误。

域名地址、电子邮件和 IP 的更改只是为了维护客户的隐私。

从外部电子邮件发送消息时,示例用户@external_domain.com,发送到我的服务器上的电子邮件帐户,例如:root@my_domain.com,它正确到达根电子邮件箱。

登录如下:

May 24 18:47:58 mail postfix/smtpd[1711]: connect from a4-salsa4-1.my_domain.com[62.14.x.x] 
May 24 18:47:58 mail postfix/smtpd[1711]: 6C776419DE: client=a4-salsa4-1.my_domain.com[62.14.x.x] 
May 24 18:47:58 mail postfix/cleanup[1715]: 6C776419DE: message-id=<[email protected]> 
May 24 18:47:58 mail postfix/qmgr[1415]: 6C776419DE: from=<exemplo user@external_domain.com>, size=2087, nrcpt=1 (queue active) 
May 24 18:47:58 mail postfix/smtpd[1711]: disconnect from a4-salsa4-1.my_domain.com[62.14.x.x] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5 
May 24 18:47:58 mail postfix/local[1716]: 6C776419DE: to=<root@my_domain.com>, relay=local, delay=0.07, delays=0.06/0.01/0/0, dsn=2.0.0, status=sent (delivered to mailbox) 
May 24 18:47:58 mail postfix/qmgr[1415]: 6C776419DE: removed

我想要到达“root”帐户的所有电子邮件(root@my_domain.com) 转发至“[电子邮件受保护]”,所以我配置了路由。

启用转发(在 shell 中以 root 用户身份):

# echo "\ root [email protected]"> ~ / .forward

通过此路由设置,从“发送的电子邮件”用户@external_domain.com“发送至电子邮件地址”root@my_domain.com”,到达本地邮件帐户(在我的 vps 处),但不到达“[电子邮件受保护]”。

然而日志表明它们已被发送到“[电子邮件受保护]”,请参阅下面的日志:

May 24 17:58:14 mail postfix/smtpd[32297]: connect from a4-salsa4-1.my_domain.com[62.14.x.x]
May 24 17:58:14 mail postfix/smtpd[32297]: 7A43B41A02: client=a4-salsa4-1.my_domain.com[62.14.x.x]
May 24 17:58:14 mail postfix/cleanup[32301]: 7A43B41A02: message-id=<[email protected]>
May 24 17:58:14 mail postfix/qmgr[30879]: 7A43B41A02: from=<user@external_domain.com>, size=2087, nrcpt=1 (queue active)
May 24 17:58:14 mail postfix/smtpd[32297]: disconnect from a4-salsa4-1.my_domain.com[62.14.x.x] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
May 24 17:58:14 mail postfix/cleanup[32301]: 7FD4D41A08: message-id=<[email protected]>
May 24 17:58:14 mail postfix/qmgr[30879]: 7FD4D41A08: from=<user@external_domain.com>, size=2231, nrcpt=1 (queue active)
May 24 17:58:14 mail postfix/local[32302]: 7A43B41A02: to=<root@my_domain.com>, relay=local, delay=0.03, delays=0.02/0.01/0/0, dsn=2.0.0, status=sent (forwarded as 7FD4D41A08)
May 24 17:58:14 mail postfix/qmgr[30879]: 7A43B41A02: removed
May 24 17:58:14 mail postfix/smtp[32303]: 7FD4D41A08: to=<[email protected]>, orig_to=<root@my_domain.com>, relay=relay.my_vps_host.com[177.153.9.96]:25, delay=0.33, delays=0/0.01/0.31/0.01, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as CE14D777DC134)
May 24 17:58:14 mail postfix/qmgr[30879]: 7FD4D41A08: removed

当向 root 发送本地电子邮件时(例如:crontab 作业),电子邮件成功到达本地帐户,并且也到达“[电子邮件受保护]”,查看日志:

May 24 17:55:03 mail postfix/smtp[32250]: 6E08B41A02: to=<[email protected]>, orig_to=<root>, relay=relay.my_vps_host.com[177.153.9.96]:25, delay=1.2, delays=0.01/0.02/0.93/0.28, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 6732B777D6711)
May 24 17:55:03 mail postfix/qmgr[30879]: 6E08B41A02: removed

我强烈怀疑我有一个过滤器“中继.my_vps_host.com“屏蔽消息。

因此,我在服务器的支持下打开了一个检查请求,他们告诉我中继中没有任何类型的锁定(“中继.my_vps_host.com”)。

应该转发的电子邮件根本不会到达“[电子邮件受保护]”。

/etc/postfix/main.cf:

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
compatibility_level = 2
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated 
defer_unauth_destination
myhostname = mail.my_domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, my_domain.com,  mail.my_domain.com, localhost.my_domain.com, , localhost
relayhost = relay.my_vps_host.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

/etc/postfix/master.cf:

# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd
#smtp      inet  n       -       y       -       1       postscreen
#smtpd     pass  -       -       y       -       -       smtpd
#dnsblog   unix  -       -       y       -       0       dnsblog
#tlsproxy  unix  -       -       y       -       0       tlsproxy
submission inet n       -       y       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       y       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       y       -       -       qmqpd
pickup    unix  n       -       y       60      1       pickup
cleanup   unix  n       -       y       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       y       1000?   1       tlsmgr
rewrite   unix  -       -       y       -       -       trivial-rewrite
bounce    unix  -       -       y       -       0       bounce
defer     unix  -       -       y       -       0       bounce
trace     unix  -       -       y       -       0       bounce
verify    unix  -       -       y       -       1       verify
flush     unix  n       -       y       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       y       -       -       smtp
relay     unix  -       -       y       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       y       -       -       showq
error     unix  -       -       y       -       -       error
retry     unix  -       -       y       -       -       error
discard   unix  -       -       y       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       y       -       -       lmtp
anvil     unix  -       -       y       -       1       anvil
scache    unix  -       -       y       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender     $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

my_domain.com 的 SPF:

  • v=spf1 +a +mx +ptr:my_vps_host.com 包括:_spf.google.com -all

我在用着:

  • Debian 9(延伸)。
  • 后缀 3.1.8。

有人可以帮助将转发的电子邮件发送到“root@my_domain.com”吗?

太感谢了!

相关内容