大网数据广告活动
服务器运维问答

Failed SPF for email imported to Gmail because of client IP instead of server's in message when sent through SMTP from one local box to another

· 52CE 我爱测

We have a linux (Debian) VPS with domain (let's say example.com with MX mail.example.com) that has SPF set up. There is dovecot+exim running. There is also Direct Admin on top of that. When I send a mail to foreign server then ev…

问题原文

原帖链接 · Zbyszek · CC BY-SA 3.0

We have a linux (Debian) VPS with domain (let's say example.com with MX mail.example.com) that has SPF set up. There is dovecot+exim running. There is also Direct Admin on top of that.

When I send a mail to foreign server then everything is fine. There is server IP in the message and SPF check goes fine.

Some data changed (domain etc.):

Received: from mail.example.com (mail.example.com. [188.40.153.39])
    by mx.google.com with ESMTPS id ***.7.2015.02.18.04.09.46
    for <*@gmail.com>
    (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
    Wed, 18 Feb 2015 04:09:47 -0800 (PST)
Received-SPF: pass (google.com: domain of [email omitted] designates 188.40.153.39 as permitted sender) client-ip=188.40.153.39;

But when I send it from a local mailbox to another local mailbox and then get mails into gmail through POP3 then I have problem with SPF because a message contains original client IP address and SPF check fails.

Authentication-Results: mx.google.com;
   spf=fail (google.com: domain of [email omitted] does not designate 82.160.100.10 as permitted sender) smtp.mail=[email omitted]
Received-SPF: fail (google.com: domain of [email omitted] does not designate 82.160.100.10 as permitted sender) client-ip=82.160.100.10;

82.160.100.10 is IP of original sender.

Because of that problem our internal corespondence tends to be marked as spam in gmail for people who check their boxes through it.

Any ideas how to fix that?


EDIT: headers of test mail (changed our IPs and domain)

1) Email sent from one box to another - headers from Thunderbird client:

Return-path: <[email omitted]>
Envelope-to: [email omitted]
Delivery-date: Thu, 19 Feb 2015 11:41:20 +0100
Received: from nat10.net08-g2.isko.net.pl ([82.160.100.10] helo=[11.0.0.22])
    by mail.example.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128)
    (Exim 4.83)
    (envelope-from <[email omitted]>)
    id 1YOOPC-0005Ud-Qq
    for [email omitted]; Thu, 19 Feb 2015 11:41:20 +0100
Message-ID: <[email omitted]>
Date: Thu, 19 Feb 2015 11:41:18 +0100
From: Head Developer <[email omitted]>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version: 1.0
To: Zbyszek <[email omitted]>
Subject: This is test
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

2) Same mail after being received by gmail (by automatic regular import by POP3):

Delivered-To: *@gmail.com
Received: by 10.140.86.210 with SMTP id p76csp775880qgd;
    Thu, 19 Feb 2015 02:47:12 -0800 (PST)
X-Received: by 10.140.102.165 with SMTP id w34mr10762910qge.26.1424342832562;
    Thu, 19 Feb 2015 02:47:12 -0800 (PST)
Authentication-Results: mx.google.com;
   spf=fail (google.com: domain of [email omitted] does not designate 82.160.100.10 as permitted sender) smtp.mail=[email omitted]
Received-SPF: fail (google.com: domain of [email omitted] does not designate 82.160.100.10 as permitted sender) client-ip=82.160.100.10;
Received: by 10.224.31.8 with POP3 id w8mf619596qac.5;
    Thu, 19 Feb 2015 02:47:12 -0800 (PST)
X-Gmail-Fetch-Info: [email omitted] 2 mail.example.com 110 [email omitted]
Return-path: <[email omitted]>
Envelope-to: [email omitted]
Delivery-date: Thu, 19 Feb 2015 11:41:20 +0100
Received: from nat10.net08-g2.isko.net.pl ([82.160.100.10] helo=[11.0.0.22])
    by mail.example.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128)
    (Exim 4.83)
    (envelope-from <[email omitted]>)
    id 1YOOXn-0005j5-Tm
    for [email omitted]; Thu, 19 Feb 2015 11:41:20 +0100
Message-ID: <[email omitted]>
Date: Thu, 19 Feb 2015 11:41:18 +0100
From: Head Developer <[email omitted]>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
MIME-Version: 1.0
To: Zbyszek <[email omitted]>
Subject: This is test
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Edit: some extra info

  • method of delivery is SMTP (I send email from Thunderbird in home using mailbox [email omitted] to another mailbox on same server [email omitted])
  • 82.160.100.10 is my home IP, nat10.net08-g2.isko.net.pl is my home hostname which resolves to that IP
  • 10.140.102.165 is gmail server IP
  • 11.0.0.22 is local IP in my home network
  • Mail server IP wasn't in any of headers (If it would be there it would be 188.40.153.39).
  • Hostname mail.example.com points to mail server IP
  • Domain IP wasn't in any of headers (if it would be there I would change it to 85.17.23.59)
  • domain has proper MX entry (that points to subdomain mail.example.com)
  • SPF record: "v=spf1 a mx ip4:188.40.153.39 -all"

Edit: uncovered IPs as not so sensitive

已采纳解答

原帖链接 · masegaloeh · CC BY-SA 3.0

Disclaimer: This answer was speculation one until GMail person confirmed it.

Looks like it's GMail mishandle your fetched email here. Some peoples also report similar case with yours in here, here or here

The problem is: GMail also deploying SPF measure when scanning email after fetching it via POP3.

Normally SPF-checking take place in SMTP transaction by checking the domain parts of sender address and client IP address. But in POP3, GMail has to parsing header and find the last Received header.

Received: from nat10.net08-g2.* ([*.160.100.10] helo=[11.0.0.22])
    by mail.example.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128)
    (Exim 4.83)
    (envelope-from <[email omitted]>)
    id 1YOOXn-0005j5-Tm
    for [email omitted]; Thu, 19 Feb 2015 11:41:20 +0100

This is original email that fetched from your server. It states that your email accepts email from *.160.100.10 with sender [email omitted]. In this stage Gmail pretends as your server and checks domain parts of sender address (example.com) and client IP address (*.160.100.10). The result was expected:

SPF softfail because domain of [email omitted] does not designate *.160.100.10 as permitted sender

For workaround, you can set Gmail filters to never mark your email as Spam.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-02-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。