1. About.com
  2. Computing & Technology
  3. Web Design / HTML

Discuss in my forum

The Mailto Command

Learn How to Write Email Links

By , About.com Guide

See More About:

Putting links on your site is as easy as using the <a> tag, but sometimes people forget that you can link to more than just "http://". If you want people to send you email from your Web page, you can use the "mailto" tag. Then, when your readers click on the link, an email browser opens up to allow them to send you email.

Setting up a Mailto Link

To write an email link just create an anchor link like you would normally, but instead of http:// write mailto: and then your email address. For example, to set up a link to email me, you would write
  <a href="mailto:webdesign.guide@about.com">mail the Web Design/HTML Guide</a>

If you want to send to multiple people, separate the email addresses with a comma:
  mailto:email@address1.com,email@address2.com

But there is so much more that you can do with the mailto links. Most current Web browsers and email clients support more than just the "To" line. You can specify the Subject, send carbon copies, and blind carbon copies.

Advanced Mailto Links

When you create an email link with extra features, you treat it similarly to a CGI script that uses a GET operation (attributes on the command line). Use a question mark after the final "To" email address to indicate you want more than just a "To" line. Then you specify what other elements you would like:

  • cc - to send a carbon copy
  • bcc - to send a blind carbon copy
  • subject - for the subject line

You treat the elements as name=value pairs. The name is the element type listed above that you want to use, and the value is what you want to send. To send a letter to me and cc the Web Design Guide, you would type:
  <a href="mailto:webdesign.guide@about.com?cc=webdesign.guide@about.com">Web Help</a>

To add multiple elements, separate the second and subsequent elements with an ampersand (&).
  mailto:toaddress?cc=ccaddress&bcc=bccaddress

Finally, when adding a subject, keep this in mind, while you can use spaces, they may not come to your email address as spaces. Well, technically they are, but they are sent as URL encoded spaces, so while your browser would know they are spaces, they look like code to you. It's better to separate your words with underlines rather than spaces, as this make it easy for you to read without worrying about how the browsers will interpret it:"mailto:html.guide@about.com?subject=mail_to_the_HTML_Guide".

Putting Mailtos Together

<a href="mailto:webdesign.guide@about.com?subject=here is a mailto link&cc=webdesign.guide@about.com">testing mailto</a>
results in: testing mailto

Previous Features

©2012 About.com. All rights reserved. 

A part of The New York Times Company.