Matthew
Matthew

Reputation: 15632

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 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?

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

Upvotes: 32

Views: 63597

Answers (5)

Chandra Kumar
Chandra Kumar

Reputation: 1

Use the anchor tag without href:

<a>link</a>

This will be considered as text.

Upvotes: -3

Raymond Skinner
Raymond Skinner

Reputation: 159

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: [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

Upvotes: 13

Brian Moeskau
Brian Moeskau

Reputation: 20419

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.

Upvotes: 17

Dmytro Evseev
Dmytro Evseev

Reputation: 11581

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.

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

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.

Upvotes: 26

Related Questions