How to Create a Mailto Link

Email Links on Your Website - Part 2

Email @-sign - Image © Michael Bretherton
Image © Michael Bretherton

Mailto links are links on web pages that point to an email address instead of to a web page URL (either somewhere else on your site or out on the Web on another site) or another resource like an image, video, or document. When a website visitors clicks on one of these mailto links, the default email client on that person's computer opens and they can send a message to that email address specified in the mailto link.

These links are a great way to provide a contact option on your website, but they do come with some challenges (which we will cover shortly).

Creating a Mailto Link

To create a link on your website that opens an email window, you simply use a mailto link. For example:

<a href="mailto:webdesign@aboutguide.com">Send me an email</a>

If you want to send email to more than one address, you simply separate the email addresses with a comma. For example:

<a href="mailto:email1@aboutguide.com,email2@aboutguide.com">

In addition to the address that should receive this email, you can also set up your mail link with a cc, bcc, and subject. Treat these elements as if they were arguments on a URL. First you put the to address as above. Follow this with a question mark (?) and then the following:

  • cc=emailaddress for a Cc
  • bcc=emailaddress for a Bcc
  • subject=subject text for a Subject

If you want multiple elements, separate each with an ampersand (&).

For example (write this all on one line, and remove the » characters):

<a href="mailto:html@aboutguide.com? »
bcc=gethelp@aboutguide.com »
&subject=testing">

 

The Downside of Mailto Links

Using mailto links can lead to spam being sent to the emails specified in those links. Many spam programs exist that crawl websites harvesting email addresses to use in their spam campaigns or to perhaps sell to others who will use these emails in this fashion.

In truth, this is one of the most common ways that spammers get email addresses to use in their schemes. Even if you don’t get a lot of spam, or have a good spam filter to try to block this type of unsolicited and unwanted communication, you might still get more email than you can handle. I've spoken to many people who get dozens or even hundreds of spam emails a day! To help prevent this from happening, you can consider using a web form on your site instead of a mailto link.

Using Forms

If you are worried about getting an unwieldy amount of spam from you site, you may want to consider using a web form in place of a mailto link.Those forms can also give you the ability to do more with these communications, since you can ask specific questions in a way that a mailto link does not allow for. With the answers to your questions, you may be able to better sort through email submissions and respond to those inquires in a more informed manner.

In addition to being able to ask more question, using a form also has the advantage of not (always) printing an email address on the web page for spammers to harvest.

Written by Jennifer Kyrin. Edited by Jeremy Girard on 8/11/16

Previous Page > Why Contact Information is Critical for a Website
Next Page > Using Web Forms for Contact Mail > The Web Design @ About.com Contact Solution