电子邮件由 procmail 转发,但被 Gmail 拒绝

电子邮件由 procmail 转发,但被 Gmail 拒绝

编辑

让我们暂时忽略下面我所写的所有内容,重新思考这个问题:如果你有自己的域名,并且想要将该域名的电子邮件发送到你的 Gmail 收件箱(而不是 Google Apps),你应该怎么做?可以吗?最好只使用 SMTP,而不要使用 POP3。

原始问题:

  • 我有一些虚荣域名,其中之一就是amedee.be
  • 我在 Amazon AWS 主机上运行 Debian 服务器,并带有 Postfix。
  • 我也安装了SpamAssassin,并确认它可以处理最明显的垃圾邮件。
  • 我正在使用 Procmail 将邮件转发到 Gmail。
  • 我正在使用 Google 描述的最佳做法:https://support.google.com/a/answer/175365?hl=en

大多数电子邮件都能正常到达,这与 ServerFault 建议的类似问题不同,后者要么全部到达,要么全部不到达。但比我希望的更频繁的是(大约 1/20),我收到以下邮件/var/log/mail.log

Nov 30 15:01:39 ip-172-31-51-67 postfix/smtp[29724]: 4B72563149: 
  to=<[email protected]>, 
  relay=gmail-smtp-in.l.google.com[74.125.22.26]:25, 
  delay=2657, 
  delays=2657/0.2/0.07/0.18, 
  dsn=5.7.1, 
  status=bounced (host gmail-smtp-in.l.google.com[74.125.22.26] said: 
    550-5.7.1 [52.0.177.1037] Our system has detected that this message is 
    550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 
    550-5.7.1 this message has been blocked. Please visit 
    550 5.7.1 https://support.google.com/mail/answer/188131 for more information. 
  y66si45484104qhc.73 - gsmtp (in reply to end of DATA command))

我已经证实这绝对是不是垃圾邮件。当相同的邮件直接发送到 Gmail 时,它会到达。

我不知道这是否是巧合,但我在将服务器从 Hetzner 移至 AWS 时开始注意到这一点。我已经使用这种设置几年了,只是在过去 2 个月里电子邮件才丢失。奇怪的是,我的新旧服务器上的 Postfix 和 Procmail 配置完全相同。

其他相关问题提到了 DKIM 和 SPF,我必须调查这些字母的含义,但过去我没有使用过它们并且它有效,所以首先我想排除其他明显的原因。

/etc/postfix/main.cf

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
append_dot_mydomain = no
biff = no
body_checks = regexp:/etc/postfix/checks/body_checks
broken_sasl_auth_clients = yes
disable_vrfy_command = yes
header_checks = regexp:/etc/postfix/checks/header_checks
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = ipv4
local_destination_concurrency_limit = 1
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0

# If you can't deliver it in two hours - it can't be delivered!
#bounce_queue_lifetime = 2h
#maximal_queue_lifetime = 3h
#queue_run_delay = 3m
#minimal_backoff_time = 5m
#maximal_backoff_time = 10m

message_size_limit = 0
mime_header_checks = regexp:/etc/postfix/checks/mime_header_checks
mydestination =
        styx,
        styx.amedee.be,
        ip-172-31-51-67.ec2.internal,
        localhost.ec2.internal,
        localhost,
        intrepid,
        intrepid.exabyte.be,
        intrepid.amedee.be,
        mail.amedee.be,
        mx.amedee.be,
        localhost.localdomain,
        localhost.amedee.be,
        amedee.be,
        amed.ee,
        vangasse.eu,
        vangas.se,
        dhertefelt.be,
        dhertefe.lt,
        pcrobots.amedee.be,
        nowww.be
mydomain = amedee.be
myhostname = styx.amedee.be
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/8
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = -
relayhost =
smtp_destination_concurrency_limit = 1
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name. All Your Spam Are Belong To Us!
smtpd_client_connection_count_limit = 5
smtpd_client_restrictions =
#       reject_invalid_hostname,
        permit
smtpd_error_sleep_time = 10
smtpd_hard_error_limit = 5
smtpd_helo_required = yes
smtpd_helo_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
#       reject_invalid_hostname,
        permit
smtpd_junk_command_limit = 3
smtpd_recipient_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
#       reject_invalid_hostname,
        reject_multi_recipient_bounce,
        reject_non_fqdn_recipient,
