HTML:在电子邮件主题中插入换行符,例如 %20 是空格吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15019689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:48:44  来源:igfitidea点击:

HTML: insert line-break in email subject like %20 is a space?

htmlemail

提问by matt

BreakHere…

打破这里…

I wonder if it is possible to write something like %20(which stands for a space) for a line-break as well. So I want to have seperate lines in my body of the e-mail.

我想知道是否也可以%20为换行符编写类似(代表空格)的内容。所以我想在我的电子邮件正文中有单独的行。

Any ideas?

有任何想法吗?

回答by MikroDel

You should use a carriage return %0Dand line feed %0A

您应该使用回车%0D和换行%0A

<a href="mailto:[email protected][email protected]&subject=your subject&body=Text before new line.%0D%0AText after new line.">create email</a>

This is defined in RFC2368and is the only valid method of generating a line-break.

这在RFC2368中定义并且是生成换行符的唯一有效方法。

回答by olibre

Replace \n(and \r\n) by %0D%0Aas specified by RFC6068(in section 5) updating the mailtoURI Schemeas of October 2010 (replacing RFC2368).

替换\n(和\r\n)由RFC6068(在第 5 节中%0D%0A指定,更新截至 2010 年 10 月的URI 方案(替换RFC2368)。mailto

[...] line breaks in the body of a message MUST be encoded with "%0D%0A".
Implementations MAY add a final line break to the body of a message even if there is no trailing "%0D%0A"in the body [...]

[...] 消息正文中的换行符必须使用"%0D%0A".
即使正文中没有尾随"%0D%0A"[...]

This is the example from the RFC (in section 6)

这是来自 RFC 的示例(在第 6 节中

<mailto:[email protected]?body=send%20current-issue%0D%0Asend%20index>

The above mail body corresponds to:

上述邮件正文对应于:

send current-issue
send index