Ayush Arora

Mar 16, 20222 min

What is an HTML email Link, how to build one, samples, and code generator

Updated: Mar 25, 2022

In this we will cover:

  1. What is mailto link?

  2. How to create mailto link in HTML?

  3. mailto examples

  4. mailto link code generator

What is mailto link

Mailto link is a type of HTML link that activates the default mail client on the computer for sending an e-mail. The web browser requires a default e-mail client software installed on his computer in order to activate the e-mail client. If you have Microsoft Outlook, for example as your default mail client, pressing a mailto link will open a new mail window.

How to create mailto link in HTML

The mailto link is written like regular link with extra parameters inside the href attribute:

<a href="mailto:name@email.com">Link text</a>

mailto examples

Mail to email address

<a href="mailto:ayush@ayusharora.com">Send mail</a>

The code will generate this link: Send mail

Pressing the above link will open a new mail window:

Mail to email address with subject

<a href="mailto:ayush@ayusharora.com?subject=The%20subject%20of%20the%20mail">Send mail with subject</a>

The %20 represents space character. The code will generate this link: Send mail with subject

Pressing the above link will open a new mail window:

Mail to email address with cc, bcc, subject and body

aa<a href="mailto:name1@ayusharora.com?cc=name2@ayusharora.com&bcc=name3@ayusharora.com&subject=The%20subject%20of%20the%20email@body=The%20body%20of%20the%20email">Send mai with cc,bcc,subject and body</a>

The %20 represents space character. The code will generate this link: Send mail with cc, bcc, subject and body

Pressing the above link will open a new mail window:

How to add spaces in the mail's subject or body

You can add spaces by writing %20 in the text of the subject or body.

<a href="mailto:name@mail.com?subject=The%20subject&body=This%20is%20a%20message%20body">Send mail</a>

How to add line break in the mail's body

You can add newline by writing %0D%0A in the text of the body.

<a href="mailto:name@mail.com?body=Line1-text%0D%0ALine2-text">Send mail</a>

How to add multiple email recipients

You can add multiple recipients by writing a comma separator (,) between email addresses.

<a href="mailto:name1@mail.com,name2@mail.com">Send mail</a>

Are there downsides to using mailto links?

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.

Advantages of using mailto links

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.

To configure your gmail account to open all mailto links, you can check the step-by-step guide here.

Mailto link code generator

    680
    1