?
Solved

PHPMailer sending email into SPAM on GMAIL

Posted on 2012-09-16
6
Medium Priority
?
5,710 Views
Last Modified: 2012-09-17
Greetings,

I am using PHPMailer 5 for sending emails, but for some reason the Gmail Addresses show up in the Gmail SPAM folder.

Here's The code:
<?PHP
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded



$mail             = new PHPMailer();
$mail->IsHTML(true);



$body             = "<html><head></head><body>" . urldecode($_GET["body"]) . "</body></html>";

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
//$mail->SMTPSecure = "tls";                 // sets the prefix to the servier
$mail->Host       = "cutlerplace.com"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "<classified>"; // SMTP account username
$mail->Password   = "<classified>";        // SMTP account password

$mail->SetFrom("hospitaljobsservce@cutlerplace.com", "Hospital and Physician Locator Service");

$mail->AddReplyTo("hospitaljobsservce@cutlerplace.com", "Hospital and Physician Locator Service");

$mail->Subject    = $_GET["sbjt"];

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = $_GET["email"];
$toname = $_GET["ename"];
$mail->AddAddress($address, "John Doe");


//$mail->AddAttachment("images/phpmailer.gif");      // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

?>

Open in new window


Here's the result of the SMTP send:
SMTP -> FROM SERVER:220 wdz23.dailyrazor.com ESMTP MailEnable Service, Version: -5.11- ready at 09/16/12 22:40:45

<br />SMTP -> FROM SERVER: 250-dailyrazor.com [184.173.127.66], this server offers 5 extensions
250-AUTH CRAM-MD5 LOGIN
250-SIZE 26214400
250-HELP
250-AUTH=LOGIN
250 STARTTLS

<br />SMTP -> FROM SERVER:250 Requested mail action okay, completed

<br />SMTP -> FROM SERVER:250 Requested mail action okay, completed

<br />SMTP -> FROM SERVER:354 Start mail input; end with <CRLF>.<CRLF>

<br />SMTP -> FROM SERVER:250 Requested mail action okay, completed

<br />Message sent!    

Open in new window


how can I rig this so it will stay out of SPAM folders?
THanks
0
Comment
Question by:Evan Cutler
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:g3nu1n3
ID: 38404346
The headers for the email at Gmail should have something regarding why the email was sent to the spam folder, like a spam score and details on how the score was achieved.
0
 
LVL 9

Author Comment

by:Evan Cutler
ID: 38404364
Here's the headers from the latest email:

                                                                                                                                                                                                                                                               
Delivered-To: arcee123@gmail.com
Received: by 10.76.87.234 with SMTP id bb10csp161862oab;
        Sun, 16 Sep 2012 20:51:42 -0700 (PDT)
Received: by 10.229.135.149 with SMTP id n21mr6619143qct.82.1347853901999;
        Sun, 16 Sep 2012 20:51:41 -0700 (PDT)
Return-Path: <hospitaljobsservce@cutlerplace.com>
Received: from wdz23.dailyrazor.com (wdz23.dailyrazor.com. [184.173.127.66])
        by mx.google.com with ESMTP id m12si4294824qct.184.2012.09.16.20.51.41;
        Sun, 16 Sep 2012 20:51:41 -0700 (PDT)
Received-SPF: neutral (google.com: 184.173.127.66 is neither permitted nor denied by best guess record for domain of hospitaljobsservce@cutlerplace.com) client-ip=184.173.127.66;
Authentication-Results: mx.google.com; spf=neutral (google.com: 184.173.127.66 is neither permitted nor denied by best guess record for domain of hospitaljobsservce@cutlerplace.com) smtp.mail=hospitaljobsservce@cutlerplace.com
Received: from www.cutlerplace.com ([184.173.127.66]) by dailyrazor.com with MailEnable ESMTP; Sun, 16 Sep 2012 22:51:40 -0500
Date: Mon, 17 Sep 2012 03:51:40 +0000
Return-Path: hospitaljobsservce@cutlerplace.com
To: John Doe <arcee123@gmail.com>
From: Hospital and Physician Locator Service <hospitaljobsservce@cutlerplace.com>
Reply-to: Hospital and Physician Locator Service <hospitaljobsservce@cutlerplace.com>
Subject: INFORMATION FOR AURORA MEMORIAL HSPTL BURLINGTON
Message-ID: <f4ecc91d24329b9f1de169c563ac0c58@www.cutlerplace.com>
X-Priority: 3
X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="b1_f4ecc91d24329b9f1de169c563ac0c58"
X-ME-Bayesian: 0.016491


--b1_f4ecc91d24329b9f1de169c563ac0c58
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

To view the message, please use an HTML compatible email viewer!


--b1_f4ecc91d24329b9f1de169c563ac0c58
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit

<Body was truncated for EE>



--b1_f4ecc91d24329b9f1de169c563ac0c58--

Open in new window

0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 2000 total points
ID: 38405383
I wrote an article on this topic:
http://www.experts-exchange.com/Software/Internet_Email/A_1222-16-Tips-to-Improve-Email-Delivery.html

Chances are that you need to implement SPF and send it from a fixed IP address with reverse IP set up.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 2000 total points
ID: 38405387
Also make sure you don't use all-caps in your subject line, and make sure you don't misspell anything (e.g. HSPTL should be Hospital) . Those are two typical flags that indicate a spammy message.
0
 
LVL 35

Assisted Solution

by:gr8gonzo
gr8gonzo earned 2000 total points
ID: 38405394
By the way, just to further push the need for SPF - look at header line 11. A neutral SPF means that you don't have it set up at all. SPF is easy to implement and completely free to do. It's just a matter of adding a TXT record in your DNS for cutlerplace.com.
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 38405410
Thanks very much.
it appears as the most interesting fact is that I am using a Plesk email on a shared server.
Once I figure out how to get a stable email, I wont' be able to solve this.

Thanks much, and I'll grant you points on your blog entry.

Most appreciative.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question