php: Textarea HTML value to show in Html Email?

自闭症网瘾萝莉.ら 提交于 2019-12-23 04:20:32

问题


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.

  • Actually the mail itself is HTML already.
  • I can embed Images.. etc as well.
  • Just the <textarea> is not working.

I am using this:

$mail->IsHTML(true);
$mail->Body = $_POST['textarea'];

Lets say the <textarea> contains something like:

Hello,
How are you.

Best Wishes,
4lvin

Then in the email, it is showing just like:

Hello, How are you. Best Wishes, 4lvin

Any idea please? :(


回答1:


use

$mail->IsHTML(true);
$mail->Body = nl2br($_POST['textarea']);


来源:https://stackoverflow.com/questions/13816746/php-textarea-html-value-to-show-in-html-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!