Introduction to Mailto Links
Mailto links are a useful feature in HTML that allow users to compose and send emails by simply clicking on a link. These links are commonly used in websites, allowing visitors to contact the site owners or send inquiries directly from their email clients.
In this article, we will explore how to create mailto links in HTML and provide examples of different use cases. Whether you want to add a “Contact Us” link on your website or create personalized email links, this guide will help you get started.
What is a Mailto Link?
A mailto link is an HTML hyperlink that triggers the user’s default email client to compose a new email message. When a user clicks on a mailto link, it automatically opens their email client with the recipient, subject, and body fields pre-filled.
Creating a Basic Mailto Link
Syntax of a Mailto Link
A mailto link uses the mailto:
scheme followed by the email address, subject, and body parameters. The basic syntax of a mailto link is as follows
<a href="mailto:[email protected]">Email Us</a>
In the above example, clicking on the “Email Us” link will open the user’s default email client and pre-fill the recipient field with “[email protected]“.
Adding Subject and Body Parameters
To pre-fill the subject and body fields in the email, you can include additional parameters in the mailto link. Here’s an example:
<a href="mailto:[email protected]?subject=Hello%20World&body=I%20hope%20you%20are%20doing%20well.">Email Us</a>
In this example, the subject parameter is set to “Hello World” and the body parameter is set to “I hope you are doing well.”. Note that spaces are represented by %20
in the URL encoding.
Additional Mailto Link Options
Adding Multiple Recipients
You can include multiple recipients in a mailto link by separating their email addresses with commas. Here’s an example:
<a href="mailto:recip[email protected],[email protected]">Email Us</a>
licking on the “Email Us” link will open the email client with both [email protected] and [email protected] pre-filled in the recipient field.
Including CC and BCC Recipients
To include CC (carbon copy) and BCC (blind carbon copy) recipients in the email, you can use the cc
and bcc
parameters in the mailto link. Here’s an example:
<a href="mailto:[email protected]?c[email protected]&[email protected]">Email Us</a>
In this example, the email client will open with [email protected] in the recipient field, [email protected] in the CC field, and [email protected] in the BCC field.
Specifying a Reply-To Address
You can set a specific email address as the reply-to address by using the replyto
parameter in the mailto link. Here’s an example:
<a href="mailto:recipient@[email protected]">Email Us</a>
Clicking on the “Email Us” link will open the email client with [email protected] in the recipient field and [email protected] as the designated reply-to address.
Styling Mailto Links
Adding Styling to Mailto Links
Mailto links can be styled using CSS to match the design of your website. You can target the <a>
tag and apply styling properties like color, font, and text-decoration. Here’s an example:
<style>
a.mailto-link {
color: #007bff;
text-decoration: none;
font-weight: bold;
}
</style>
<a href="mailto:r[email protected]" class="mailto-link">Email Us</a>
In this example, the mailto link is styled with a blue color, no underline, and bold font weight.
Conclusion
Mailto links provide a convenient way for users to send emails directly from a website. By utilizing the mailto:
scheme and various parameters, you can pre-fill recipients, subjects, and bodies to streamline the email composition process.
In this article, we covered the basic syntax of mailto links, including adding subject and body parameters. We also explored additional options such as multiple recipients, CC and BCC fields, and reply-to addresses. Lastly, we discussed how to style mailto links to match your website’s design.
Now that you have a good understanding of mailto links, you can enhance the user experience on your website by enabling visitors to contact you effortlessly.

My name is Mark Stein and I am an author of technical articles at EasyTechh. I do the parsing, writing and publishing of articles on various IT topics.
+ There are no comments
Add yours