The full guide to mailto links!

sending-email.jpgFor a small project I had to create a smart mailto: link to make my life a bit easier. I wanted it to hold not only a to and the subject (I'd figured that much out) but a multi lined body too.

Turns out that is pretty darn easy to do. So, for my own reference, and yours, here's a complete overview of everything possible with a mailto link.

There are a couple of variables you can use, and you'd have to do that in standard URL format:

<a href="mailto:info@example.com?subject=subject&cc=cc@example.com">mail link</a>

Here are the variables you can use in these mailto links:

mailto: to set the recipient, or recipients, separate with comma
&cc= to set the CC recipient(s)
&bcc= to set the BCC recipient(s)
&subject= to set the email subject, URL encode for longer sentences, so replace spaces with %20, etc.
&body= to set the body of the message, you can add entire sentences here, including line breaks. Line breaks should be converted to %0A.

Some mailto examples

Simple mailto link:

<a href="mailto:info@example.com">mail link</a>

mailto link with subject:

<a href="mailto:info@example.com?subject=email%20subject">mail link</a>

mailto link with multiple recipients:

<a href="mailto:info@example.com,email@example.com">mail link</a>

mailto link with a CC:

<a href="mailto:info@example.com?cc=email2@example.com">mail link</a>

mailto with message body already started:

<a href="mailto:info@example.com?body=these%20mailto%20links%20are%20cool">mail link</a>

mailto with 3 lines of message body:

<a href="mailto:info@example.com?body=these%20mailto%0Alinks%20are%0Acool">mail link</a>

mailto with 3 lines of message body and a BCC:

<a href="mailto:info@example.com?bcc=mail2@example.com&body=these%20mailto%0Alinks%20are%0Acool">mail link</a>

As you can see, you can add as many of these as you want and stack them on top of each other. Remember that after the email address you'll use a question mark to prefix the first variable, and ampersands ( & ) for each consecutive variable.

On top of that, for the code to be valid HTML, you have to replace every & with &amp;.

Happy mailing!

Enjoyed this article?

Join 4714 subscribers and subscribe by daily or weekly emails or with RSS to receive more tips, tricks and ideas on improving your website!

22 Responses to “The full guide to mailto links!”

Trackbacks/Pingbacks

  1. Effectize
  2. How To: Creating Mailto Links | WordPress Hacks Log
  3. The full guide to mailto links! | The Affiliate Desk