Jump to content

PHP contact form linebreak issue


$Three3

Recommended Posts

I have a PHP contact form on my website. I have been using it for about a year now without any problems. Nothing has been updated on my website that has do to with the contact form. However, all of a sudden, when a user enters "line breaks" or "paragraphs" in the message box, when I receive the message, instead of having several paragraphs I have 1 long paragraph with "\r\n" in place of line breaks.

 

Here is the code:

 

$to = "[email protected]";
$headers = "From: $email";
$subject = $subject;
$body = "Name: $name\n\n"
. "Email: $email\n\n"
. "Subject: $subject\n\n"
. "Message: $message" ;

mail ($to, $subject, $body, $headers) ;

 

 

For example, if someone fills out my contact form, here is what it looks like in my inbox:

 

Name: Allen Falcon

 

Email: [email protected]

 

Subject: Help

 

Message: Hello,\r\n I would like to know more about you guys program and how it works.\r\n Thanks,\r\n Allen Flacon

 

 

 

I really do not know why it started doing this out of the blue but any help is greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/259739-php-contact-form-linebreak-issue/
Share on other sites

if your code and mail server haven't changed, maybe its your e-mail client that changed and is now incorrectly displaying plain text line breaks.  Have your tried looking at the e-mail in a different mail client? (ie, check it gmail, thunderbird, outlook, etc)

 

otherwise,  :shrug:

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.