How to use HTML mailto with examples

The mailto attribute in HTML

In HTML hyperlinks, you can use mailto: in the href to enable users sending the email by using their already set up email program. For example in your website, you have a link “contact us”. When a user clicks on that link the outlook express or some other email program that is set up at user’s machine will be opened.

The mailto syntax

The syntax of the mailto in HTML link is:

<a href=”mailto:toaddress@email.com>Contact</a>

As it can be seen inside the href attribute of the a tag, you can place mailto: followed by “To” email address where you intend to send the email. You may also give the subject of the email after using the email address as shown in the second example of this tutorial.

The example below shows how to link an email address to a hyperlink by using the mailto.

Where you will replace toaddress@email.com address to the actual email address where you want to receive the email.

Specify subject in the HTML mailto

The example below shows how to include subject as well in the mailto in HTML hyperlinks. That means when a user clicks that link, the email program like outlook will open in a new email mode with To and Subject fields already filled by the given information in mailto part of the link.

A final word about mailto HTML

These days you should use mailto hyperlink quite carefully, as spammers catch the given email address and start sending spammed emails. You can also use HTML email forms along with captcha (for security) to decrease spam factor.

Was this article helpful?

Related Articles

Leave A Comment?