Link to home
Start Free TrialLog in
Avatar of catonthecouchproductions
catonthecouchproductionsFlag for United States of America

asked on

Mail returned sent via PHP - header problem - wrong format

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.";
}
?>

Open in new window

Avatar of flubbard
flubbard

Are you sure that your MTA server is not blocking it due to a "masking" issue.  You can sometime choose to trust e-mails sent by localhost.

Additionally, is the name reporting correctly on your server and is that name resolving correctly to that server through DNS.  Sometimes the spam filter does not like to see messages sent from "mail@localhost"

HTH - flub
Avatar of catonthecouchproductions

ASKER

This is a copy of what I get:

The original message was received at Fri, 2 Jul 2010 08:10:07 -0700
from localhost [127.0.0.1]

  ----- The following addresses had permanent fatal errors -----
<glanceatx@gmail.com>
   (reason: 553 sorry, your mail was administratively denied. (#5.7.1))

  ----- Transcript of session follows -----
... while talking to relay-hosting.secureserver.net.:
>>> MAIL From:<glanceatx@gmail.com> SIZE=1425
<<< 553 sorry, your mail was administratively denied. (#5.7.1)
501 5.6.0 Data format error

Final-Recipient: RFC822; glanceatx@gmail.com
Action: failed
Status: 5.1.3
Diagnostic-Code: SMTP; 553 sorry, your mail was administratively denied. (#5.7.1)
Last-Attempt-Date: Fri, 2 Jul 2010 08:10:07 -0700


---------- Forwarded message ----------
From: "Burger Survey @ Stars Hingham <burgersurvey@starshingham.com> Reply-To": burgersurvey@starshingham.com
To: glanceatx@gmail.com
Date: Fri, 2 Jul 2010 08:10:07 -0700
Subject: New Burger Survey Complete - Stars Hingham
Burger Survey - Customer Review
Server: Wes
Ate on:       07/01/2010
Time:       7pm
Which Burger:       Cannonball
Burger Rating:       10
Burger Comments:       Yes I like the burger and I would try it again. Don't change a thing.

It's possible that you have malformed headers...you may want to try removing the spaces before and after your \r and \n.

Alternatively, the recipient "gmail" may not see that you are sending the message from a valid server.  What is the hostname of your server and do you operate any other e-mail from this server.  Also, do you get similar messages when sending to other recipients?

 - flub
I did that and no go.

Would it help if I created the email: burgersurvey@starshingham.com - on the server?

I use this same script all the time and never get this.

Ryan
Do you get the same problem when not sent to gmail?

 - flub
Weird...seems to be GMAIL only.. sent it to my other email address which is hosted at GoDaddy and it worked fine.

Ryan
ASKER CERTIFIED SOLUTION
Avatar of flubbard
flubbard

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
I wonder if I create that email address if that will do it? Weird how it worked on another server but not GoDaddy, can you see anything off in my PHP?

Ryan
SOLUTION
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