Html 电子邮件格式基础知识(纯文本电子邮件中的链接)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5315464/
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
Email formatting basics (links in plain text emails)
提问by Matthew
Sending an email from a server isn't quite as easy as sending it from a client.
从服务器发送电子邮件并不像从客户端发送电子邮件那么容易。
I know I can choose to send plain text or html, but I want to keep things as simple as possible.
我知道我可以选择发送纯文本或 html,但我想让事情尽可能简单。
I have a link in the email that the user should click to reset their password.
我在电子邮件中有一个链接,用户应该点击该链接来重置他们的密码。
When I send the whole link, and check my gmail, it becomes a hyperlink automatically.
当我发送整个链接并检查我的 gmail 时,它会自动变成一个超链接。
My guess is that this isn't the case in all email clients.
我的猜测是,并非所有电子邮件客户端都是这种情况。
What are my options for sending a link in plain text format?
以纯文本格式发送链接的选项有哪些?
Is the only way to be sure to have a clickable link to use html?
是确保使用 html 的可点击链接的唯一方法吗?
If I use html, what is the minimum markup I must have?
如果我使用 html,我必须拥有的最低标记是多少?
采纳答案by Diodeus - James MacFarlane
If you send your email in plain text, then your URL will be plain text. It's plain text, you can't dress it up.
如果您以纯文本形式发送电子邮件,那么您的 URL 将是纯文本。这是纯文本,你不能修饰它。
If you send it as HTML, just use a simple anchor tag and use the URL as both the href and the text. That way if a mail client removes the link at least the user will still be able to copy/paste the url.
如果您将其作为 HTML 发送,只需使用一个简单的锚标记并将 URL 用作 href 和文本。这样,如果邮件客户端删除链接,至少用户仍然可以复制/粘贴 url。
回答by Brian Moeskau
Another option rather than simply including urls inline in your text is to use a markdown-ish syntax that allows you to separate the two. For example, using citation-style link references (a la the way SO does it in this editor) could be done like so:
另一个选择而不是简单地在文本中包含内联 url,是使用 markdown-ish 语法,允许您将两者分开。例如,使用引文样式的链接引用(就像在这个编辑器中那样)可以像这样完成:
Hello, this is a plain email that links to a [cool page][1]. Sincerely, Joe [1]: http://foo.com/cool_page
Hello, this is a plain email that links to a [cool page][1]. Sincerely, Joe [1]: http://foo.com/cool_page
I've seen it done this way and it works well, especially if you have a lot of links.
我已经看到它以这种方式完成并且效果很好,特别是如果您有很多链接。
回答by Raymond Skinner
There is a syntax similar to angle-addr
as defined in RFC2822and mailto
URL Schema defined in RFC2368.
有类似的语法angle-addr
中定义的RFC2822和mailto
URL架构中定义RFC2368。
RFC2396mentions using angle brackets as delimiters around URI in text documents and protocol fields:
RFC2396提到使用尖括号作为文本文档和协议字段中 URI 的分隔符:
The angle-bracket "<" and ">" and double-quote (") characters are excluded because they are often used as the delimiters around URI in text documents and protocol fields. The character "#" is excluded because it is used to delimit a URI from a fragment identifier in URI references (Section 4). The percent character "%" is excluded because it is used for the encoding of escaped characters.
delims = "<" | ">" | "#" | "%" | <">
尖括号“<”和“>”和双引号 (") 字符被排除在外,因为它们经常用作文本文档和协议字段中 URI 的分隔符。字符“#”被排除在外,因为它用于从 URI 引用中的片段标识符分隔 URI(第 4 节)。排除百分比字符“%”,因为它用于转义字符的编码。
delims = "<" | ">" | "#" | "%" | <">
Example derived from real-world usage:
来自实际使用的示例:
From: [email protected]
To: [email protected]
Content-Type: text/plain
Some introduction text
The text I want to display in this link<https://some.target.dom/ain#place?i=want&to=go>
The rest of my plain text message
回答by Dmitry Evseev
To send html emails you have to provide full structured html page with no relative links (only full urls) for any resources(images src, styles and href link attributes).
要发送 html 电子邮件,您必须提供没有任何资源(图像 src、样式和 href 链接属性)的相对链接(只有完整 url)的完整结构化 html 页面。
But text emails are good enough for their purposes, in web mail clients links are found in mails text by browser, and standalone mail clients do this work by themselves.
但是文本电子邮件对于它们的目的来说已经足够了,在 web 邮件客户端中,浏览器可以在邮件文本中找到链接,而独立的邮件客户端自己完成这项工作。