开发者

add return carriage from input field after post in php

Hello all I am working on a project at work where people can send emails from a certain part of the site. There is a开发者_开发百科 body textarea field which represents the body of an email. Return carriages show up on the textarea but when I POST the data and send the email everything shows up on one line. How would I express this when the email is sent so that the return carriages are included in the email format. I am using PHP to send textarea information to my PHP script via the POST array. Any help would be greatly appreciated


It depends on format of letters. For html, use this:

$text = nl2br($text);

plain text should work fine with usual symbols.


are you sending html mail? in that case nl2br() is your friend (http://php.net/nl2br). Otherwise newlines should just show up in the source of the mail...


You could do this:

$trans[chr(15)] = "\n";
$the_string = strtr($the_string, $trans);

Should do the trick.


What I understand is that the end user, who reads your mail, reads it in HTML format where as the email is composed in text. Things you can do is to insert line breaks or <br> tags for all carriage returns. I would in fact suggest you to use something like PHPMailer which takes care of mos of these things.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