Email links
You can create links on webpages not just to other webpages and resources, but to an email message as well.
This tutorial focuses on:
- Creating a basic email link
- A more complex email link
- Disadvantages of email links
- Sending email directly from a webpage
Creating a basic email link
To create a basic email link the <a> tag is used just as it is used for regular links but instead of the href attribute taking the value of a URL, it takes the value of mailto: followed by the email address that the message will be sent to.
Click on the above link and it will open a new email message in your email program (the default email program you use such as Mozilla Thunderbird or Microsoft Outlook Express) with the "to" field already filled in.
NOTE: A websites visitor must have an email program (such as Mozilla Thunderbird or Microsoft Outlook) installed and configured on their computer for the email link to work. If you clicked on the email link and it did not work, that is probably the reason why.
A more complex email link
You can create even more complex email links that fill in the subject as well as the body of the email, not just the email address that the message will be sent to. This is achieved by using the word subject in the link followed by the subject of the message, and the word body followed by the message itself.
NOTE: When creating an email link with a subject and/or body, make sure to always separate the email address from this information using a question mark ( ? ), and also the subject and body information should be separated by an ampersand ( & ).
Click on the above link and it will open a new email message in your email program (the default email program you use such as Mozilla Thunderbird or Microsoft Outlook Express) with the "to" field already filled in as well as the subject field filled in with the value "Hi, cool website!" and the body of the email filled in with the value "I am reading the page on email links. HTML is cool."
NOTE: A websites visitor must have an email program (such as Mozilla Thunderbird or Microsoft Outlook) installed and configured on their computer for the email link to work. If you clicked on the email link and it did not work, that is probably the reason why.
Disadvantages of email links
Although email links serve a useful purpose, there are some disadvantages to them.
- The email address you specify with an email link can be picked up by spammers. Spammers have programs called spambots that go around the web harvesting email addresses from webpages for the purpose of spamming. It is possible that by specifying an email address with an email link, that email address will be picked up by a spambot.
- A websites visitor must have an email program (such as Mozilla Thunderbird or Microsoft Outlook) installed and configured on their computer for the email link to work.
- Using an email link makes you look somewhat unprofessional (if the person reading your page knows a thing or two about web development). It is better to use a form that automatically sends an email from the page.
Sending email directly from a webpage
So an email link when clicked on opens an email program to send an email, but how do you send an email directly from a webpage?
Achieving this is not possible with HTML and actually requires a server-side language like PHP. And besides this, other things have to be configured and working such as the email server that a website is using.