How do I set a proper name for the recipient when in HTML I want to use the \"mailto\" tag.
Something like:
mailto:\"John Wayne(jw@email.com)?subject
As mentioned in other answers, RFC 2368 allows the full mailbox
syntax, which can be in name-addr
(display-name
plus angle-addr
) form (RFC 5322). Unfortunately, it was obsoleted by RFC 6068, which only allows addr-spec
form. However, both specifications allow omitting the URI authority (where the to-address usually goes) and specifying full header fields (including To:
) as query parameters. Therefore, mailto:?to=John%20Wayne%20%3cjw@email.com%3e
is valid.
I tried
mailto:John Wayne<jw@email.com>?subject...
and it seems to work.
The original standard for mailto:
links, RFC 1738, says this:
A mailto URL takes the form:
mailto:<rfc822-addr-spec>
where
<rfc822-addr-spec>
is (the encoding of an)addr-spec
, as specified in RFC 822 [6].
Under that definition, no proper name could be included.
But the mailto:
section of RFC 1738 has been superseded by RFC 2368, which allows (among other things, including predefined subject lines) for an RFC 822 mailbox
specification—which includes a proper name.
[2016-05-31] As David Balažic points out in a comment, RFC 2368 is in turn obsoleted by RFC 6068. From Section 9, “Main Changes from RFC 2368”:
The main changes from RFC 2368 are as follows:
- Changed syntax from RFC 2822
<mailbox>
to [RFC5322]<addr-spec>
.
In actual use, mailto:Fred Foo<foo@example.com>
still seems to work, but it’s not officially supported; you may also have to encode the space, i.e., mailto:Fred%20Foo<foo@example.com>
, and/or put the name in quotes, i.e., mailto:"Fred Foo"<foo@example.com>
.
This all depends on what mail client you use. I've tried that long before at Outlook express and it's ok. But after many years, I use Dream Mail and it will only bring in the mail address part while leave out the name part.
You can't set the receipt name on mailto links
Try this: mailto:%22John%20Wayne%22%3cjw@email.com%3e?subject..
Wrap the name in %22
and the email has %3c
before it and %3e
after it and %20
for spaces
That will output: "John Wayne"<jw@email.com>
Full list of URL Encoding here: http://www.w3schools.com/tags/ref_urlencode.asp