Email

MX記錄指向gmail;直接從伺服器發送的後綴郵件被 gmail、雅虎標記為垃圾郵件

  • October 7, 2018

我有一個安裝了 postfix 的 Ubuntu 14.04 伺服器。但是,根據 Google 的說明,我已將域 MX 記錄設置為指向 Google 應用程序的配置。

使用 Thunderbird、Apple、Gmail om Android 等電子郵件客戶端,一切正常。

我還想將系統郵件(例如 cron 輸出)轉發到 gmail 帳戶。我為此設置了 /etc/postfix/virtual 。但是,此類郵件在到達 gmail 時會被標記為垃圾郵件。如果我發送到雅虎郵件帳戶,同樣的事情。

/etc/postfix/main.cf 的內容:

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/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = example.com
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
message_size_limit = 5120000
mailbox_size_limit = 5120000
recipient_delimiter = +
inet_interfaces = all

# to forward to another domain
virtual_alias_maps = hash:/etc/postfix/virtual
inet_protocols = ipv4

/etc/postfix/virtual 的內容:

root root@example.com
postgres info@example.com

被 gmail 標記為垃圾郵件的郵件內容:

Delivered-To: info@example.com
Received: by 2002:aed:2f41:0:0:0:0:0 with SMTP id l59-v6csp1151407qtd;
       Fri, 5 Oct 2018 17:01:30 -0700 (PDT)
X-Google-Smtp-Source: ACcGV634DT4ke7ML+6DR3ZbuM0ejugIaHIVQ0A5hTlmrTZQGXwR7JjeJs48KeoNHV3o6zeeGjrp1
X-Received: by 2002:a50:8e56:: with SMTP id 22-v6mr17250946edx.101.1538784090699;
       Fri, 05 Oct 2018 17:01:30 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1538784090; cv=none;
       d=google.com; s=arc-20160816;
       b=LVJKKOt6I2s8vjwvsViL5b7wbkfbzHlQNGu9spySNuQpj8pDSyOa22qvFMw0hy9AL4
        qx8pOqm4iXiREJ6MK+tLEHQ6f1MehnnbxvKNyMwlpZ3GwKPaXYA3di5RZBeXpYJvqINP
        wppqIUo7IFGSQ4nxsZOABbGalB91piDYlEdUS7mZLTeq2krADoDLy1qZJVp0zXRLCXez
        6pASUh4UZv4MfyPOwXRM8pEkefEEEwj3pwW38luavDba9G9qzYaTS9DRR9zBYqI4NPII
        azKKqgqScaPJ/kj3wFCx7xkQ1Zkt/9qpL1/K09qpQfCBF09SVFrKnj5Jp6EtH+sCwbYx
        BK3Q==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
       h=date:message-id:subject:to:from;
       bh=N+L1jS190l79xwwSepOlGcofnIXcnMDJmaZWohHFPME=;
       b=MfrDCRJLJYqKIOzGHDeEYD1OYxc/qQoVRALEo8KxIWVig51edIPOvy7eUgYljVUqss
        oUmQHIwgMiIjDIpnzG4qDAKoB9F9bWu0IhB8k900+iK1+ZH7sOKPFLwBHXtQhBp7SxOG
        0OEe5MVSCozsVGnQ6z2MDno/zsrG2uqmDQetL2g3ogCePP9kjzqA0KB2bLnPauktDD2T
        Eljz1nrGyJKcnAlb8JVMPD9DFggLBPpmk1yY8hahTmT91B/CVRMSNKXKRInH/msvJWIM
        0lOKkic1tb7mdmoAsCh+BfCiUtxsLk+ndK7TmOS03NzXvEPE7t0xU6I7G7qzeiiQwOre
        Nnyg==
ARC-Authentication-Results: i=1; mx.google.com;
      spf=neutral (google.com: 198.51.100.123 is neither permitted nor denied by best guess record for domain of postgres@example.com) smtp.mailfrom=postgres@example.com
Return-Path: <postgres@example.com>
Received: from example.com ([198.51.100.123])
       by mx.google.com with ESMTP id o20-v6si8540152edr.352.2018.10.05.17.01.30
       for <info@example.com>;
       Fri, 05 Oct 2018 17:01:30 -0700 (PDT)
Received-SPF: neutral (google.com: 198.51.100.123 is neither permitted nor denied by best guess record for domain of postgres@example.com) client-ip=198.51.100.123;
Authentication-Results: mx.google.com;
      spf=neutral (google.com: 198.51.100.123 is neither permitted nor denied by best guess record for domain of postgres@example.com) smtp.mailfrom=postgres@example.com
Received: by example.com (Postfix, from userid 105)
   id 0901860898; Sat,  6 Oct 2018 02:01:20 +0200 (CEST)
From: root@example.com (Cron Daemon)
To: postgres@example.com
Subject: Cron <postgres@treemapp> /var/lib/postgresql/pg_backup_rotated.sh
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/var/lib/postgresql>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=postgres>
Message-Id: <20181006000120.0901860898@example.com>
Date: Sat,  6 Oct 2018 02:01:20 +0200 (CEST)

*** Message Text ****

如何配置這個?

spf=neutral(google.com: 198.51.100.123 既不允許也不拒絕 postgres@example.com 域的最佳猜測記錄)

這是開始的地方:為您的域配置 SPF 記錄。

配置 SPF 記錄以使用 G Suite

您可以設置 SPF 記錄以防止垃圾郵件發送者使用您的域發送未經授權的電子郵件,也稱為欺騙。一些郵件收件人需要 SPF。如果您沒有為您的域添加 SPF 記錄,您的郵件可能會被標記為垃圾郵件,甚至會被退回。

SPF 記錄列出了允許代表您的域發送電子郵件的郵件伺服器。如果郵件是通過未經授權的郵件伺服器發送的,則會被報告並標記為垃圾郵件。

您的 SPF 記錄可能類似於:

v=spf1 +ip4:198.51.100.123 include:_spf.google.com ~all

如果這還不夠,內容實際上可能看起來像垃圾郵件。

引用自:https://serverfault.com/questions/934273