Expanding the Mailto tag
Expanding the Mailto: tag
The Mailto tag is used as a way to include an email address on a web page which can be clicked on thus opening the visitors default email client with the email address pre-filled. The mailto code can e expanded to include multiple email addresses, email addresses to CC and BCC, the email subject and even a message body.
The following is the basic mailto tag:
Which would result in: Mailme!
Adding multiple recipients:
TO add multiple mail addresses just add in more addresses after the first address separated by a comma:
<a href=”mailto:email@example.com, firstname.lastname@example.org,email@example.com”>Mailme!</a>
Which results in the following, if you feel like clicking it:Mailme!
Adding emails to Carbon copy (CC) or blind carbon copy (BCC):
Adding recipients to copy the emails to just add cc= or bcc=after the email address.
<a href=”mailto:firstname.lastname@example.orgemail@example.com”>Mail and CC!</a>
<a href=”mailto:firstname.lastname@example.orgemail@example.com”>Mail and BCC!</a>
You should note at this point that we needed to insert a “?” before the CC and BCC ‘functions’. This is always the case even if you add a subject or message body here. The first ‘function’ after the main email addresses must start with a “?” while any extra ‘functions’ will start with a “&”
If we combine the previous examples this will become clearer:
<a href=”mailto:firstname.lastname@example.orgemail@example.comfirstname.lastname@example.org”> CC&BCC</a>
<a href=”mailto:email@example.comfirstname.lastname@example.orgemail@example.com”> BCC&CC</a>
Result: CC & BCC
Adding a subject:
To add a subject simple add “subject=” :
Result: Mail & subject
Adding a message body:
To add a subject simple add “body=” :
Result: Mail & body
If you would like to add an extra line to the body of the email you must add %0A where ever you want the text to break to a new line.
<a href=”mailto:firstname.lastname@example.org?body=message%0Ahere”> Mail & body</a>
Result: Mail & body
We can combine the previous examples to make a comprehensive mailto link:
<a href=”mailto:email@example.com,firstname.lastname@example.orgemail@example.com& firstname.lastname@example.org&subject=Complaint& body=Dear sir.%0AI have a complaint to make”>Mail us!</a>
Result: Mail us!
- You are limited to 255 characters in your mailto link.
- Including email addresses in this way leave them vulnerable to harvesting by spammers.
- The newline code “%0A” works well with MS Outlook Express but there have been mixed results with other email clients. (Thanks to Willians for info on this.)
- BCC will not always work, it’s a bit ‘buggy’
- These were tested in MS Outlook, MS Outlook Express, Lotus Notes and Mozilla Thunderbird and in general performed correctly (note point 3 & 4 above).