How to add a subject to an email mailto
link
Summary
Learn how to add subject, carbon copy (CC), blind carbon copy (BCC), and body (email content) fields to a mailto:
link. Follow proper mailto
URL encoding per RFC 3986 to handle special characters and ensure compatibility.
Introduction #
Adding a subject, carbon copy (CC), blind carbon copy (BCC), and body content (email content) to an email mailto
link ensures that when a user clicks the link, their email client opens with the relevant fields pre-filled. This is useful for guiding recipients, improving email clarity, and streamlining communication.
Important: mailto
links rely on the user's default email client, which means they may not work as expected in web-based email services like Gmail, Yahoo!, GMX, Apple Mail, etc. These services typically do not support opening pre-filled emails via mailto
links unless they are specifically configured to handle them.
Understanding the mailto
URL scheme #
The mailto
URL scheme is defined in Request for Comments (RFC) 2368, which specifies how to create hyperlinks that open email clients. Additionally, the convention for encoding information into URLs and Uniform Resource Identifiers (URIs) is defined in RFC 1738 and later updated in RFC 3986. These standards prescribe how to include various headers such as subject
and body
in an email hyperlink.
Basic mailto
syntax #
A basic mailto
link consists of mailto:
followed by an email address:
<a href="mailto:example@example.com">Send Email</a>
Will be rendered as:
This will open the user’s default email client with the recipient field populated.
Adding a subject to a mailto
link #
To add a subject line, use the ?subject=
parameter:
<a href="mailto:example@example.com?subject=Hello">Send Email</a>
Will be rendered as:
When clicked, this link will open an email with “Hello” in the subject line.
Adding CC to a mailto
link #
To add a carbon copy (CC) recipient, use the cc
parameter:
<a href="mailto:example@example.com?subject=Hello&cc=cc@example.com">Send Email</a>
Will be rendered as:
This link opens an email with “Hello” as the subject and cc@example.com
in the CC field.
Adding BCC to a mailto
link #
To add a blind carbon copy (BCC) recipient, use the bcc
parameter:
<a href="mailto:example@example.com?subject=Hello&bcc=bcc@example.com">Send Email</a>
Will be rendered as:
This link opens an email with “Hello” as the subject and bcc@example.com
in the BCC field.
Adding a body to a mailto
link #
To add a pre-filled body (email content), use the body
parameter:
<a href="mailto:example@example.com?subject=Hello&body=This%20is%20a%20test%20email.">Send Email</a>
Will be rendered as:
This link opens an email with “Hello” as the subject and “This is a test email.” in the body.
Adding multiple parameters #
To include more fields, such as body
, cc
, and bcc
, use an ampersand (&
) to separate them:
<a href="mailto:example@example.com?subject=Meeting%20Request&body=Please%20confirm%20the%20meeting.&cc=cc@example.com&bcc=bcc@example.com">Send Email</a>
Will be rendered as:
This link pre-fills the recipient, subject, body (email content), CC (carbon copy), and BCC (blind carbon copy) fields.
Encoding special characters #
URLs cannot contain spaces or special characters directly. They must be percent-encoded according to RFC 3986. For example:
Character | Encoding |
---|---|
Space | %20 |
? | %3F |
& | %26 |
= | %3D |
@ | %40 |
# | %23 |
+ | %2B |
/ | %2F |
: | %3A |
; | %3B |
" | %22 |
' | %27 |
( | %28 |
) | %29 |
, | %2C |
$ | %24 |
% | %25 |
For example, “Meeting Request?” in a subject line should be written as Meeting%20Request%3F
. Encode special characters properly to avoid broken links.
Further readings #
Sources and recommended, further resources on the topic:
- RFC2368: The mailto URL scheme
- RFC1738: Uniform Resource Locators (URL)
- RFC3986: Uniform Resource Identifier (URI): Generic Syntax
License
How to add a subject to an email mailto
link by Jonas Jared Jacek is licensed under CC BY-SA 4.0.
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:
<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/how-to-add-a-subject-to-email-mailto-link">How to add a subject to an email mailto
link</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>
For more information see the Ditig legal page.