Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Mail returned sent via PHP - header problem - wrong format

Avatar of catonthecouchproductions
catonthecouchproductionsFlag for United States of America asked on
PHP
9 Comments1 Solution378 ViewsLast Modified:
I have the code below, but it is getting trapped in my spam and showing as returned mail, is it my headers that are in the wrong format?

Ryan
<?php
error_reporting(E_ALL);
if(isset($_POST["honeypot"])){
	$honeypot = $_POST["honeypot"];
}

if(empty($honeypot)){
	//Check to make sure that the name field is not empty
	if(trim($_POST['date']) == '') {
		$hasError = true;
	} else {
		$date = trim($_POST['date']);
	}

	//Check to make sure that the name field is not empty
	if(trim($_POST['time']) == '') {
		$hasError = true;
	} else {
		$time = trim($_POST['time']);
	}
	if(trim($_POST['server']) == '') {
		$hasError = true;
	} else {
		$server = trim($_POST['server']);
	}
	if(trim($_POST['new_burger']) == '') {
		$hasError = true;
	} else {
		$new_burger = trim($_POST['new_burger']);
	}
	if(trim($_POST['rate_burger']) == '') {
		$hasError = true;
	} else {
		$rate_burger = trim($_POST['rate_burger']);
	}
	//Check to make sure comments were entered
	if(trim($_POST['burger_comments']) == '') {
		$hasError = true;
	} else {
		if(function_exists('stripslashes')) {
			$burger_comments = stripslashes(trim($_POST['burger_comments']));
		} else {
			$burger_comments = trim($_POST['burger_comments']);
		}
	}

	//If there is no error, send the email
	if(!isset($hasError)) {
		$emailTo = 'glanceatx@gmail.com'; //Put your own email address here

			$message  = '<html><body>';
			$message .= '<h2>Burger Survey - Customer Review</h2>';
			$message .= '<h3>Server: '.$server.'</h3>';
			$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
			$message .= "<tr><td><strong>Ate on:</strong> </td><td>" .$date. "</td></tr>";
			$message .= "<tr><td><strong>Time:</strong> </td><td>" .$time. "</td></tr>";
			$message .= "<tr><td><strong>Which Burger:</strong> </td><td>" .$new_burger. "</td></tr>";
			$message .= "<tr><td><strong>Burger Rating:</strong> </td><td>" .$rate_burger. "</td></tr>";
			$message .= "<tr><td><strong>Burger Comments:</strong> </td><td>" .$burger_comments. "</td></tr>";
			$message .= "</table>";
			$message .= "</body></html>";

		$headers  = 'From: Burger Survey @ Stars Hingham <burgersurvey@starsstarshingham.com>' . "\r\n Reply-To: burgersurvey@starsstarshingham.com \r\n";
		$headers .= "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
		$subject  = "New Burger Survey Complete - Stars Hingham";
		mail($emailTo, $subject, $message, $headers, "-f $emailTo") or die("Mail error occurred");
		$emailSent = true;
	}
}else{
	echo "spam spam.";
}
?>
ASKER CERTIFIED SOLUTION
Avatar of flubbard
flubbard

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answers