mwtillman Posted October 17, 2010 Share Posted October 17, 2010 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 = "[email protected]"; /* * 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. Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/ Share on other sites More sharing options...
Bodhi Gump Posted October 17, 2010 Share Posted October 17, 2010 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.) Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/#findComment-1123091 Share on other sites More sharing options...
mwtillman Posted October 17, 2010 Author Share Posted October 17, 2010 Thank you. Both yield the same output - Parse error: syntax error, unexpected ';' inD:\Hosting\2229431\html\sendMail.php on line152 Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/#findComment-1123127 Share on other sites More sharing options...
BlueSkyIS Posted October 18, 2010 Share Posted October 18, 2010 have you tried replacing CR's in the message, too? or does this continue to fail with a simple, one-line message? Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/#findComment-1123151 Share on other sites More sharing options...
mwtillman Posted October 18, 2010 Author Share Posted October 18, 2010 I only tried with crs in message. Do again with no cr message? Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/#findComment-1123171 Share on other sites More sharing options...
mwtillman Posted October 18, 2010 Author Share Posted October 18, 2010 Same error message with no cr message... Quote Link to comment https://forums.phpfreaks.com/topic/216099-php-send-mail-error-with-multi-line-messages/#findComment-1123197 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.