A mailto link allows users to send emails straight from a website using the user's default email client. But how do you create a mailto link in HTML?

In this article, I will walk you through how to create a mailto link in HTML using example code.

Here is the basic syntax for the mailto link:

<a href="mailto:johndoe@fakeemail.com">Example mailto link</a>

In the browser, the user can click on the link and it will open up their default email client.

In this example, when I click on the link it opens up my Mail app and the email address is already populated in the to field.

Screen-Shot-2021-11-14-at-12.07.32-AM
Screen-Shot-2021-11-14-at-12.05.15-AM

Using this method, I would be able to send a quick email and return to the website.

You can add multiple email addresses to the mailto link using this syntax:

<a href="mailto:johndoe@fakeemail.com, janedoe@fakeemail.com">
    Multiple email addresses
</a>

It is important to separate the multiple email addresses using commas.

When I click on the link in the browser, it will open up the Mail app and populate the email addresses in the to field.

Screen-Shot-2021-11-14-at-12.18.17-AM
Screen-Shot-2021-11-14-at-12.18.42-AM

Here is some example code that shows you how to add a subject line to the mailto link.

<a href="mailto:johndoe@fakeemail.com, janedoe@fakeemail.com?subject=this is how to use the mailto link">
    Using the subject parameter
</a>

After the email addresses, you need to add an ? to separate the emails and the subject parameter. If you omit that ?, then the subject link will not work.

Screen-Shot-2021-11-14-at-12.32.41-AM
Screen-Shot-2021-11-14-at-12.34.08-AM

This is an example that shows you how to add CC (carbon copy) and BCC (blind carbon copy) recipients to the mailto link.

<a
    href="mailto:johndoe@fakeemail.com, janedoe@fakeemail.com?cc=jackdoe@fakeemail.com &bcc=jennydoe@fakeemail.com &subject=this is how to use the mailto link">
    Using the CC and BCC parameters
</a>

After the email addresses, you need to add a ? to separate the emails and the CC parameter. You also need to add an & before the BCC and subject parameters.

Screen-Shot-2021-11-14-at-12.44.29-AM
Screen-Shot-2021-11-14-at-12.45.03-AM

This is an example that shows you how to use the body parameter with the mailto link. This lets you add text to the body of your email.

<a
   href="mailto:johndoe@fakeemail.com, janedoe@fakeemail.com?cc=jackdoe@fakeemail.com &bcc=jennydoe@fakeemail.com &subject=this is how to use the mailto link &body=this is an article on how to use the mailto link">
    Using the body parameter
</a>

You need to add an & before the body parameter.

Screen-Shot-2021-11-14-at-12.57.00-AM
Screen-Shot-2021-11-14-at-12.57.17-AM

One of the downsides to using a mailto link is that it does often come across as spam by users. Unfortunately, a lot of spammers will use this option to send emails to users. So just keep that in mind when you're using it.

A good reason to use a mailto link is if you are sending emails to a group of people that you know. If that entire group is using a default email client, then using a mailto link would be a good option over a contact form.