Multiple "Received: from" in headers while sending email with postfix
<p>I have configured postfix on my server. The problem is my emails are going in spam folder in gmail. Below is the link to complete mail with headers (obtained from gmail "show original" option with some edits like recipient email address, hostname and message content):</p>

<pre><code>Received: by 10.176.65.100 with SMTP id j91csp564258uad;
        Sun, 17 Jul 2016 02:42:13 -0700 (PDT)
X-Received: by 10.98.157.12 with SMTP id i12mr36676711pfd.164.1468748533226;
        Sun, 17 Jul 2016 02:42:13 -0700 (PDT)
Return-Path: &lt;service@mydomain.co&gt;
Received: from mydomain.co ([139.59.16.224])
        by mx.google.com with ESMTPS id c132si1739901pfc.233.2016.07.17.02.42.12
        for &lt;recipientemail@gmail.com&gt;
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 17 Jul 2016 02:42:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of service@mydomain.co designates 139.59.16.224 as permitted sender) client-ip=139.59.16.224;
Authentication-Results: mx.google.com;
       dkim=pass header.i=@mydomain.co;
       spf=pass (google.com: domain of service@mydomain.co designates 139.59.16.224 as permitted sender) smtp.mailfrom=service@mydomain.co
Received: from [127.0.1.1] (localhost [127.0.0.1])
    by mydomain.co (Postfix) with ESMTP id 50060142D51
    for &lt;recipientemail@gmail.com&gt;; Sun, 17 Jul 2016 05:42:10 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mydomain.co; s=mail;
    t=1468748530; bh=WctOxI13mNA4A7VXZBnp5dQPWeaTuXW+cDu+gpgm5gc=;
    h=Subject:From:To:Date:From;
    b=OqCqWn15sn5Ap0voyrq50bASfykTiuIR6dR8fOZZfo9okNV2928rYnYgypzi9Zzm1
     JC4b86B6pV7Vk5hCDnMPNUeEZGaBY/bShUzckh4xCqaHZx9tHA/pEGGryd70GlvB2z
     XmnA2T3Z+1vWcWfOcJmTTdHY9tCrbqEBXaP3B1iU=
Content-Type: multipart/alternative;
 boundary="===============3201548845801807681=="
MIME-Version: 1.0
Subject: Mydomain Help Service
From: service@mydomain.co
To: recipientemail@gmail.com
Message-Id: &lt;20160717094210.50060142D51@mydomain.co&gt;
Date: Sun, 17 Jul 2016 05:42:10 -0400 (EDT)

--===============3201548845801807681==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

MESSAGE CONTENT

--===============3201548845801807681==
Content-Type: text/html; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

MESSAGE CONTENT

--===============3201548845801807681==--
</code></pre>

<p>I suspect (no good reason) that it is because of two different "Received from: " entries.</p>

<pre><code>Received: from mydomain.co ([139.59.16.224])
Received: from [127.0.1.1] (localhost [127.0.0.1])
</code></pre>

<p>I don't understand why are two different entries appearing. I am using python smtplib library to send mails. I have seen headers corresponding to other emails I receive on my gmail account and none of them has localhost in "Received: from". How can I fix this?</p>

<p>Do you see any other reason why are the mails going into spam? I have tried sending to multiple gmail address with different message content.</p>

<p>Any help would be really appreciated.</p>