Stupid Web Tricks: Customize your mailto functions

Don't use just any mailto function. Learn how to use Super Ninja Mailtos that automatically fill in CC:, BCC:, and subject lines.

Click here for our complete list of Stupid Web Tricks.

By Lauren Guzak and Patrick Joseph
(1/26/99, updated 6/22/01)

Mailtos are a convenient way to let your audience offer feedback on your Web site or to arrange other contact information. But you can do a lot more with a mailto than just automatically generate an email message. Super Ninja Mailtos can automatically CC: and BCC: people—or even fill in the subject line. Here's how to customize your mailto functions.

Your basic mailto looks like this:

<A href="">
Click here to send a boring old mailto message</a>.

When users click the link, it brings up their email client with the recipient's email address prepopulated in the To: field. Snore. To spice it up, follow these steps.

Step One
Create your regular mailto with the main recipient's email address, as you normally would.

Step Two
To copy (CC:) someone on the email, follow the To: recipient's email address with ?cc=. The example below shows how the code should look:

<A href="">
Click here to send an email message to multiple recipients</a>.

Step Three
To blind copy (BCC:) someone on the email, follow the CC: recipient's email address with &bcc= (as you add these features, the first one begins with a ? and subsequent ones begin with a &). It should look something like this:

<A href="">
Click here to send an email message to multiple recipients (only some of which you know about)</a>.

You can also separate numerous To:, CC:, and BCC: recipients by commas:

<A href=",">
Click here to send an email message to multiple comma-delimited recipients.</a>

Step Four
To prepopulate the Subject: field, follow steps 1 and 2 with &subject=. For spaces, use the escaped version, %20. The whole string—with To:, CC:, BCC:, and Subject:—should look like this:

<a href="
This%20is%20only%20a%20test">Click here to send us super ninja email</a>.

Here's an example of the whole thing in action: Click here to send us super ninja email. Note: this trick only works with standards compliant email clients.

Lauren Guzak is a project manager for Ask Jeeves, and Patrick Joseph is a freelance writer.

Editor's Picks

Free Newsletters, In your Inbox