How to Add Clickable Email Links in HTML
Adding mail links in HTML allows users to quickly send an email by clicking a link that opens their default email client with the recipient’s address automatically filled in. Mail links in html improves accessibility and user experience by allowing instant communication without manually copying email addresses. It is most commonly used in website contact sections, “Email Us” buttons, customer support pages, newsletters, and promotional emails where direct feedback or inquiries are encouraged.
The correct way of sending mail in html:
<a href="mailto:info@example.com">Email Us</a>
Explanation:
- Uses the proper
mailto:
protocol. - Clicking the link opens the user’s default email client with a new message addressed to info@example.com.
Adding Mail Links in HTML
Email links (also called mailto links) let users click a link or button to open their default email client with a pre-filled recipient, subject, or message.
1. Basic Mailto Link
The simplest form uses the mailto:
scheme in an <a>
tag.
<a href="mailto:example@example.com">Email Us</a>
👉 When clicked, it opens the user’s default mail app with a new message addressed to example@example.com
.
2. Add a Subject Line
You can prefill a subject line using a query parameter:
<a href="mailto:example@example.com?subject=Hello%20There">Email Us</a>
%20
encodes spaces.- Always URL-encode your parameters.
3. Add Body Text
You can include message body text as well:
<a href="mailto:example@example.com?subject=Feedback&body=Hi%20there,%0A%0AI%20have%20a%20question.">
Send Feedback
</a>
Notes:
%0A
adds line breaks.- Use plain text only (HTML won’t render inside mailto bodies).
4. Add CC and BCC Recipients
You can add multiple recipients and copy (CC) or blind copy (BCC) addresses:
<a href="mailto:example@example.com?cc=team@example.com&bcc=manager@example.com">
Email Support Team
</a>
You can combine with subject and body too:
<a href="mailto:example@example.com?cc=team@example.com&subject=Support%20Request&body=Please%20describe%20your%20issue.">
Contact Support
</a>
5. Add Multiple Recipients
Separate multiple email addresses with commas:
<a href="mailto:user1@example.com,user2@example.com">Email Both</a>
6. Use Mailto in Buttons
While <a>
tags are standard, you can style them as buttons:
<a href="mailto:info@example.com" style="display:inline-block;padding:10px 20px;background:#007BFF;color:#fff;border-radius:6px;text-decoration:none;">
Contact Us
</a>
Or wrap a <button>
with JavaScript:
<button onclick="window.location.href='mailto:info@example.com'">Email Us</button>
7. Use JavaScript for Dynamic Mail Links
If you want to obfuscate email addresses from bots or add them dynamically:
<script>
const user = "info";
const domain = "example.com";
const subject = "Inquiry";
const body = "Hello%20team,";
document.write(
`<a href="mailto:${user}@${domain}?subject=${subject}&body=${body}">Email Us</a>`
);
</script>
✅ Helps reduce spam by avoiding plain-text exposure of your email.
8. Use mailto:
in Form Submissions (Not Recommended)
You can use mailto:
as a form action
, but it’s unreliable because it depends on the user’s local mail client.
<form action="mailto:info@example.com" method="post" enctype="text/plain">
<input type="text" name="name" placeholder="Your name">
<input type="email" name="email" placeholder="Your email">
<textarea name="message"></textarea>
<button type="submit">Send</button>
</form>
⚠️ Avoid this in production, instead use a backend script or service instead.
9. HTML Entities for Spam Protection
Hide your email address from bots using character entities:
<a href="mailto:info@example.com">
Contact
</a>
This renders correctly for humans but is harder for crawlers to read.
10. Accessible Mail Links (a11y Best Practices)
Always include clear link text for screen readers:
<a href="mailto:support@example.com" aria-label="Email the support team">Support</a>
Avoid “Click here” — use descriptive text like “Email Customer Support.”
11. Using mailto:
in Markdown or CMS
For Markdown (like in README files or blogs):
[Email Me](mailto:hello@example.com)
Or in CMS editors, you can usually insert a link and choose “Email” as the type.
12. Adding Mailto Links in HTML Email Templates
In email templates themselves, mailto:
works fine:
<a href="mailto:support@tabular.email">Contact our team</a>
✅ Supported by all major email clients.
Common Problems and Troubleshooting
- Issue: Link opens nothing
- Cause: No default mail client configured
- Solution: Add alternate contact
- Issue: Spaces not working
- Cause: Unencoded spaces
- Solution: Replace with
%20
- Issue: Wrong subject or body
- Cause: Misplaced
?
or&
- Solution: Follow correct query order:
mailto:address subject=...&body=...
- Cause: Misplaced
- Issue: Spam Email exposed in code
- Solution: Use JS or entity encoding
Best Practices for Adding Mail Links in HTML
- ✅ Always URL-encode parameters
- ✅ Keep text descriptive and accessible
- ✅ Avoid exposing raw emails (spam risk)
- ⚠️ Avoid using
mailto
in forms for real communication - 💡 Consider adding “copy email” buttons as a fallback
Bonus: “Copy Email to Clipboard” Alternative
You can combine modern UX with JavaScript:
<button onclick="navigator.clipboard.writeText('info@example.com')">
Copy Email Address
</button>
Add a tooltip like “Copied!” for a smooth user experience.
Example Mailto Link
<a href="mailto:support@example.com?cc=info@example.com&bcc=manager@example.com&subject=Website%20Feedback&body=Hi%20team,%0A%0AI'm%20reaching%20out%20about%20your%20services.">
Email Our Support Team
</a>
Final Words
Adding mail links in HTML is a simple yet powerful way to improve user interaction and accessibility on your website. When implemented correctly, mailto
links provide an instant communication channel that encourages engagement and makes it easier for users to reach you directly. However, always remember to use them responsibly by encoding parameters properly, keeping link text clear and accessible, and protect your email addresses from spam.
While mailto
links work great for quick contact options, consider using contact forms or backend email handlers for professional or large-scale use cases to ensure reliability and better data management.