# Preserving text format/line breaks in email script

**URL:** <https://forum.kirupa.com/t/preserving-text-format-line-breaks-in-email-script/268478>\
**Category:** Uncategorized\
**Created:** [August 14, 2008, 10:16am UTC](https://forum.kirupa.com/t/preserving-text-format-line-breaks-in-email-script/268478 "2008-08-14T10:16:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![StigC](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@StigC](https://forum.kirupa.com/u/StigC)\
**Post date:** [August 14, 2008, 10:16am UTC](https://forum.kirupa.com/t/preserving-text-format-line-breaks-in-email-script/268478/1 "2008-08-14T10:16:58Z")

</div>

Hey Everyone.

I have a simple email form made in AS2, which of course sends an email through PHP.  
I used Senocular’s tutorial as inspiration. [http://www.kirupa.com/developer/actionscript/flash\_php\_email.htm](http://www.kirupa.com/developer/actionscript/flash_php_email.htm)

The problem I have is this - when recieving the email, the text has been stripped of all line breaks, which makes it quite hard to read.  
I’m no flash or php shark, so I was wondering if anyone has a good way of preserving the format of the input-text being sent? I’ve serched over and over again, here, google, you name it. I can’t seem to find a way to preserve the line breaks.

php code:

```php
<?php
header('content-type: text/html; charset: utf-8');

// Constants
$sendTo = "mail@mail.com";
$subject = "Subject line";

// Name Escape
$escName = mb_convert_encoding($_POST["Navn"], "ISO-8859-1", "UTF-8");

// message escape
$escMessage = mb_convert_encoding($_POST["Besked"], "ISO-8859-1", "UTF-8");

// Headers
$headers = "From: " . $escName;
$headers .= "<" . $_POST["Email"] . ">
";
$headers .= "Reply-To: " . $_POST["Email"] . "
";
$headers .= "Return-Path: " . $_POST["Email"];

mail($sendTo, $subject, $escMessage, $headers);

?>

```

note: After fiddling about for a whole day, I finally figured out how to get it to display special Danish characters in the email correctly - hence the mb\_convert\_encoding.

Any help would be appreciated.  
Thanks  
Stig
