php mail() goes to junk folder!

Soldato
Joined
18 Oct 2002
Posts
9,047
Location
London
I'm aware you can get premade php mailing classes, but I'm stubborn and want to get it to work without all that...
Whenever I send an email to my hotmail address it goes in the junk folder which I don't want. I don't understand why though.. Are my headers wrong?
Here's a snippet:

Code:
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: [email protected]' . "\r\n";
$headers .= 'Reply-To: [email protected]' . "\r\n";
$headers .= 'Return-Path: [email protected]' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";


	// prepare email body text
	$Body = "";
	$Body .= "Message: ";
	$Body .= $Message;
	$Body .= "\n";
	
	// send email 
	$success = mail($EmailTo, $Subject, $Body, $headers);

I'd appreciate any help on this! :)
 
From Googleing ;) it apears to be something to do with using \r , try using:

Code:
$headers  = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'From: [email][email protected][/email]' . "\n";
$headers .= 'Reply-To: [email][email protected][/email]' . "\n";
$headers .= 'Return-Path: [email][email protected][/email]' . "\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\n";;
 
Just to give feedback, I was having this prob, and indeed altering it from "\r \n" to "\n" Does fix the problem :)
 
Here is my code

Code:
        <?php
/*Here we are going to declare the variables*/
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nComments: $message";
$recipient = "
$subject 
$mailheader = "From: $email\n";
$mailheader .= "Reply-To: $email\n";
$mailheader .= "MIME-Version: 1.0\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
?>

I was getting the same problem so i changed it to \n but i cant test it until ukfsn sort out there server failure :mad:
 
Last edited:
Thanks for the tip with the /r, however it still goes in the bin :(

I did google some, hence all the headers I've accumulated hoping it would solve the problem! But nothing seems to get through. I even tried changing every mention of an email address to this format:

Code:
$EmailTo = 'XYZ <[email protected]>';

But no good! What can I be possibly be missing that hotmail needs?
 
Back
Top Bottom