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..
How do I achieve that ??
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..
How do I achieve that ??
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
RFC 6068. From Section 9, “Main Changes from RFC 2368”:
The main changes from RFC 2368 are as follows:
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 will work: mailto:%22John%20Wayne%22%3cjw@email.com%3e?subject..
You have to 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
I tried
mailto:John Wayne<jw@email.com>?subject...
and it seems to work.
<a href="mailto:lala lala2(astark1@unl.edu)?subject=MailTo Comments&cc=ASTARK1@UNL.EDU&bcc=id@internet.node">ddddd</a>
Remember to use only one ? (question mark), when providing multiple entries beyond e-mail address
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.
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.
Encode the uri and assign it to mailto.
Also your email and display name need to be formed as either John Wayne <jw@email.com> or jw@email.com (John Wayne)
.
Make sure you did encodeURI for these. Else it wont work properly in different mailclients.
You can't set the receipt name on mailto links