Gmail sends legitimate mails from php mail() function to spam folder
I already searched for solutions for this, but none of them resolved my problem. I'm using Google apps also.
Here's a copy of the message received on gmail:
Delivered-To: email@example.com Received: by 10.114.37.166 with SMTP id z6csp286681ldj; Tue, 22 Jan 2013 17:22:28 -0800 (PST) X-Received: by 10.236.119.206 with SMTP id n54mr27422481yhh.8.1358904147674; Tue, 22 Jan 2013 17:22:27 -0800 (PST) Return-Path: <firstname.lastname@example.org> Received: from smtp-web3-ctba.kinghost.net (smtp-web3-ctba.kinghost.net. [184.108.40.206]) by mx.google.com with ESMTP id h1si4616624anp.108.2013.01.22.17.22.26; Tue, 22 Jan 2013 17:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of email@example.com designates 220.127.116.11 as permitted sender) client-ip=18.104.22.168; Authentication-Results: mx.google.com; spf=pass (google.com: domain of firstname.lastname@example.org designates 22.214.171.124 as permitted sender) email@example.com Received: from smtp-web-ctba.kinghost.net (smtp-web-ctba [127.0.0.1]) by smtp-web3-ctba.kinghost.net (Postfix) with ESMTP id 7C5D58F2AE for <firstname.lastname@example.org>; Tue, 22 Jan 2013 23:22:26 -0200 (BRST) Received: from web593.kinghost.net (unknown [10.27.86.33]) by smtp-web-ctba.kinghost.net (Postfix) with ESMTP id 7BB2BC2DFC6C for <email@example.com>; Tue, 22 Jan 2013 23:22:26 -0200 (BRST) Received: by web593.kinghost.net (Postfix, from userid 850) id 77EA6E9B6; Tue, 22 Jan 2013 23:22:26 -0200 (BRST) To: firstname.lastname@example.org Subject: test mail From: email@example.com Subject: test mail MIME-Version: 1.0 Content-Type: text/html; charset=UTF-8 Message-Id: <20130123012226.77EA6E9B6@web593.kinghost.net> Date: Tue, 22 Jan 2013 23:22:26 -0200 (BRST) It's a test mail<br/> Another line<br/> Yet another line.
and the spf on jetcarros.com.br:
v=spf1 ip4:126.96.36.199/24 a mx a:jetcarros.com.br include:aspmx.googlemail.com ?all
in other cases that i have found people have said that i could fix the problem by setting the 5th param on php mail function to "-f$senderAdderess" but the envelope-from doesn't even appear in any part of the mail as you can see above.
here's my script:
$email_content = implode ( "\n",array ( "It's a test mail", "Another line", "Yet another line.") $email_headers = implode ( "\n",array ( "From: firstname.lastname@example.org", "Subject: test mail","Return-Path: email@example.com","MIME-Version: 1.0","Content-Type: text/html; charset=UTF-8" ) ); mail('firstname.lastname@example.org', 'test mail', nl2br($email_content), $email_headers, "-email@example.com")
Edit: As the iWizardPro sugest i use DKIM to sign my mail, and after several hours to make it sign correctly i have accomplished it. But my emails keep going on spam folder.
Any help here is welcome.
I believe Gmail requires DKIM keys to verify the validity of emails.
When I implemented my site's email system, I had to include DKIM keys for Gmail to stop blocking my emails and sending them to SPAM.
Edit: I believe this site is relevant as you stated that you are using Google Apps: http://support.google.com/a/bin/answer.py?hl=en&answer=174124
Your IP-/domain reputation seems to be wrecked:
Solution: Send from another IP/domain.