开发者

Email formatting basics (links in plain text emails)

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.

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.

My guess is that this isn't the 开发者_如何学Pythoncase 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?

If I use html, what is the minimum markup I must have?


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.

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.


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:

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.


There is a syntax similar to angle-addr as defined in RFC2822 and mailto URL Schema defined in RFC2368.

RFC2396 mentions using angle brackets as delimiters around URI in text documents and protocol fields:

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 = "<" | ">" | "#" | "%" | <">

Example derived from real-world usage:

From: alpha@beta.com
To: theta@omega.com
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


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).

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