Site hosted by Build your free website today!

html mailto tips and tricks


This page will cover how easy it is to allow people to email their friends from your website using mailto and includes tips and tricks for html forms, each mailto example is a working example

Many people already know about the mailto attribute of the <A> tag

html mailto example
<a href="">example</A>

And you will probably already also know how to include a subject in the mailto tag but heres an example for those who don't

mailto subject example
<a href=" chocolate">example</A>

Now, before moving on it's worth taking a look at the syntax of mailto
notice that there is only one set of double quotes and every thing goes between them

" chocolate"

This is the most common mistake that website builders make and is nearly always the culprit when something goes wrong with mailto It seems odd because it's unusual to include an equals sign = between double quotes

The other common mistake when using mailto is to ommit the word 'subject', If you've done this then you will know it can drive you nuts

<a href=" chocolate">

Having told you what you already probably know, it's time to move on to something slightly more interesting

the best thing about mailto

Probably the best thing about the mailto tag is very much undocumented and that is, that you can include a message in the body of the email

What that means is, if you have a mailto link on your website and a user clicks on it, the to:, subject: and message are already complete, so all that the user has to do is click send

now your probably thinking "so what?" but this can seriously increase the number of visitors to your website, take a quick look at this example

Imagine putting a link like this example on your homepage : tell a friend

This is the html source code for the working mailto example above

<A HREF="mailto:?subject=look at this website&body=Hi, I found this website and thought you might like it">tell a friend</A>

you may notice that there's no email address in the mailto example and although the link in the web address is not clickable in the body of the email, it is when it arrives at the recipient's inbox

mailto sequence

There are a squence of events that can be included in mailto
the first one is the question mark?
the second one is the ampersand &

mailto sequence quick reference
? must be used first and once only
& use as many of these as you want but should be preceeded by ? or else everything after & is interpreted as a seperate to: address
&cc use this to send a carbon copy to a second recipient
&bcc use this to send a blind carbon copy to a second recipient, the main recipient will not see the bcc: email address
mailto reference
256 The maximum number of characters allowed in a mailto string is 256

html mailto sequence example :
<a href=", free chocolate&">

the trouble with mailto

In the majority of cases mailto will work just fine but for a very small number of user's in won't work at all or can be unpredictable.

The small number that mailto does not work for is declining with the advent of modern email software being bundled with pc's and other software and if every email is critical to you, you will need to find a server that offers cgi formmail.

Probably the most common reason for mailto to fail is that the user does not have their email set up properly.

html mailto forms

Another way to use mailto is with html forms, the main advantage of forms is that you can collect more information about the user than they would normally volunteer, for example you can ask specific questions and all the user has to do to answer your questions is simply click on an input checkbox before clicking send

below is an example html source code for setting up mailto in a form

<FORM method="post" action="" enctype="text/plain">

<INPUT TYPE="text" NAME="email">

<INPUT TYPE="hidden" NAME="subject" VALUE="web_monitor">
<INPUT TYPE="text" NAME="subject">

(rest of form content)


the method should be post and the encrypt type should be text/plain

input name="email" and input name="subject" are special tags because they control the way the headers look in your email inbox input name="email" is the from: and subject is, of course the subject

As you may have noticed there are two subject tags in the example html source code above, one text and one hidden

using the html form code above, emails arriving in your inbox should look like this example

FROM: SUBJECT: web_monitor, users subject

The web_monitor subject prefix will allow you to clearly see, at a glance that the email has been sent from your website

back to webmaster articles

html tutorial css tutorial