HTML Tip #1: Subjects in Mailto Links

This tip is dedicated to all the W3C working groups that keep writing things like “you may send your comments to the W3C XSLT/XPath/XQuery mailing list, public-qt-comments@w3.org. It will be very helpful if you include the string [UPD] in the subject line of your comment, whether made in Bugzilla or in email” in their drafts. I’ve gotten tired of making the following suggestion to each and every working group, so let me publish it here publicly for all to see.

It is easy to code a mailto link such that the subject line you’d like correspondents to use appeard automatically in their mail client. That way they don’t have to waste time typing it, and you don’t get so many messages where the correspondent forgets to put the magic keyword in the subject line. Here’s how:

Simply add a query string with a Subject field and a value being the subject line you want to use For example, the link for comments on XQuery updates should be:

<a href= "mailto:public-qt-comments@w3.org?Subject=[UPD]"> public-qt-comments@w3.org </a>

Spaces and other characters that cannot appear in URLs can be percent escaped, just as in http URLs. For example,

<a href= "mailto:public-qt-comments@w3.org?Subject=[UPD]%20Replace%20Me"> public-qt-comments@w3.org </a>

You can use the same trick to include additional headers in the message. Just add another field with a different name. For example, this link CC’s one of the editors of the spec personally:

<a href= "mailto:public-qt-comments@w3.org?Subject=[UPD]&CC=chamberlin%40almaden.ibm.com"> public-qt-comments@w3.org </a>

There are some security issues when setting headers other than Subject, and some e-mail clients may only allow you to set the Subject. Thunderbird does respect both Subject and CC headers. In practice, Subject is the only header I’ve ever needed to set anyway.

This is all completely standards conformant, and is endorsed by the original RFC 2368 that defined the mailto scheme as well as the enhanced version now being developed to replace it.

I will not swear that this works in all e-mail clients. I know it works with Eudora and Thunderbird on the Mac, the only two clients I’ve used with any regularity since I started browsing the Web. I strongly suspect it works in most other clients; and even if it it doesn’t work in a few, it doesn’t harm them to include this. Make your life and your users’ lives simpler. Include subject headers in mailto links.

7 Responses to “HTML Tip #1: Subjects in Mailto Links”

  1. George Bailey Says:

    It works in outlook. You can also specify a “starter” for the body of the email.

    ?&body=The stuff you want to include.%0AThis would be the second line of the body because of the “%0A.”

  2. Oliver Mason Says:

    I never use mailto: links, as I’m too worried they might be harvested by Spam robots. It’s a shame really, as this looks like a very useful idea!

  3. Mark Waschkowski Says:

    In terms of spam robots, if you specify the mailto information from Javascript the robots can’t harvest because it never appears in the source ๐Ÿ˜€

  4. verisimilidude Says:

    If you specify the mailto information in Javascript then a certain portion of your users will never see it appear either. Not everyone runs with Javascript on all the time. I would think anyone browsing on this site would understand that.

  5. merlin65537 Says:

    If you specify the mailto information in Javascript, you can also include a noscript-part where you display the e-mail address in an image, or in a ‘me AT somedomain DOT tld’-like way. This way, people with JavaScript on can simply click the link, while others can still access it using their brain, which we can hope to be something the spam-bots don’t have. If you don’t want external files to your HTML-document, you can just include the image using CSS with a url(data:…) attribute. I have also seen some people providing audio-files where they spell their e-mail address.

  6. kris Says:

    L.S.
    If i want to make something which resembles/looks like a postcard , how can i create a blank ‘ send to field ‘

    Best regards,

    Kris

  7. Alfredo Baylock Says:

    Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my Website ?