The HTML Mailto Code
HTML links can be coded to send email messages automatically. By tailoring the "href" attribute of an HTML anchor to include the "mailto" syntax, a link can become an email link. When website users click a "mailto" link, it will cause their default email program to start up and open a new message for them. There are additional options and considerations when using "mailto" links, which can affect their usefulness.
-
Function
-
The function of a "mailto" link is simple. Whatever email application the user has set as his default program will open on clicking the "mailto" link. "Mailto" links appear the same as other page links, but what they do is fundamentally different. For this reason, it's advisable to make it clear that a link is a "mailto" link, so that users know clicking it will cause another program to open.
Syntax
-
The syntax for a "mailto" link is exactly the same as any other HTML anchor, except for the value within the "href" attribute. The following example syntax creates a "mailto" link for a specified email address:
<a href="mailto:someone@somewhere.com">Email Us</a>
Inclusion of the word "email" in the visible link text lets users know that the link is an email link rather than a standard link to another page. Within the visible page, the link will appear the same as other links, unless you apply specific styling to it using Cascading Style Sheets.
-
Options
-
The "mailto" link can include a series of options. The default syntax prompts the email program to open an empty email message with the "To" field filled out. You can also include additional options such as multiple recipients, or the subject as follows:
<a href="mailto:someone@somewhere.com?subject=Website Comment">Email Us</a>
Further options can be listed after the question mark character in the "mailto" link, including addresses to copy the message to CC or to BCC and content to include within the message body.
Use
-
The "mailto" link appears within many websites. It provides an automated way for users to get in touch using email. Use of the link reduces the number of steps a user must take to send an email message, so it can be seen as enhancing usability. Use of the additional options such as the "subject" element allows site administrators to see -- at a glance -- that a message has been sent by someone viewing the site.
Considerations
-
The "mailto" link has the disadvantage that it can encourage spam email. Developers can opt to encode the email addresses listed within a "mailto" link in an attempt to reduce this. Common alternatives to the "mailto" link include various types of contact form. Using a contact form is the preferred method for many website owners, as they can tailor the types of input users are able to send.
-
References
Resources
- Photo Credit Medioimages/Photodisc/Photodisc/Getty Images