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 test@example.com 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 test@example.com does not designate 82.160.100.10 as permitted sender) smtp.mail=test@example.com
Received-SPF: fail (google.com: domain of test@example.com 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: <ldev@example.com>
Envelope-to: zbyszek@example.com
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 <ldev@example.com>)
id 1YOOPC-0005Ud-Qq
for zbyszek@example.com; Thu, 19 Feb 2015 11:41:20 +0100
Message-ID: <54E5BDCE.5040207@example.com>
Date: Thu, 19 Feb 2015 11:41:18 +0100
From: Head Developer <ldev@example.com>
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 <zbyszek@example.com>
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 ldev@example.com does not designate 82.160.100.10 as permitted sender) smtp.mail=ldev@example.com
Received-SPF: fail (google.com: domain of ldev@example.com 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: zbyszek@example.com 2 mail.example.com 110 zbyszek@example.com
Return-path: <ldev@example.com>
Envelope-to: zbyszek@example.com
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 <ldev@example.com>)
id 1YOOXn-0005j5-Tm
for zbyszek@example.com; Thu, 19 Feb 2015 11:41:20 +0100
Message-ID: <54E5BDCE.5040207@example.com>
Date: Thu, 19 Feb 2015 11:41:18 +0100
From: Head Developer <ldev@example.com>
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 <zbyszek@example.com>
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 ldev@example.com to another mailbox on same server zbyszek@example.com)
- 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