HTML and CSS Reference
In-Depth Information
A mailto link is straightforward. In fact, it's much easier to create than a contact form and associated back-end
machinery for processing the form. It just requires a standard a element and a mailto URL. The URL is just
mailto: followed by the address. For example, here's a mailto link you can use to reach me:
<a href="mailto:elharo@metalab.unc.edu">
E-mail Elliotte Rusty Harold
</a>
You can encode additional headers in the URL's query string. For example, here's an e-mail link that sets the
Subject line to "Refactoring":
<a href="mailto:elharo@metalab.unc.edu?Subject=Refactoring">
E-mail Elliotte Rusty Harold
</a>
You can encode non-ASCII characters and non-URL legal characters by first converting them to UTF-8 and then
encoding each UTF-8 byte as a percent sign followed by two hexadecimal digits. For example, a space is %20 , so
this link sends e-mail to me with the subject "Refactoring HTML":
<a href=
"mailto:elharo@metalab.unc.edu?Subject=Refactoring%20HTML">
E-mail Elliotte Rusty Harold
</a>
You can separate additional headers from each other with ampersands (which must themselves be encoded as
&amp; in the XHTML). For example, this link CCs the message to another address of mine:
<a href=
"mailto:elharo@metalab.unc.edu?Subject=Refactoring%20HTML&amp;
CC=elharo%40macfaq.com">
E-mail Elliotte Rusty Harold
</a>
You can even set a default body for the e-mail using the query string variable Body . Here's one example:
<a href=
"mailto:elharo@metalab.unc.edu?Subject=Refactoring%20HTML&amp;
Body=I%20love%20Refactoring%20HTML.">
E-mail Elliotte Rusty Harold
</a>
These techniques should suffice to reproduce most contact forms in regular e-mail. I really believe that all e-
mail should be read and responded to by a human being. However, if you need some greater level of
automation, you can achieve it with a two-step process. First, set up a classic contact form that collects a series
of fielded data from the user. The first submission sends it into your CMS and assigns it a unique ID by which it
can be tracked. However, the response, rather than a simple thank you, is actually a confirmation screen that
invites the user to e-mail the response to you. You can provide both a form and a mailto link for doing this. The
Search WWH ::




Custom Search