The mailto: chronicles 
 an attempt to document the hidden features of the mailto: command

The Need...

Using the mailto: convention in either forms or href tags is a great way to bypass the need for cgi scripts, Java, or JavaScript in your HTML documents when you want to have greater control over 1) who gets the email sent from your site, or 2) sending form information from your site. Unfortunately, there's few resources available for those who are looking for a comprehensive list of the features that go along with mailto: (and there are quite a few) as these commands are mostly undocumented or hidden - until now.


(8-29-02) UPDATE: You can add linefeeds to the body by using the ASCII hexcode %0A in the body text! A lot of people have emailed me asking if this were possible. Well, I just found out how! Enjoy!

What Can MAILTO: Be Used For?

mailto: can do so much more than provide an easy way to send email to you from your site. Used as an <A HREF> tag, one email can be sent to multiple addresses. Not only that, but any combination of those addresses can be tagged as To: (regular), Cc: (carbon copy), or Bcc: (blind carbon copy) addresses. You can also set default text for the Subject: line and the email body!

In forms, mailto: provides an easy way to email you formatted information from your site without having to deal with cgi or other programming methods. The email you receive from a form can then be manually evaluated or saved out to a file that can be read for entry into a database. In addition to all the features mentioned above, forms provide you a slight benefit of being able to hide email addresses from the casual visitor.


mailto: OPTIONS

mailto: IN FORMS
SENDING MAIL TO MULTIPLE RECIPIENTS
Add additional email addresses after the first, seperated by a ",":
mailto: foo@bar.com, bar@foo.com, buffy@slayer.com

ADDITIONAL MAILTO: COMMANDS
  Sender is the person who selects the mailto: link
  Recipient is the person who will receive the mailto: email

  • TO - same as using "," in the mailto: line
    Recipient's name will appear in the To: line, along with all the other To: addresses. Sender will see all addresses in the To: line. Recipient will see all addresses in the To: line. Can be changed by Sender.
  • CC - carbon copy
    Recipient's name will be in the Cc: line, along with all the other Cc: addressees. Sender will see all addresses in the Cc: line. Recipient will see all addresses in the Cc: line. Can be changed by Sender.
  • BCC - blind carbon copy
    Recipient's name will appear in the Bcc: line, along with all the other Bcc: addresses. Sender will see all addresses in the Bcc: line. Recipient will see no addresses in the Bcc: line. Can be changed by Sender.
  • SUBJECT - default text for subject line
    Text following this command will appear in the Subject: line. Can be changed by Sender.
  • BODY - default text for email body
    Text following this command will appear in the Body of the email. Can be changed by Sender. NOTE: You can add linefeeds to text in the body by adding the hex code of a linefeed, %0A where you want the linefeed.
If you set up your form correctly, you can have the completed form emailed to you instead of to some other post-processing function via a cgi-script or other method once the user hits the submit button. This is a great option for those who don't have access to cgi.

When using mailto: in forms, the method should be set to POST and the mailto: goes in the action tag, using any of the options mentioned on this page.

<form method=post action="mailto:foo@bar.com, bar@foo.com, buffy@slayer.com" enctype="text/plain">

. . . (form data goes here) . . .

</form>

  • So that the data sent to you is posted in the body of the email and not the subject, use the enctype="text/plain" command in the form tag.
  • OKAY, SO HOW DO I DO IT?

    All of the options are added in the mailto: tag. Here's the format:

    <a href="mailto:first_email_address[,second_email_address] [, etc...] [?option=variable] [&option=variable] [&next option=variable] [&etc...] ">

    EXAMPLE:
    <a href="mailto:foo@bar.com, bar@foo.com?subject=Suspicion Breeds Confidence&cc=barfoo@foobar.com&bcc=secretfoo@bar.com">

    IMPORTANT:
    Notice that there are no quotation marks other than those used by the <A HREF> tag. This is one of the most common mistakes when using these options.
    Just place this code with your desired email addresses on your page and you're set to go!

    THE RULES...

    • The ? and & are used to identify the options selected.
    • The ? must be used first, and only once. The & can be used as many times as needed.
    • If you start with a &, then everything after it is interpreted as a separate To: address.
    • Spaces can be used with the Subject: and Body: options, but spaces found in any of the address options (To:, Cc:, etc.) are interpreted as commas and will be parsed into separate entries, like this:
      Sample:
        ...&cc=Use CC for comment...
      Result:
        Cc: Use
        Cc: CC
        Cc: for
        Cc: comment
    • Apparently, the entire mailto: string is limited to 256 characters. This should not be a problem unless you are planning on a lengthy body statement.

    THE CATCH : Reliable, it ain't...

    Well, you knew there had to be one, otherwise, everyone would be using mailto:'s on their pages!

    The problem with using the mailto: method is its unpredictability. There are some email programs that just won't play well with the mailto: command and if they do, they ignore the special commands described on this page. Outlook Express is the most-reported offender.

    For all intents and purposes, the mailto: command and its features should never be used for critical email. By being able to add some extra content like cc:'s and subject lines, most (or some) of the email can be sufficiently "marked" to stand out when you download your email.

    If you need these features in a more critical situation, then cgi's or JavaScript is the best way to go. I know that's probably not what you want to hear, but mailto: cgi's are available by the truckload on the Web and can do what I've mentioned and much, much more.

    CATCH 2 : The user must play along...

    For mailto: to work, the user's broswer must be set up for email. Yes, I know it's like pulling teeth to get users to make any change to their browser settings, but if they don't have email set up, mailto: will sit there like undefrosted hash browns. So, you can either trust your visitors to have email set up, or give them directions on what to do if mailto: isn't working...

    Internet Explorer Instructions

    1. Open Internet Explorer.
    2. Choose Internet Options in the View menu.
    3. Go to the Programs tab.
    4. Select a program under the mail drop down menu. If you don't have any options you will have to download an e-mail program. Outlook Express interfaces with Internet Explorer well.
    5. Once you have selected a program you will have to configure it to send outgoing mail. If your server does not work with external programs then just enter your e-mail address and use mail as your server. The program might ask for a user name if it does then just use whatever username you have for your e-mail account.
    Netscape 4.0+ Instruction
    1. Open Netscape.
    2. Choose Preferences from the Edit menu.
    3. Click on the box next to Mail and Newsgroups in the list.
    4. Select Identity.
    5. Enter your e-mail information into the fields.
    6. Select the Mail Servers.
    7. Enter your e-mail server information. If your e-mail service is not compatible with external e-mail programs then use mail as your server.
    Netscape 3.0- Instructions
    1. Open Netscape.
    2. Choose Mail and News Preferences under the options menu.
    3. Choose the Identity tab.
    4. Enter your e-mail information into the fields.
    5. Select the Servers tab.
    6. Enter your e-mail server information. If your e-mail server is not compatible with external e-mail programs then use mail for your server.

    CATCH 3: Only manual. No automatic...

    As far as I know, there is no way to get mailto: to automatically send an email, such as to use this function to to automatically email you when someone visits a particular page. Once the mailto: command is called, all control is passed over to the email client along with the email properties you've defined.


    Well, I hope this page helps you with the most-undocumented mailto: command. If you have any questions or comments, you can email Network 23.


    Copyright ©2002, Network 23[TM]
    This site is part of:
    The Hub
    Come Visit The Hub
    Concept and design by:
    Network 23
    Network 23