A Web Design Community curated by Chris Coyier

Code Snippets Gallery

Code Snippets > HTML > Mailto Links Submit one!

Mailto Links

Basic

Open default mail program, create new message with the TO field already filled out.

<a href="mailto:someone@yoursite.com">Email Us</a>  

Adding a subject

Open default mail program, create new message with the TO and SUBJECT field already filled out. Essentially we are adding the parameter subject to the href value.

Spaces in the subject will probably work OK, but to be super-extra sure, you can replace spaces with “%20″.

<a href="mailto:someone@yoursite.com?subject=Mail from Our Site">Email Us</a>  

Adding CC and BCC

Open default mail program, create new message with the TO, SUBJECT, CC, and BCC field already filled out. Essentially we are adding the parameters cc and bcc to the href value.

Also note that you add multiple values to CC and BCC by comma separating them.

<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News">Email Us</a>

Adding Body Text

Just add the body parameter into the ever-growing list of parameters we are using.

<a href="mailto:someone@yoursite.com?cc=someoneelse@theirsite.com, another@thatsite.com, me@mysite.com&bcc=lastperson@theirsite.com&subject=Big%20News&body=Body-goes-here">Email Us</a>

6 Responses

  1. JMLeon says:

    Sadly, mailto’s are a call-for-spammers widely, so this is a curiosity more than something to use actually.

  2. @JMLeon: Not if you use Hivelogic’s Enkoder:

    http://hivelogic.com/enkoder

    I just used this today for a client, as a stop-gap till he can set up a contact form.

  3. OldGuy says:

    Although people have been steadfast in their belief that the sky would fall, the world would end, and that their email boxes would overflow with spam if they were crazy enough to use mailto, I have yet to see the problem materialize. I have a number of smallish sites that have been up for years using mailto without ever having a problem. I do use contact forms on larger sites but only because I think it looks more professional.

    Excellent post Chris! Very handy stuff.

  4. I think you can use also the Paragraphs in the body message. Syntax = %0A%0A

    MailTo with multiline message in Body

  5. a href=”mailto:someone@yoursite.com?body=The message’s first paragraph.%0A%0ASecond paragraph.%0A%0AThird Paragraph.”

  6. Brian Lang says:

    Caution: This may NOT work with all mail clients. I’ve had problems getting this to work with some mail clients in the past.

Leave a Comment

Remember:
  • Be nice.
  • Wrap multiline code in <pre> and <code> tags and escape it first (turn <'s into &lt;'s).
  • You may use regular HTML stuff like <a href="">, <em>, and <strong>
* This website may or may not contain any actual CSS or Tricks.