Master the mailto: Command

Posted on June 30, 2013
The mailto: URI scheme defines the structure for Simple Mail Transfer Protocol (aka, SMTP) email addresses. In the early days, the mailto: URI scheme was limited to the web pages to display clickable email links in web pages. Such links, upon click, opens up your default mail client with a compose window.

Nowadays, some latest browsers like Chrome, Firefox, Opera has augmented this basic functionality. These browsers facilitate to enter mailto: command in the browser address-bar, to directly load default mail site/client.

You might be knowing about how to use mailto: command for a single mail recipient. However, mailto: command offers lot more fields that can be used with like multiple recipients, Subject, cc, bcc and so on. The complete list of values are listed in RFC-6068.



Lets master the mailto: command. Consider you are creating a Contact page of your blog and want to put few clickable mailto links. So, when readers click on the links, the email client will open up with a Compose window to allow readers to send you an email.

1. Send email to Single Recipient

Add a mail id right after the mailto: command to send a mail to single recipient.

<a href="mailto:ekgtechbeats@gmail.com">Contact Admin</a>

2. Send email to Multiple Recipients

In case you want to include multiple recipients add comma separated mail ids right after the mailto: command to send a mail to multiple recipients.

<a href="mailto:ekgtechbeats+mkm@gmail.com,ekgtechbeats+vns@gmail.com">Contact Authors</a>

3. Send email with CC

<a href="mailto:ekgtechbeats@gmail.com?cc=ekgtechbeats+mkm@gmail.com,ekgtechbeats+vns@gmail.com">Contact Admin & Authors</a>

4. Share this blog (mail Subject and Body)

Writing a subject line and message body is a little tricky. As some email client converts the space characters to the + sign and some keep space characters as is. The same applies for the new line character in the message body.

To prevent this behavior, add white space in either Subject line or message body using %20. And, to add a new line character inside the message body use %0A.

<a href="mailto:?subject=You%20would%20like%20this%20blog&body=Visit%20http://www.techbeats.co.in">Share This Blog!</a>

It important to add question mark (?) sign right after the "To" line, if you are adding cc, bcc, subject and body fields. Also, all fields after the question mark (?) part must be ampersand (&) separated.