GMail detecting mail as spam

dkimgmailpostfixsmtpspam

I've been trying for a long time to get our company's mail server send mail that will get accepted by the GMail spam filter. I have managed making it work for Yahoo Mail and Hotmail, sadly GMail is still marking our mails as spam.

I have configured DKIM, SPF, DMARC and verified our mail server IP address against blacklists. I also have pasted here the headers GMail gets when we send a mail.

Delivered-To: gmail-test-account@gmail.com
Received: by 10.42.215.6 with SMTP id hc6csp107427icb;
        Wed, 20 Aug 2014 07:34:26 -0700 (PDT)
X-Received: by 10.194.100.34 with SMTP id ev2mr59101019wjb.76.1408545265402;
        Wed, 20 Aug 2014 07:34:25 -0700 (PDT)
Return-Path: <company@phyramid.com>
Received: from mail.phyramid.com (mail.phyramid.com. [178.157.82.23])
        by mx.google.com with ESMTPS id dj10si4827754wib.79.2014.08.20.07.34.24
        for <gmail-test-account@gmail.com>
        (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 20 Aug 2014 07:34:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of company@phyramid.com designates 178.157.82.23 as permitted sender) client-ip=178.157.82.23;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of company@phyramid.com designates 178.157.82.23 as permitted sender) smtp.mail=company@phyramid.com;
       dkim=pass header.i=@phyramid.com
Received: from localhost (localhost [127.0.0.1])
  by mail.phyramid.com (Postfix) with ESMTP id ED2BB2017AC
  for <gmail-test-account@gmail.com>; Wed, 20 Aug 2014 17:33:23 +0300 (EEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=phyramid.com; h=
  content-type:content-type:mime-version:x-mailer:subject:subject
  :message-id:to:from:from:date:date; s=dkim; t=1408545197; x=
  1409409197; bh=e04RtoyF7G39lfCvA9LLhTz4nF64siZtN5IYmC18Xsc=; b=o
  +6mO8Uz4Uf1G4U2q6tKUiEy2N2n/5R2VtPPwIvBE5xzK/hEd2sDGMxVzQVgIDCsK
  Q0Xh+auPaQpxldQ+AEcL2XSZMrk/g0mJONjkpI19I5AwGIJCR1SVvxdecohTn9iR
  bCHzrGi2wAicfDBzOH6lUBNfh2thri79aubdCYc97U=
X-Amavis-Modified: Mail body modified (using disclaimer) - mail.phyramid.com
X-Virus-Scanned: Debian amavisd-new at mail.phyramid.com
Received: from mail.phyramid.com ([127.0.0.1])
  by localhost (mail.phyramid.com [127.0.0.1]) (amavisd-new, port 10024)
  with ESMTP id 3JcgXZAXeFtX for <gmail-test-account@gmail.com>;
  Wed, 20 Aug 2014 17:33:17 +0300 (EEST)
Received: from whiterock.local (unknown [109.98.21.30])
  by mail.phyramid.com (Postfix) with ESMTPSA id 05CAE200280
  for <gmail-test-account@gmail.com>; Wed, 20 Aug 2014 17:33:15 +0300 (EEST)
Date: Wed, 20 Aug 2014 17:34:15 +0300
From: Company Mail <company@phyramid.com>
To: gmail-test-account@gmail.com
Message-ID: <etPan.53f4b8b8.46e87ccd.11669@whiterock.local>
Subject: hey there!
X-Mailer: Airmail (247)
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

How was your summer?



----

Thanks a lot!

Best Answer

I have seen this to happen in other ocasions, when the received from is reported as localhost, with 127.0.0.1 as IP address.

The fact that this does not match with your DNS records is certainly getting your email marked as spam.

You should review your DNS records (A and MX) and the headers that you send in your SMTP server. Your server is sending what it believe it is his IP address, so you will need to configure your /etc/hosts to let your server know what is the external IP address of your server.