[英]Add a Line Break In HTML Email
I have made a request form for my work and it working as expected.我已经为我的工作制作了一份申请表,它按预期工作。 I have placed some text in the text area as a hide/show for users.
我在文本区域中放置了一些文本作为用户的隐藏/显示。 On the visual studio code, I see the line breaks fine but when I submit the form and the recipient gets the email all that was in the text area is all in one line instead of line break where I wanted.
在 visual studio 代码中,我看到换行很好,但是当我提交表单并且收件人收到 email 时,文本区域中的所有内容都在一行中,而不是我想要的换行符。
Also how to kill the extra white spaces.还有如何消除多余的空白。 Also have used this
也用过这个
Is there any fix to this?有什么办法解决这个问题吗?
I get this in email DC GM Groups Domain Group Access: All Folders and Drives Required Distribution List: All Emails
我在 email
DC GM Groups Domain Group Access: All Folders and Drives Required Distribution List: All Emails
中得到这个
Tried everything I could research but doesn't seem to work尝试了我能研究的一切,但似乎没有用
white-space: nowrap; text-align: left; width: 650px;
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="col-6"> <:-- style="visibility;hidden:" --> <;-- acc means account --> <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10"> Domain Group Access;  All Folders and Drives Required
: Distribution List;  All Emails </textarea> </div>
To answer your first two questions回答你的前两个问题
The easiest way to format like it is in the text area is to put the text between <pre>...</pre>
tags像在文本区域中一样格式化的最简单方法是将文本放在
<pre>...</pre>
标记之间
The other thing you could do is use regular expressions to switch from text to html, like您可以做的另一件事是使用正则表达式从文本切换到 html,例如
text.replace(/[\n]/g,"<br>");
text.replace(/\s\s+/g,function(part) {
return part.substring(0,1);
}));
A textarea
will render whitespace as it was entered into the element so just format the whitespace by literally adding it. textarea
将呈现空格,因为它被输入到元素中,因此只需通过逐字添加它来格式化空格。
<div class="col-6"> <textarea class="textarea" id="acc_GMGroup" name="acc_GMGroup" rows="10"> Domain Group Access: All Folders and Drives Required Distribution List: All Emails </textarea> </div>
So i was able to do deep research and found you can do this to make it work: just add nl2br所以我能够进行深入研究,发现你可以这样做来让它工作:只需添加 nl2br
$usersGMGroup = nl2br($_POST["acc_GMGroup"]);
Thank you to all the people that helped to resolve the issue感谢所有帮助解决问题的人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.