How to Build a Mailto Hyperlink with Subject in HTML

Learn how to build a mailto hyperlink with subject in HTML, encode special characters, add cc, bcc, and body, and avoid cross-client pitfalls.

•

Published on

•

Updated

•

How to Build a Mailto Hyperlink with Subject in HTML
Do not index
Do not index
A contact link can look harmless and still cost replies. If a support page sends visitors into a blank email draft with no subject, teams lose context, delay responses, and make it easier for messages to get buried. A mailto hyperlink with subject fixes part of that problem by opening the visitor's email client with a ready-made subject line, which reduces friction and makes the reply easier to sort.
That matters for more than convenience. A clear subject improves the odds that the message is understood quickly, routed correctly, and handled by the right person, whether it's a sales inquiry, a refund request, or a product bug. The pattern has been standardized for a long time, first in RFC 2368 in July 1998 and later in RFC 6068 in October 2010, which formalized header-style fields like subject, cc, and bcc.
Table of Contents

Why a Prefilled Subject Changes Contact Conversions

A support page, a sales contact link, and a “send feedback” button all run into the same friction point. The visitor has to decide what to write, where it should go, and how to label the message. Some people stop right there. A mailto hyperlink with subject reduces that hesitation by carrying the intent into the draft before the user starts typing.

What happens after the click

The browser does not send the email itself. It passes the mailto: URI to the user's email client, which opens a new draft with the recipient already filled in and the subject line preloaded. On a desktop with a configured mail app, that feels like handing off a note card. The browser writes the address on the card, then the mail client decides how to open it.
A minimal example looks like this:
mailto:support@example.com?subject=Billing%20Question
The ?subject= part starts the first header field, and the subject text should be URL-encoded so spaces do not break the URL. The same header-style structure appears in Yoast's mailto guide, and the mailto scheme is defined in the older Wikipedia entry for RFC 2368 and RFC 6068. In practice, the field is simple, but the client that receives it may not be.
Client behavior is where many tutorials stop too early. Some mail apps open the draft immediately, some ask the user to choose an app first, and some browser and mobile setups ignore parts of the URI or handle them inconsistently. Long prefilled subjects can also hit practical limits sooner than expected, especially once you add body text or several parameters. If the message needs a longer follow-up path, use a form or a dedicated flow like this follow-up email path for contact intent.
notion image
The reason this pattern keeps working is straightforward. It does not depend on a custom backend, and it does not ask the visitor to learn a new flow before sending the first message. The tradeoff is that the experience depends on the user's own email setup, which means a mailto: link is a good fit for quick contact intent, but a poor fit when you need validation, routing rules, or reliable capture across clients.

The Core Syntax and Every Supported Parameter

A mailto: link works like a small set of instructions packed into one URL. You start with the scheme, then the recipient address, then a question mark, and then the parameters you want to prefill. The first parameter uses ?, and every one after that uses &. That part is simple once you read it the way a browser does, but it is also where people usually slip when they add one field too many.

Read the URL like a sentence

A plain subject-only example is:
mailto:hello@example.com?subject=Demo%20Request
A subject plus body example is:
mailto:hello@example.com?subject=Demo%20Request&body=Hi%20team%2C%0A%0APlease%20send%20pricing%20details.
A fuller version with copy and blind copy fields is:
mailto:hello@example.com?subject=Demo%20Request&cc=manager@example.com&bcc=archive@example.com&body=Hi%20team
Multiple recipients can be separated by commas, and parameters like body, cc, and bcc can be added after the first field. The same structure is described in Mail-Signatures' overview of mailto fields, which is useful when you want to check how each field fits into the URI without guessing at the syntax.
Parameter
What it prefills
Multiple values
Encoding needed
subject
Email subject line
No, one value
Yes
body
Draft message body
No, one value
Yes
cc
Carbon copy recipients
Yes, comma-separated
Yes
bcc
Blind carbon copy recipients
Yes, comma-separated
Yes
The recipient line can be empty if you only need the draft to open with headers already in place. That is useful for contact widgets that let the user choose the target later, while still giving them a head start on the message itself.
A common mistake is treating the parameters like HTML attributes or raw query strings that can be pasted in without changes. They are URI components, so every value should be handled as encoded text, not as plain human-readable copy. Once you keep that rule in mind, the syntax is much easier to reason through, especially when the subject includes spaces, punctuation, or a longer phrase that would otherwise break the link.

Encoding Spaces, Newlines, and Special Characters

Encoding is where most broken mailto links start. A link can look correct in the source code and still fail in the browser if the subject or body contains spaces, punctuation, or line breaks that weren't escaped first. The safest mental model is simple, if a character has special meaning in a URL, encode it before putting it in the link.

The characters that cause the most trouble

Character
Encoded form
When to use it
Space
%20
In subject lines and body text
Newline
%0A
For line breaks in the body
Comma
%2C
When it belongs inside a value
Question mark
%3F
When it belongs inside a value
Ampersand
%26
When it belongs inside a value
A multi-line body usually uses %0A%0A between paragraphs. That keeps the draft readable instead of turning it into one long block of text. Mailtrap's mailto explanation and Tutto Semplice's mailto guidance both show the same core pattern, including %20 for spaces and %0A for line breaks.
notion image

A simple developer shortcut

