MailTo Script
Using our MailTo script, you can create simple forms that do the following:
- Mail the form responses to the e-mail address(es) of your choice.
- Subscribe or unsubscribe to your mailing list.
- Do both from the same form.
Mail The Form Responses
- Create an HTML page to display after the user has submitted the form. This page could say something like "Thanks for filling out our form."
- Create a form, with the form action and hidden fields as specified:
Form ACTION: http://www.pins.net/cgi-bin/open/mailto.cgi
Required hidden fields:
- MailTo: the e-mail address that will receive the form information. Multiple addresses should be separated by commas. Multiple MailTo parameters may also be used.
- TextTo: the complete URL of the page that users will see after submitting the form
That's it. The remainder of this step is optional:
Optional textbox:
- E-mail: the textbox where the user enters his/her address. The name of this field can be any variation of the word 'email', upper or lower case, with or without the '-', and may be preceded by two or three digits (e.g. 05Email). The value of this field will also appear in the Reply-To header of the e-mail that is sent.
Optional hidden fields:
- Subject: the subject of the e-mail that is sent (default value: Form Response)
- MailText: fixed text that will appear at the top of each e-mail message.
- MailFrom: the From: e-mail address on the form. It must be a valid email address, and it can include a full name. Please use this value with caution. (default value: MailTo Script <nobody@yourdomain.com>)
- NoBlankFields: indicates that fields not filled in by the user will not appear at all in the email message.
<input type="hidden" name="NoBlankFields" value="1"> - RequiredFields: lets the script know which fields must be filled in by the user.
<input type="hidden" name="RequiredFields" value="FieldName1">
<input type="hidden" name="RequiredFields" value="FieldName2">
Field names should be in the same case as the names in the HTML page.
Optional features:
- Field sorting
Field names appear in the e-mail in the order in which they appeared on the form. If you want to control the order of the field names, use two- or three-digit numbers at the beginning of each field name. For instance, your fields could be called "01Name", "02Address 1", "03Address2", "04Address 3", "06Email", "07Phone". The numbers will not appear in the e-mail.
- Checkbox (or other field) display
To show only the name of a field and not the value, make the value end in "noshow". For instance, the name of a checkbox field could be "I would like more information about your company." and the value could be "info_noshow".
- E-mail address checking
If your email address field is listed as a required field, the address will be checked for validity. It must be in the correct format (user@domain.com) and the domain must be a valid domain that accepts mail.
- Test your form! Make sure that you get the e-mail and that you go to the right page after submitting the form.
Here's a sample form that asks for the user's name and e-mail address:
Here's sample HTML for the above form:
The e-mail that will be sent will look like this:
From: MailTo Script <nobody@yourdomain.com> Reply-To: joe6pack@mydomain.com To: youraddress@yourdomain.com Subject: Customer Contact Form Name : Joe Sixpack Email : joe6pack@mydomain.com Please send me more information.
(Un)Subscribe To Your Mailing List
- Create an HTML page to display after the user has submitted the form. This page could say something like "You have been added to our mailing list. You should receive a mail containing the list information within a few minutes."
- Create a form, with the form action and hidden fields as specified:
Form ACTION: http://www.pins.net/cgi-bin/open/mailto.cgi
Required hidden fields:
- ListName: the name of the mailing list. You can also use a series of checkboxes, all with the name "ListName," to allow a user to subscribe to multiple lists at once. You cannot unsubscribe from multiple lists at once.
- TextTo: the complete URL of the page that users will see after submitting the form
Required textbox:
- E-mail: the textbox where the user enters his/her address. The name of this field can be any variation of the word 'email', upper or lower case, with or without the '-', and may be preceded by two or three digits (e.g. 05Email). The address entered must be in the correct format and the domain must exist and accept mail.
That's it. The remainder of this step is optional, assuming you want the user to subscribe.
Optional hidden fields:
- ListCmd: the mailing list command ("subscribe" or "unsubscribe your_list_password") (default value: subscribe) This could also be a set of radio buttons allowing users to choose 'subscribe' or 'unsubscribe'. Because including your list password in your form is not very secure, you may wish to send list members who want to unsubscribe directly to a form generated by mailman instead. The mailman forms may be customized to match your site design.
- ListTo: the recipient of the e-mail containing the list command. Do not use this field unless you know what you are doing! The default value of name_of_mailing_list-request@yourdomain.com>) is almost always correct.
- Test your form! Make sure that you get the subscribe/unsubscribe e-mail notifications and that you go to the right page after submitting the form.
Here's a sample form that lets users add or remove their email address from a mailing list:
Here's sample HTML for the above form:
Do Both
Do all of the steps above, remembering to include all necessary required fields. If you want this to be a form where the user fills out various information, and then decides whether to subscribe to the list, add the following fields:
- ListVerify: a hidden field, whose value should be non-zero, non-blank. ('1' is a good choice.)
- ListWanted: a checkbox, whose value could be 'Yes', for instance. If the user checks this box, his/her e-mail address will be added to the mailing list.
Please note that, if you use the above fields, the user's email address will only be checked for validity if ListWanted is checked. Make the email address a required field to force validity-checking even if the user does not want to join the list.
Here's a sample form that asks for the user's name and e-mail address, and allows the user to subscribe to the mailing list:
Here's sample HTML for the above form:
For more information about forms, check out the NCSA's forms overview.