Hi
I have the following email script, which is working fine except none of the carriage returns work and the entire message from all the fields just goes in one line without any spaces.

I've tried to look up carriage returns and didn't find anything different from \r\n

Any help would be great. Many thanks

if ($_POST["contact_email"]<>'') { 
    $ToEmail = 'xxxxxxxxxxx.com'; 
    $EmailSubject = 'Mas Des Filles Contact Form'; 
    $mailheader = "From: ".$_POST["contact_name"]."\r\n"; 
    $mailheader .= "Reply-To: ".$_POST["contact_email"]."\r\n"; 
    $mailheader .= "Content-type: text/plain; charset=iso-8859-1\r\n"; 
    $MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" .""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"]).""; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 
?> 

You are ending your message line and not actually including the returns:

$MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" .""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"]).""; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"]).""; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 

Try:

$MESSAGE_BODY = "Name is contacting you from Mas Des Filles Contact Page" ."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY = "Name: ".nl2br($_POST["contact_name"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Email: ".nl2br($_POST["contact_email"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Contact: ".nl2br($_POST["contact_tel"])."\r\n"; 
 "------------------------------------------------------------\r\n" . 
    $MESSAGE_BODY .= "Message: ".nl2br($_POST["contact_query"])."\r\n"; 
 "------------------------------------------------------------\n" . 
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY) or die ("Failure"); 

Thank you that is great.
Now the only thing left is remover the <br /> from the email.
I thought

nl2br($_POST["contact_query"])

would solve that.

Many thanks again. Much appreciated.

It is all working. I just removed the nl2br.

Many thanks for all the help.

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.