formatting of text area in php mail

Hi All,

We have a form text area field below, but when we process the code, the body of the email does not appear the way it was entered in the form.

It should appear with line breaks, but instead it appears as one line of text.

Should appear like :

Hi Client,

Thanks for the meeting today.


But appears like

Hi Client, Thanks for the meeting today. Regards.

<textarea cols="45" rows="9" name="email_message_one">This message will go to the client.</textarea>

Open in new window

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Open in new window

if (!isset($_POST['email_message_one']))  $email_message_one = ''; else $email_message_one = $_POST['email_message_one'];

Open in new window

Email body

Open in new window

Any help would be appreciated.
Cheryl LanderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Loganathan NatarajanLAMP DeveloperCommented:
Please use nl2br() function while you attach with email body.
Dave BaldwinFixer of ProblemsCommented:
How are you entering it in the form?  If you press 'enter' while you are in a form, it will submit the form, not create a line break.
Cheryl LanderAuthor Commented:
We have tried just hitting enter for each line, also by hitting Shift + Enter.

Same results.

All text comes out as one line.

We have looked into the suggestion that Loganathan has provided but are having trouble implementing it.
Dave BaldwinFixer of ProblemsCommented:
Your are dealing with conflicting methods.  Plain text uses "\r\n" for line breaks while HTML uses <br> and ignores \r\n in the text.  Depending on your situation, you might be able to use nl2br to put the text into a variable that will then have <br> instead of \r\n.  Then you could include that in your message body.

A good test is to echo the message to the screen.  HTML with <br> in the right places will look correct.  Plain text with \r\n will look right if it is enclosed between <pre>text</pre> tags.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.