How to Send Email From an HTML Page

By Kay Daniels

An email contact link makes a good addition to nearly any type of website, giving visitors a means of sending questions or other forms of feedback to the site owner. Although adding a contact form into an HTML page might sound a little bit complicated if you are brand new to HTML, the truth is that sending email from an HTML page is actually pretty easy to do.

Use a Mailto Link

Decide which email address you want to receive the emails from your website.

Create the HTML page from which you want the users to be able to send an email.

Add an anchor tag that contains a mailto: link. It should look like this:

Insert the email address you selected in Step 1 into the tag you just created, then type the text that you want to be clickable.

Type to close the anchor tag. The final result should look something like this: Contact Me. You can now upload your HTML page to your server, and website visitors will be able to click on it to send you email.

Use a Form

Create an HTML form using either a hard-coded HTML document or an HTML editor such as DreamWeaver or Nvu, including fields for the information you wish to collect from the users (such as name, email, etc).

Set appropriate value or name attributes to each input tag in your HTML form in order to ensure that you can identify and understand the data properly when you receive it.

Locate a form mail script. Your Web host may have pre-set scripts available through your hosting plan. If you do not already have access to an existing form mail, search for a free form mail CGI script on the Internet, then follow the instructions to customize the script and upload it to your server. Add any necessary variables, such as setting up the email address that should receive the form results.

Set the action attribute of your form tag to point to the location of your script and the method to either "post" or "get" as specified in the form setup instructions.

Add any necessary hidden variables and input fields to your HTML form that are required in the script setup instructions.

Upload your HTML form to your server in the correct location, double-checking that you have set up the action attribute to correctly point to your form script.

Send a test email to yourself using the form and make sure that it works correctly.

×