php:Textarea HTML值显示在Html电子邮件中?
问题描述:
我正在使用PHPmailer,一切都很完美,除了< textarea> 中的文本显示为ONE SINGLE LINE。意思是,没有html值(仅限于TEXTAREA)。
I'm using PHPmailer and everything is perfect except the Texts inside <textarea> are showing as ONE SINGLE LINE. Meaning, no html value (for only TEXTAREA) at all.
- 实际上邮件本身是HTML已经。
- 我可以嵌入图像..等。
- 只是
< textarea>不工作。
- Actually the mail itself is HTML already.
- I can embed Images.. etc as well.
- Just the
<textarea>is not working.
我使用这个:
$mail->IsHTML(true);
$mail->Body = $_POST['textarea'];
让我们说< textarea> 像:
Hello,
How are you.
Best Wishes,
4lvin
然后在电子邮件中,它显示的就像:
Then in the email, it is showing just like:
Hello, How are you. Best Wishes, 4lvin
有什么想法吗? :(
答
使用
$mail->IsHTML(true);
$mail->Body = nl2br($_POST['textarea']);