Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Email called spam

I am having a LOT of difficulty with email generated from phpmailer. All mail goes into spam, both for me & other recipients.

I use gmail. In my span mail it says: "We've found that lots of messages from p3nlhg759.shr.prod.phx3.secureserver.net are spam."

I have no clue what p3nlhg759.shr.prod.phx3.secureserver.net is, The site is hosted at GoDaddy.

php code sending email is:

<?
require_once('class.phpmailer.php');
function date_conv($x) {
	$dt = substr($x,5,2) . "/" . substr($x,8,2) . "/" . substr($x,0,4);
	return $dt;
}
//echo "got into email_send<br>";
session_start();
if ($_SESSION['gvhaadm'] == "") {
	header ("location: admin_login.php");
	exit;
}
$tdiff = time() - $_SESSION['alast_used'];
if ($tdiff > 2400) {
	session_destroy();	
	header ("location: admin_login.php");
	exit;
}
$_SESSION['alast_used'] = time();
$nh = 0;	
$mail             = new PHPMailer(); // defaults to using php "mail()"	
// set up database
include("db_connect.php");
//$qry = "SELECT * from homeowner where email <> '' and lname1 <> '' order by lname1";
//$res = mysqli_query ($link, $qry);
//$nh = mysqli_num_rows($res);
$attach = "";
$fname = "attach";
if ($_FILES[$fname]['name'] != "") {
	$attach = basename($_FILES[$fname]['name']);
	echo "attach = " . $attach . "<br>";
	$uploadfile = "attachments/" . $attach;
	move_uploaded_file($_FILES[$fname]['tmp_name'], $uploadfile); 
} 
if($_POST['repl'] == "on") {
	$frhd = "From: " . $_SESSION['admemail'] . "\r\n";
} else {
	$frhd = "From: do-not-reply@gvha.biz\r\n";
}	
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= $frhd;	
$headers .= "Cc: richardkorts@gmail.com\r\n";
$subj = $_POST['subject'];
$both = false;
$board = false;
$arch = false;
if ($attach != "") {
	$path = "attachments/";
	$file = $attach;
	$pf = $path . $file;
	$from = "info@gvha.biz";
	$frname = "";
}
echo "Post[test] = " . $_POST['test'] . "<br>";
if ($_POST['test'] == "on") {
	$to = "richardkorts@gmail.com, jboland11@cox.net";
	$mail->AddAddress("richardkorts@gmail.com", "Richard Korts");
	$mail->AddAddress("jboland11@cox.net", "Jim Boland");
	//echo "attach = " . $attach . "<br>";
	$msg = $_POST['email'];
	$mail->MsgHTML($msg);
	if ($attach != "") {
		echo "pf = " . $pf . "<br>";
		$mail->AddAttachment($pf);
		if(!$mail->Send()) {
			echo "Mailer Error: " . $mail->ErrorInfo;
		}
	} else {
		echo "to = " . $to , ",subj = " . $subj . ", msg = " . $msg . "headers = " . $headers . "<br>";
		$mres = mail($to, $subj, $msg, $headers);
		echo "mres return = " . $mres . "<br>";
	}
	$nh = 2;
	echo "got to end<br>";
	header("Location: admin_menu.php?nes=" . $nh);
	exit;
}	
?>

Open in new window


Any ideas on how to "un-spam" this?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Marcus Bointon
Marcus Bointon
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dr. Klahn
Dr. Klahn

As a side note, Godaddy hosting is so spammy and full of bots and scrapers, that I just this morning blocked another one of their CIDR blocks from my server.
p3nlhg759.shr.prod.phx3.secureserver.net is the mail server you get when you use 'mail()'.  While I do have customers on Godaddy that are not having any problems, what they said above is or has been true.  Godaddy will not allow you to send directly to an external mail server.  Some people use SendGrid, I'm using SendinBlue for emailing from one application on Godaddy.  https://www.sendinblue.com/
If you want the best service for email, learn about ConstantContact.  They are embarrassingly inexpensive and they take all of these problems away forever.  You get good working email, legal compliance, a programmable API, excellent statistics and full-time support.
https://www.constantcontact.com/index.jsp
Avatar of Richard Korts

ASKER

Thanks for your excellent comments.

I was originally using just the php mail function, but then had to allow for attachments.
I recognize it's an unnecessary mixture