Jump to content

PHP Send Mail Error with Multi-Line Messages


mwtillman

Recommended Posts

Forgive me.  I know there have been numerous questions on this issue.

 

Using code I did not write.  Works fine as long as message has no carriage returns.  With CR, I am getting the following error -

 

Warning: mail() [function.mail]: SMTP server response: 451 See djb/docs/smtplf.html.”>http://pobox.com/djb/docs/smtplf.html. in D:\Hosting\2229431\html\sendMail.php on line 152

 

I realize it must have something to do with \r\n but am not a coder. I want to fix this code as it also uses another script file to provide effects.  Complete code follows -

 

<?php
/*
  * YOUR EMAIL ***
*/

$adminEmail = "inTouch@vanguard-systems.net";

/*
  * VALIDATE EMAIL ***
*/

function validateEmail($email){
	return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}

/*
  * CHECK FORM ***
*/

$post = (!empty($_POST)) ? true : false;
if($post) {
	$name = stripslashes($_POST['name']);
	$email = trim($_POST['email']);
	$subject = "Get In Touch Web Form Submission";
	$message = stripslashes($_POST['message']);
	$error = '';

	/*
	  * CHECK MESSAGE ***
	*/


	if(!$message || $message == "Message") {
		$error = "Please, type in a message.";
	}

	/*
	  * CHECK MAIL ***
	*/

	if($email && !validateEmail($email) || $email == "Email") {
		$error = "Please, check your e-mail address.";
	}

	if(!$email || $email == "Email") {
		$error = "Please, type in your e-mail address.";
	}

	/*
	  * CHECK NAME ***
	*/

	if(!$name || $name == "Name") {
		$error = "Please, type in your name.";
	}

	/*
	  * ACTION ***
	*/

	if(!$error) {
		$mail = mail($adminEmail, $subject, $message,
     			"From: ".$name." <".$email.">\r\n"
    			."Reply-To: ".$email."\r\n"
    			."X-Mailer: PHP/" . phpversion());
		if($mail) {
			echo 'ok';
		}
	} else {
		echo '<p>'.$error.'</p>';
	}
}
?>

 

Please help if you can.

 

Please show the browser output, if you add:

 

var_dump("From: ".$name." <".$email.">\r\n"
             ."Reply-To: ".$email."\r\n"
             ."X-Mailer: PHP/" . phpversion());

and

var_dump('From: '.$name.' <'.$email.'>'."\r\n"
             .'Reply-To: '.$email."\r\n"
             .'X-Mailer: PHP/' . phpversion());

(Use single quotes in the last example.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.