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.

 

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.