In JavaScript, encodeURIComponent() handles most of this safely. That means the code can build the subject and body from plain strings, then encode the values before concatenating the final URL. It also helps avoid the classic bug where an ampersand inside the subject gets misread as the start of another parameter.
There's also a practical size issue. Long prefilled bodies can become brittle across browsers and mail clients, so short messages are more reliable than verbose templates. If the draft needs long legal text, tracking snippets, or structured fields, a form is usually the better path.

How Common Email Clients Handle Subject and Body

A mailto: link does not send anything by itself. It hands the request to the user's chosen mail handler, and that extra handoff is where behavior starts to vary. The operating system, desktop app, browser integration, and mobile defaults all get a say, so a link that looks clean in code can open a different draft in Outlook, Apple Mail, Gmail web, iOS, and Android.
notion image

What users usually see

Outlook desktop and Apple Mail commonly open a new draft with the subject field already filled in when the link is valid. Gmail web often routes the click into a browser compose window if it is the default handler. On iOS and Android, the result depends heavily on which mail app is set as default, and some clients are less forgiving about long bodies or encoded characters.
Client or handler
Typical subject support
Typical body support
Practical risk
Outlook desktop
Usually renders subject
Usually renders body
Can vary with local mail setup
Apple Mail
Usually renders subject
Usually renders body
Local app rules still apply
Gmail web
Often opens compose flow
Often carries body
Browser and default-handler dependent
iOS and Android mail handlers
Depends on default app
Depends on default app
Special characters may fail without warning
The key point is simple. The link is a request, not a guarantee. Microsoft's mailto documentation) describes the basic navigation pattern, while community discussion around mailto subject and body support in email clients shows how uneven client support can be. If the message flow looks odd and you need to check what reached the server, reading email headers during debugging can help separate a client issue from a delivery issue.
That matters because a link can behave well in one setup and break in another. Long subject lines, long body text, and special characters are the places where differences show up first. If the subject is business-critical, keep the link simple and avoid formatting tricks that only some clients preserve.

When Mailto Is the Wrong Tool for the Job

A mailto link is fast, but speed isn't always the goal. If the visitor needs to send a long explanation, upload files, choose a category, or consent to a policy, a contact form does a better job than a prefilled email draft. Structured flows also make it easier to reduce spam, capture analytics, and route the request to the right queue.

Good fit versus bad fit

Use mailto: when the message is short, the audience is trusted, and the main goal is to remove friction. Use a form when the team needs validation, reporting, spam protection, or a predictable submission path. For accessibility-sensitive journeys, a plain form can also be easier than having a screen reader announce a raw encoded URL.
The rough decision rule is straightforward:
  • Short, low-risk requests: mailto: can be fine.
  • Long or structured intake: a form is usually better.
  • Need analytics or CRM handoff: use a form or messaging integration.
  • Mobile-first or app-based audiences: test carefully before choosing email as the default.
Exclaimer's mailto guidance points out the gap that many tutorials skip, client-specific behavior and fallback differences. That gap matters because the same link can feel polished on one device and awkward on another.
There's also a security angle. Publicly exposed email addresses can be harvested by scrapers, and a bare mailto link makes that easier. If the contact path sits on a high-traffic page, a relay address or a form often creates a cleaner boundary between the public web and the inbox.

Accessibility, Security, and Deliverability Best Practices

Accessible link text matters because screen readers don't care that a subject line is encoded neatly in the source. They read what's visible, and if the visible text is just a raw address or a long encoded string, the experience gets noisy fast. A better pattern is clear human text, with an optional aria-label when the context needs more detail, which lines up with guidance from WebAbility.io's WCAG overview.

Keep the link usable for everyone

The visible label should say what the action does, not just where it points. “Email support about billing” is better than a bare address, and it gives keyboard and screen-reader users a clearer target. For a public site, that also keeps the page cleaner for sighted visitors scanning for the next step.

Don't confuse the link with the mail system

A mailto link doesn't affect sender reputation by itself, but the message it creates still enters the email ecosystem. If that message later feeds a workflow, outreach sequence, or high-volume contact process, the domain behind it still needs healthy authentication and infrastructure.
That's where deliverability checks matter. Verifying SPF, DKIM, DMARC, MX, and blacklist status helps confirm that mail infrastructure is configured correctly before the contact flow scales. If the receiving side is misconfigured, even a perfect subject line won't rescue inbox placement.
A quick checklist helps:
  • Use descriptive visible text so the link is understandable without decoding.
  • Avoid exposing raw addresses on public pages when scrapers are a concern.
  • Test the default mail handler on desktop and mobile.
  • Check authentication and DNS health before relying on email at scale.
  • Choose forms for structured or high-volume journeys where predictability matters more than convenience.
For teams seeking a quicker method to diagnose the mail aspect of that setup, a live deliverability audit reveals what's functioning and what's malfunctioning before the contact flow negatively impacts inbox placement. That's the practical layer these teams require when the objective is fewer failures and clearer fixes.
If mailto links are part of a support flow, outbound process, or AI-assisted contact journey, the next step is to verify the email infrastructure around them before traffic grows. Run a free deliverability audit with mailX to check DNS, authentication, blacklist status, and mail server health in one place. It's the fastest way to spot what could block replies or damage inbox placement before the problem spreads.

Most senders lose 30–70% of their emails to spam without knowing it.

Get a free expert audit of your domain, email authentication, and infrastructure. Identify hidden issues and fix them fast.

Book Your Free Deliverability Audit

CEO Mailwarm, email deliverability expert.