PHP Mail() to Gmail = Spam

emailgmail

Recently Gmail has started marking emails sent directly from my server (using php mail()) as spam and I'm having problems trying to find the issue. If I send an exact copy of the same email from my email client it goes to the Gmail inbox. The emails are plain text, around 7 lines long and contain a URL link in plain text.

As the emails sent from my client are getting through fine I'm thinking that the content isn't the issue. It would be greatly appreciated if someone could take a look at the the following headers and give me some advice why the email from the server is being marked as spam.

Email from Server:


Delivered-To: mygmail@gmail.com
Received: by 10.49.98.228 with SMTP id el4csp101784qeb;
    Thu, 15 Nov 2012 14:58:52 -0800 (PST)
Received: by 10.60.27.166 with SMTP id u6mr2296595oeg.86.1353020331940;
    Thu, 15 Nov 2012 14:58:51 -0800 (PST)
Return-Path: >admin@mydomain.co.uk>
Received: from dom.mydomain.co.uk (dom.mydomain.co.uk. [xx.xx.xx.xx])
    by mx.google.com with ESMTPS id df4si17005013obc.50.2012.11.15.14.58.51
    (version=TLSv1/SSLv3 cipher=OTHER);
    Thu, 15 Nov 2012 14:58:51 -0800 (PST)
Received-SPF: pass (google.com: domain of admin@mydomain.co.uk designates xx.xx.xx.xx as permitted sender) client-ip=xx.xx.xx.xx;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of admin@mydomain.co.uk designates xx.xx.xx.xx as permitted sender) smtp.mail=admin@mydomain.co.uk; dkim=pass header.i=@mydomain.co.uk
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mydomain.co.uk; s=default;
    h=Date:Message-Id:Content-Type:Reply-to:From:Subject:To; bh=2RJ9jsEaGcdcgJ1HMJgQG8QNvWevySWXIFRDqdY7EAM=;
    b=mGebBVOkyUhv94ONL3EabXeTgVznsT1VAwPdVvpOGDdjBtN1FabnuFi8sWbf5KEg5BUJ/h8fQ+9/2nrj+jbtoVLvKXI6L53HOXPjl7atCX9e41GkrOTAPw5ZFp+1lDbZ;
Received: from grantw by dom.mydomain.co.uk with local (Exim 4.80)
    (envelope-from >admin@mydomain.co.uk>)
    id 1TZ8OZ-0008qC-Gy
    for mygmail@gmail.com; Thu, 15 Nov 2012 22:58:51 +0000
To: mygmail@gmail.com
Subject: Offer Accepted
X-PHP-Script: www.mydomain.co.uk/admin.php for xx.xx.xx.xx
From: My Name >admin@mydomain.co.uk>
Reply-to: admin@mydomain.co.uk
Content-Type: text/plain; charset=Windows-1251
Message-Id: >E1TZ8OZ-0008qC-Gy@dom.mydomain.co.uk>
Date: Thu, 15 Nov 2012 22:58:51 +0000
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - dom.mydomain.co.uk
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [500 500] / [47 12]
X-AntiAbuse: Sender Address Domain - mydomain.co.uk
X-Get-Message-Sender-Via: dom.mydomain.co.uk: authenticated_id: grantw/from_h

Email from client:


Delivered-To: mygmail@gmail.com
Received: by 10.49.98.228 with SMTP id el4csp101495qeb;
        Thu, 15 Nov 2012 14:54:49 -0800 (PST)
Received: by 10.182.197.8 with SMTP id iq8mr2351185obc.66.1353020089244;
        Thu, 15 Nov 2012 14:54:49 -0800 (PST)
Return-Path: >admin@mydomain.co.uk>
Received: from dom.mydomain.co.uk (dom.mydomain.co.uk. [xx.xx.xx.xx])
        by mx.google.com with ESMTPS id ab5si17000486obc.44.2012.11.15.14.54.48
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 15 Nov 2012 14:54:49 -0800 (PST)
Received-SPF: pass (google.com: domain of admin@mydomain.co.uk designates xx.xx.xx.xx as permitted sender) client-ip=xx.xx.xx.xx;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of admin@mydomain.co.uk designates xx.xx.xx.xx as permitted sender) smtp.mail=admin@mydomain.co.uk; dkim=pass header.i=@mydomain.co.uk
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mydomain.co.uk; s=default;
    h=Content-Transfer-Encoding:Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=bKNjm+yTFZQ7HUjO3lKPp9HosUBfFxv9+oqV+NuIkdU=;
    b=j0T2XNBuENSFG85QWeRdJ2MUgW2BvGROBNL3zvjwOLoFeyHRU3B4M+lt6m1X+OLHfJJqcoR0+GS9p/TWn4jylKCF13xozAOc6ewZ3/4Xj/YUDXuHkzmCMiNxVcGETD7l;
Received: from w-27.cust-7941.ip.static.uno.uk.net ([xx.xx.xx.xx]:1450 helo=[127.0.0.1])
    by dom.mydomain.co.uk with esmtpa (Exim 4.80)
    (envelope-from >admin@mydomain.co.uk>)
    id 1TZ8Ke-0001XH-7p
    for mygmail@gmail.com; Thu, 15 Nov 2012 22:54:48 +0000
Message-ID: >50A572BA.9020401@mydomain.co.uk>
Date: Thu, 15 Nov 2012 22:54:50 +0000
From: My Name >admin@mydomain.co.uk>
User-Agent: Postbox 3.0.6 (Windows/20121031)
MIME-Version: 1.0
To: mygmail@gmail.com
Subject: Offer Accepted
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - dom.mydomain.co.uk
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - mydomain.co.uk
X-Get-Message-Sender-Via: dom.mydomain.co.uk: authenticated_id: admin@mydomain.co.uk

Best Answer

A few things.

1) Make sure your mail server PTR record is set to reflect the same as your MX record, not the same as your server hostname.

2) Your IP address appears to be a WebsiteWelcome/HostGator IP address. I'd check with their support if you haven't already. Of course the IP could be an old IP address of theirs that they sold back to their host, and you just happened to get it.

3) If you're proficient with tcpdump or wireshark, you could try to packet capture the email as it goes out and get the response from the gmail server. That would help more than headers would.

4) Bear in mind that Gmail also treats email for every person differently because their spam filters know that what some people consider spam, others don't -- so it could very likely be that you've flagged something similar to what is coming from your server as spam (even though the content is the same as what you're sending through the mail client), and so gmail is picking up on that. I'd say to try using a different gmail email address to test that theory.

5) X-Get-Message-Sender-Via: dom.domainbrokerage.co.uk: authenticated_id: grantw/from_h The problem here is that the authenticated_id is not an email address. In cpanel, setup an dedicated email address that is not the master email account for the cpanel account.

6) X-PHP-Script: www.domainbrokerage.co.uk/admin.php for 95.172.231.27 Gmail may see this and block based on that but its just a hunch. If there's a possibility to remove that header, do so.

Hope some of these help.