HTML Email Links Tutorial
Another use of HTML hyperlink is to create an email link and clicking on it will open the default email client in your computer. The hyperlink reference element “mailto:email_id” is used within the anchor <a> tag to create an email link.
<a href="mailto:email@example.com">Contact Us</a>
It looks like below in a web page:
Clicking on the link will open the new email window using default email client configured on your computer. Generally the email client will be Microsoft Outlook on Windows based PCs and Mail App on Mac. The “To” address filed will be prefilled with the email id from “mailto:” attribute.
Email Link with Subject
You can easily add a subject to your email by using the below HTML code.
<a href="mailto:firstname.lastname@example.org?Subject=Thanks%20for%20tutorials" target="_blank"> Contact Us</a>
The result on the browser will look similar to normal email link like below:
When you click on the link, you will see new email is opened with subject line.
Email link with CC and BCC
If you want to create an email link with CC and BCC then use the CC & BCC attributes within “href” as below.
<a href="mailto:email@example.comfirstname.lastname@example.orgemail@example.com&Subject= Thanks%20for%20tutorials" target="_blank">Contact Us</a>
It will look similar to normal email link on the browser.
Clicking on the link will open the email with CC and BCC filled.
Using Emails in a Web Page
Now that you know how to use email links!!! But the question is – is it safe to use emails on web pages? The answer is – No, it is not safe. The “mailto:” attribute will reveal the email ids to automated bots and users. Hence, avoid using direct email links in your web pages as explained above.
There are plenty of bad automated bots crawl and index the web content for illegal uses. These bots will get your email id and start sending spam emails. In order to avoid the spamming issue HTML forms can be used with human verification like CAPTCHA code.