#       reject_non_fqdn_sender,
        reject_unauth_destination,
        reject_unauth_pipelining,
        reject_unknown_recipient_domain,
        reject_unlisted_recipient,
        permit
smtpd_relay_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        defer_unauth_destination
#smtpd_sasl_auth_enable = yes
#smtpd_sasl_local_domain = $myhostname
#smtpd_sasl_path = private/auth
#smtpd_sasl_security_options = noanonymous
#smtpd_sasl_type = dovecot
smtpd_sender_restrictions =
#       reject_unknown_sender_domain,
        permit
smtpd_soft_error_limit = 2
smtpd_timeout = 120
smtpd_tls_cert_file = /etc/postfix/tls/mail.cert
smtpd_tls_key_file = /etc/postfix/tls/mail.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
#virtual_alias_domains = /etc/postfix/maps/virtual_alias_domains
virtual_alias_maps = hash:/etc/postfix/maps/virtual_alias_maps

/etc/postfix/master.cf

smtp      inet  n       -       -       -       -       smtpd
  -o content_filter=spamassassin
submission inet n       -       -       -       -       smtpd
  -o content_filter=spamassassin
pickup    unix  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
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}
spamassassin unix -     n       n       -       -       pipe
  user=debian-spamd argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

/home/amedee/.procmailrc

UMASK=007
PATH=/usr/bin:/usr/local/bin
MAILDIR=$HOME/Maildir
LOGFILE=$HOME/log/procmail.log
SHELL=/bin/bash
VERBOSE=no
SED=/bin/sed

SENDER=`formail -c -x Return-Path`
SENDMAILFLAGS="-oi -f $SENDER"

[email protected]

#From the manpages: prevent duplicate mails
:0 Wh: msgid.lock
| formail -D 8192 msgid.cache

:0
* ^Subject: Undelivered Mail Returned to Sender
/dev/null

:0
* .*
! $GMAIL

我的问题是:我需要做什么才能让 Gmail 不再退回我转发的任何合法电子邮件?

编辑:有人将我的问题标记为该问题的重复:如何发送电子邮件并避免被归类为垃圾邮件? 然而我的问题不是关于以原始发件人身份发送电子邮件,我的问题是关于转发其他人发送的电子邮件。标记也是在我发布问题 2 分钟后完成的,这段时间不足以完全阅读它,所以我认为这是对角阅读的情况。不要难过,我们都想获得 StackExchange 声誉。

我将继续编辑这个问题,因为我会解决每个疑似重复的问题,直到我毫无疑问地证明它不是重复的。

编辑:DNS配置:

* 300 IN A 52.0.177.103
@ 300 IN A 52.0.177.103
styx 300 IN A 52.0.177.103
@ 300 IN MX 1 styx.amedee.be.
@ 300 IN SPF "v=spf1 ip4:52.0.177.103 ptr ?all"
@ 300 IN TXT "v=spf1 ip4:52.0.177.103 ptr ?all"

编辑:根据 mxtoolbox.com 的说法,我的反向 DNS 与我的 SMTP 横幅不匹配。因此,我更改了我的 SMTP 横幅/etc/postfix/main.cf

#smtpd_banner = $myhostname ESMTP $mail_name. All Your Spam Are Belong To Us!
smtpd_banner = ec2-52-0-177-103.compute-1.amazonaws.com

并在 Postfix 重新加载后确认更改:

admin@ip-172-31-51-67:~$ telnet 127.0.0.1 25
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 ec2-52-0-177-103.compute-1.amazonaws.com
quit
221 2.0.0 Bye
Connection closed by foreign host.

因此,据我所知, 的反向 DNS52.0.177.103ec2-52-0-177-103.compute-1.amazonaws.com, 的 IP 地址ec2-52-0-177-103.compute-1.amazonaws.com52.0.177.103。不幸的是,我更希望主机名styx.amedee.be和反向 DNS 相同,但我认为这超出了我的控制范围。

答案1

仅使用 SMTP 无法实现这一点。您必须在个人邮件服务器(例如 Dovecot)上配置 POP3 服务,然后配置 Gmail 以使用 POP3 获取邮件。使用任何其他方法,您都有可能丢失电子邮件。

相关内容