title: Emails sent through smtp.gmail.com marked as spam by Gmail
body: <p>I'm using PHP Mailer to send mail from my webserver to users, but my messages are marked consistently as spam. I've done my research, and fixed all the obvious issues: we pass DKIM, have a working SPF, the email text isn't spammy, and we're sending through TLS.</p>
  
  <p>Here's the header of an email that gets marked as spam by gmail:</p>
  
  <pre><code>Delivered-To: test.bar.002@gmail.com
  Received: by 10.181.12.40 with SMTP id en8csp116861wid;
          Fri, 9 May 2014 18:46:55 -0700 (PDT)
  X-Received: by 10.224.6.10 with SMTP id 10mr19706177qax.45.1399686414997;
          Fri, 09 May 2014 18:46:54 -0700 (PDT)
  Return-Path: &lt;mailer@mysite.io&gt;
  Received: from mail-qg0-x241.google.com (mail-qg0-x241.google.com [2607:f8b0:400d:c04::241])
          by mx.google.com with ESMTPS id v7si2881235qge.66.2014.05.09.18.46.54
          for &lt;test.bar.002@gmail.com&gt;
          (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
          Fri, 09 May 2014 18:46:54 -0700 (PDT)
  Received-SPF: pass (google.com: domain of mailer@mysite.io designates 2607:f8b0:400d:c04::241 as permitted sender) client-ip=2607:f8b0:400d:c04::241;
  Authentication-Results: mx.google.com;
         spf=pass (google.com: domain of mailer@mysite.io designates 2607:f8b0:400d:c04::241 as permitted sender) smtp.mail=mailer@mysite.io;
         dkim=pass header.i=@mysite.io
  Received: by mail-qg0-x241.google.com with SMTP id i50so1732747qgf.8
          for &lt;test.bar.002@gmail.com&gt;; Fri, 09 May 2014 18:46:54 -0700 (PDT)
  DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
          d=mysite.io; s=google;
          h=date:to:from:reply-to:subject:message-id:mime-version:content-type
           :content-transfer-encoding;
          bh=n6hX3e1GZ+Q/POR+xMHxvjDK/1rDVqzc9ou8V6y9ytw=;
          b=UwZR6ZGo9UvrlFi7dEvc79EvBcD05JuSiYzKJFmvB/7UDxmavBlFLXamKTnnQjUFOq
           kHL9T/o7nLh19mcZQLRZ+MxRbz4YMEtLnWmWS4H2b+J6LIJprEa5q8lf5dnDtLQkBMB5
           sUG8jxH5JDvGgNZTAszesbzbnFNRYROtNztWM=
  X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
          d=1e100.net; s=20130820;
          h=x-gm-message-state:date:to:from:reply-to:subject:message-id
           :mime-version:content-type:content-transfer-encoding;
          bh=n6hX3e1GZ+Q/POR+xMHxvjDK/1rDVqzc9ou8V6y9ytw=;
          b=hjzBYoeDiPsFfb51gYZy40dfC00g7GkutZ3eLVPl/MVGlmInAAn08wmvjziZBu0x6W
           cZsuvX+Lmvo0CS8xfA7c7WvKEajz8drtfY/4KRdCst4NJAUbygvwtbM+BjlTReYDRs7w
           iG49tFYOGeVtiPDjpmFIiNpTdSqtmigVic5l1MuOzWQvxN2bIHKpu7EBWTmcDpwOQwO6
           wZjTQPp34pRJTVCmI9LxjraoQPEDcF65eQePnw09WwqXB6f4rIhTTdSrqfj7bz0nnC6Y
           1ffFtBxIOlacX4MkeaunqxtrlkrE1/PWiS3TBAtOHGG5WcTbBR6vyYIbc03jNh76jM9Q
           JBWQ==
  X-Gm-Message-State: ALoCoQlsyfeiWIDN4lXUnaoJrzWGVWYxtpyEiArI04f/0C180ysTVHSZPeM7kNG0/gv4guEkE0SP
  X-Received: by 10.140.28.198 with SMTP id 64mr18697366qgz.49.1399686414621;
          Fri, 09 May 2014 18:46:54 -0700 (PDT)
  Return-Path: &lt;mailer@mysite.io&gt;
  Received: from mysite.io (iad1-vshost51.dreamhost.com. [208.113.210.253])
          by mx.google.com with ESMTPSA id q8sm9340911qas.5.2014.05.09.18.46.54
          for &lt;test.bar.002@gmail.com&gt;
          (version=TLSv1 cipher=RC4-SHA bits=128/128);
          Fri, 09 May 2014 18:46:54 -0700 (PDT)
  Date: Fri, 9 May 2014 18:46:54 -0700
  To: test.bar.002@gmail.com
  From: Burn After Reading Mailer &lt;mailer@mysite.io&gt;
  Reply-To: mailer@mysite.io
  Subject: Here's a test subject. 
  Message-ID: &lt;110ee4e3922d30540207be948c995d93@mysite.io&gt;
  X-Priority: 3
  X-Mailer: PHPMailer 5.2.7 (https://github.com/PHPMailer/PHPMailer/)
  MIME-Version: 1.0
  Content-Type: text/plain; charset=iso-8859-1
  Content-Transfer-Encoding: 8bit
  
  Here's a message with innocuous copy.
  </code></pre>
  
  <p>I have a running support ticket with Google, and they haven't been able to figure it out either. I'm connecting to stmp.gmail.com with port 465 through SSL:</p>
  
  <pre><code>$mail = new PHPMailer();
  $mail-&gt;IsSMTP();                                    
  $mail-&gt;Host = "smtp.gmail.com";
  $mail-&gt;SMTPSecure = 'tls';
  $mail-&gt;SMTPAuth = true;
  $mail-&gt;Username = "myGmailAccount@gmail.com";       
  $mail-&gt;Password = "myGmailAccountPassword";  
  </code></pre>
  
  <p>Here's the SPF we have running on dreamhost:</p>
  
  <pre><code>v=spf1 ip4:208.113.210.253 include:_spf.google.com ~all
  </code></pre>
  
  <p>That's the same IP that's seen in the header:</p>
  
  <pre><code>Received: from mysite.io (iad1-vshost51.dreamhost.com. [208.113.210.253])
  </code></pre>
  
  <p>I don't know what I'm missing here. Is there a chance that we've tested this so many times that we've actually trained Gmail to think the messages are spam, just because we haven't marked them as 'not spam'?</p>