外发电子邮件未送达

外发电子邮件未送达

我配置了 Postfix 服务器以使用 SQL 虚拟主机和 smtps。我可以在 imap 和 smtp 上登录,但通过 smtp 登录时无法再向任何出站邮件服务器发送邮件。我收到了Undelivered Mail服务器的通知。我不明白我错过了什么,这与我的有关吗smtp_relay_restrictions

主配置文件

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

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/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/example.com/privkey.pem
smtpd_use_tls=yes
smtpd_tls_auth_only = yes
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydomain = example.com
myorigin = $mydomain
#mydestination = $myhostname localhost.$mydomain
mydestination = localhost.$mydomain
relayhost =
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

# Handing off local delivery to Dovecot's LMTP, and telling it where to store mail
virtual_transport = lmtp:unix:private/dovecot-lmtp

# Virtual domains, users, and aliases
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf,
        mysql:/etc/postfix/mysql-virtual-email2email.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_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_reject_unlisted_recipient=no
  -o smtpd_client_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_sasl_type=dovecot
  -o smtpd_sasl_path=private/auth
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
#  -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}

更新

抱歉,我应该仔细阅读,邮件被 gmail 退回了。我到底错过了什么?我的反向主机条目是正确的。当我在服务器上使用 rainloop 时,也配置了 smtps,它工作正常。但 thunderbird 和我的 android 邮件应用程序失败了。

邮件日志

Aug 20 16:01:05 s20698923 dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=XXX.XXX.XXX.XXX, lip=87.106.145.99, mpid=3549, TLS, session=<aRH+Vt5zcZTVk6ae>
Aug 20 16:01:05 s20698923 postfix/smtps/smtpd[3504]: 3602F28C9F: client=unknown[XXX.XXX.XXX.XXX], sasl_method=PLAIN, [email protected]
Aug 20 16:01:05 s20698923 postfix/cleanup[3550]: 3602F28C9F: message-id=<>
Aug 20 16:01:05 s20698923 postfix/qmgr[2045]: 3602F28C9F: from=<[email protected]>, size=507, nrcpt=1 (queue active)
Aug 20 16:01:05 s20698923 postfix/smtps/smtpd[3504]: disconnect from unknown[XXX.XXX.XXX.XXX] ehlo=1 auth=1 mail=1 rcpt=1 data=1 commands=5
Aug 20 16:01:05 s20698923 postfix/smtp[3553]: 3602F28C9F: to=<[email protected]>, relay=gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b]:25, delay=0.73, delays=0.34/0.02/0.14/0.23, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b] said: 550-5.7.1 This message does not have authentication information or fails to pass 550-5.7.1 authentication checks. To best protect our users from spam, the 550-5.7.1 message has been blocked. Please visit 550-5.7.1  https://support.google.com/mail/answer/81126#authentication for more 550 5.7.1 information. b186-v6si7351796wmd.211 - gsmtp (in reply to end of DATA command))
Aug 20 16:01:05 s20698923 postfix/cleanup[3550]: E576B28CA2: message-id=<[email protected]>
Aug 20 16:01:05 s20698923 postfix/bounce[3554]: 3602F28C9F: sender non-delivery notification: E576B28CA2
Aug 20 16:01:05 s20698923 postfix/qmgr[2045]: E576B28CA2: from=<>, size=3029, nrcpt=1 (queue active)
Aug 20 16:01:05 s20698923 postfix/qmgr[2045]: 3602F28C9F: removed
Aug 20 16:01:05 s20698923 dovecot: lmtp(3556): Connect from local
Aug 20 16:01:06 s20698923 dovecot: lmtp([email protected]): RLxFO6HJelvkDQAA7uhc5A: msgid=<[email protected]>: saved mail to INBOX

此消息没有身份验证信息或未能通过 550-5.7.1 身份验证检查。

答案1

有趣的日志事件是这个:

8月20日 16:01:05 s20698923 postfix/smtp[3553]: 3602F28C9F:
[电子邮件保护]
relay=gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b]:25,
delay=0.73,delays=0.34/0.02/0.14/0.23,dsn=5.7.1,
status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b] 表示:
550-5.7.1 此邮件没有身份验证信息或未通过
550-5.7.1 身份验证检查。为了更好地保护我们的用户免受垃圾邮件的侵害,
550-5.7.1 邮件已被阻止。请访问
550-5.7.1https://support.google.com/mail/answer/81126#authentication更多
550 5.7.1 信息。b186-v6si7351796wmd.211 - gsmtp(回复 DATA 命令结束)

这向我展示了两件有趣的事情:

而且我在您的 postfix 配置中没有看到对 OpenDKIM 过滤器之类的明显引用。

人们通常只为他们的 IPv4 地址配置了适当的 PTR 反向 DNS 记录,而不是他们使用的 IPv6 地址,同样这些 IPv6 地址也不包含在他们的 SPF 记录中。

您需要为邮件服务器使用的所有 IPv4 和 IPv6 地址配置反向 DNS。并为邮件服务器上托管的所有域配置 SPF、DNARC 和 DKIM。

相关内容