Hi, I've been having trouble with a form script that sends an e-mail but doesn't format the information correctly:

$formcontent="VISITOR NAME: $name\\n\\nFEEDBACK: $message";
$recipient = "facadmin@frontandcover.com";
$subject = "Contact Form";
$mailheader = "From: $email\\r\\n";
$mailheader .= "Reply-To: $email\\r\\n";
$mailheader .= "MIME-Version: 1.0\\r\\n";
if(strlen($message)>0){
mail($recipient, $subject, $formcontent, $mailheader) or die("Failure!");
echo "Your Message was Sent, <a href='index.php'><--Back</a>";
} else { echo "No E-mail was sent because your message contained no content. <a href='index.php'><--Back</a>"; }

For instance, if I enter my name as FrontAndCover.com, from e-mail qwerty@frontandcover.com with the content "Hello this is my message" I get an e-mail that looks like this:

From: qwerty@frontandcover.com\r\nReply-To:qwerty@frontandcover.com\r\nMIME-Version: 1.0\r\n
To: recipient-addr@frontandcover.com
Subject: Contact Form
Message Body:
VISITOR NAME:
FrontAndCover.com\n\nFEEDBACK: Hello this is my message

So I'm trying to figure out how to get this to send a normal looking e-mail.

your return and line feed characters have double slashes which causes them to be ignored should be \r\n

I can tell you what I would try. I would first try it without escaping the backslashes (i.e. \r\n instead of \\r\\n). Then try just using \n (without \r). If neither of those worked then I would try replacing the newlines with <br> (for HTML email).

according to the test I just did, removing the second backslashes worked exactly right

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.