PHP格式的电子邮件

In the input <textarea> text looks good 3 lines

First Line 
John Smith
Ivan Normand

when i capture input with php and send email text looks like this when i capture input with php and send email text looks like this

First Line                    Bellman:
                          
John Smith
Ivan Normand

I use Thunderbird to receive email and i see this mess. It shows properly in webmail.

$message = $_POST["message"];

$headers = "From: $from";

// boundary

$semi_rand = md5(time());

$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

// headers for attachment

$headers .= "
MIME-Version: 1.0
" . "Content-Type: multipart/mixed;
" . " boundary=\"{$mime_boundary}\"";

// multipart boundary

$message = "This is a multi-part message in MIME format.

" . "--{$mime_boundary}
" . "Content-Type: text/plain; charset=\"utf-8\"
" . "Content-Transfer-Encoding: 7bit

" . $message . "

";

$message .= "--{$mime_boundary}
";

// preparing attachments

for ($x = 0; $x < count($files); $x++) {

    $file = fopen($files[$x], "rb");

    $data = fread($file, filesize($files[$x]));

    fclose($file);

    $data = chunk_split(base64_encode($data));

    $message .= "Content-Type: {\"application/octet-stream\"};
" . " name=\"$files[$x]\"
" .

        "Content-Disposition: attachment;
" . " filename=\"$names[$x]\"
" .

        "Content-Transfer-Encoding: base64

" . $data . "

";

    if ($x == count($files) - 1) {
        $message .= "--{$mime_boundary}--
";
    } else {
        $message .= "--{$mime_boundary}
";
    }
}

// send

$ok = @mail($to, $subject, $message, $headers);

You can use nl2br() of php, which convert ' ' character to '
'.

You can use it like below:

$message = nl2br($_POST["message"]); //Please take care of sql injection here