Jump to content

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 = "info@mycompany123.com";
$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: allen_falcon@example.com

 

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:

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.