开发者

Getting line breaks in a contact form text area to appear in an email

开发者 https://www.devze.com 2023-03-01 02:25 出处:网络
We are currently creating a contact form - how would it be possible to reproduce line breaks in a textarea in the email sent by the contact form?

We are currently creating a contact form - how would it be possible to reproduce line breaks in a textarea in the email sent by the contact form?

Thanks in adva开发者_StackOverflow社区nce


Just wrap your textarea content into <pre> element and define proper font for it in CSS:

<pre>content-of-your-textarea-goes-here</pre>


There are two options -- first, use c-smile's answer; all webmail clients and most if not all desktop clients should render <pre> tags properly.

Your other option is to parse the submitted text-area's text and turn newlines into <br> tags. If you want to be really nice about it you can change on \n into a <br> tag and two newlines in a row into a <p> tag.

This is a message.

With multiple paragraph-like structures.

would become either:

This is a message.<br>
<br>
With multiple paragraph-like structures.

or

<p>This is a message.</p>

<p>With multiple paragraph-like structures.</p>


This may depend on the MSA software, but you could try to use CRLF line breaks instead of LF.

I've had issues with an MS Exchange server once...

0

精彩评论

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