1. Technology

Mailto Forms

HTML Forms Tutorial

By

Close up of a contact us key
Courtney Keating/E+/Getty Images

Mailto forms are an easy way to make forms work. Mailto forms rely on email clients to send the form data from the customer's computer to the form owner. The form data is emailed to the owner. If you are new to web design, don't know how to program, or are running a small website, having a mailto form as a contact form is a lot easier than learning to write PHP and cheaper than buying a pre-written script.

HTML forms can be challenging for new web developers because they require more than just learning HTML. You have to have some way to get the form to "work". And that usually requires access to a CGI script or other program to put in the action attribute.

If you don't have access to a script, there is one form action that most modern browsers support.

action="mailto:youremailaddress"

This is a simple way to get the form data from your website to you.

Tricks to Using Mailto Forms

  • Use the enctype="text/plain" attribute
    This tells the browser (and email client) that the form is sending plain text rather than anything more complicated. Some browsers and email clients send form data encoded for web pages. This means that the data is sent as one long line, spaces are replaced by plus (+), and other characters are encoded. Using the enctype="text/plain" attribute helps make the data easier to read.
  • Use the GET method
    While the POST method sometimes works, it often just causes the browser to open a blank email window. If this happens to you with the GET method, then try switching to POST.

Sample Mailto Form

Here is a sample form using the mailto action:

<form enctype="text/plain" method="get" action="mailto:webdesign@aboutguide.com">
Your First Name: <input type="text" name="first_name"><br>
Your Last Name: <input type="text" name="last_name"><br>
Comments: <textarea rows="5" cols="30" name="comments"></textarea>
<input type="submit" value="Send">
</form>

Your customers will see a message saying that the form is being submitted via email. This is what the results look like:

first_name=Jennifer
last_name=Kyrnin
comments=Hi there!

Please note, mailto forms don't always work for all combinations of browsers and email clients. For more information, read my related article When Mailto Forms Don't Work.

Special Note About Mailto Forms

Mailto forms don't always work. If you set up a mailto form and it doesn't work, check out these two articles:

This article is part of the HTML Forms Tutorial

©2014 About.com. All rights reserved.