IRT Logo

How to Use FormMail

NEW!

Email Form Templates
You can quickly add email capability to your site by downloading two HTML files and adapting them for your own use.
Check it out

If you maintain a site on the main School of Medicine server, med.stanford.edu, you can use our FormMail cgi script to send email from your Web page. If you use a custom domain, like yoursite.stanford.edu, then you will need to have the domain added to our approved list. Follow these simple steps to have the information submitted through your HTML forms mailed to you:

A formality...

Copy and paste the following text into the page you want the form to appear in:

<FORM METHOD="POST" ACTION="http://med.stanford.edu/cgi-bin/formmail.pl">

That line just tells our server that the page contains form information that needs to be emailed out.

Give a recipient

Copy and paste the following line just below the one you pasted before:

<input type=hidden name="recipient" value="recipientemailaddress">

Be sure to replace recipientemailaddress with the address of the person who wants to receive the responses to the form. If more than one person needs to receive them, just separate the email addresses with a comma: email1,email2,email3. NOTE: The addresses you use must be added to the approved list or they won't work.

Add fields to your form

Just use standard HTML input fields. Here are some examples to copy and paste:


<input name="email" type="text" id="email" size="25"textstring="default input">

<input name="checkbox" type="checkbox" id="checkbox" value="Yes" checked>

<input name="radiobutton" type="radio" value="No" checked>

<input name="submit" type="submit" id="submit" value="Submit">

Add special FormMail features

These are all optional...but you will likely use them. Just copy and paste into your form code....replacing the red text as needed.

<input type=hidden name="redirect" value="http://med.stanford.edu/yourdirectory/yourfile.html">

This specifies the page the user will see after submitting a form. For example, you can tell him/her thanks and provide more information. That way you avoid the ugly standard page that is normally seen.

<input type=hidden name="required" value="email,phone">

Sometimes you will want to make some fields required...so the user must fill them out before the form is submitted. Just type in the names of the fields you want required in this tag. Those names are the ones in the "name" part of each field's line of code. Remember, it's case-sensitive so make sure they match exactly.

<input type=text name="email">

Lets the user specify a return email address. This lets you reply to the form submission just by hitting 'reply' in your email program. Highly recommended if you want to be in touch with people submitting forms.

<input type=hidden name="subject" value="Your Subject">

Normally, the subject of any submission is "WWW Form Submission." If you are serving up multiple forms that can be confusing...so this tag lets you specify a custom subject line.

<input type=hidden name="sort" value="order:field1,field2,field3, ">

You may want to control the order in which your information occurs in the email. To do so, add this hidden field and and update the list after "order:" You must spell the field names exactly. Any fields not included will be omitted from the email. On the other hand, without this control, your email will include an item for every form element.

Not all of these form elements must remain hidden. You can also substitute regular visible form elements for the hidden "recipient" and "subject" fields.. You can have a pull-down menu or radio buttons with a list of alternative recipients. You could also provide a text field for the user to write their own subject. As long as the form element has the right name, as found on the invisible element, it should work. Experiment.

A note about custom URLs

Many sites on the School of Medicine server use "Custom URLs," also known as "virtual hosts." These are short, customized URLs that take the form "abcxyz.stanford.edu" The longer URLs also work for these sites. However, when the browser uses a FormMail page under the short URL, the script won't work properly, unless the domain is authorized.

The easiest way to deal with this is to always link to your FormMail page using an absolute URL in the long form. That is, instead of linking to "feedback.html" your links should be to "http://med.stanford.edu/path/to/yoursite/feedback.html" where "/path/to/yoursite/ is replaced by your directory. Then FormMail works fine.

If for some reason this approach won't work for you, you can request that your domain be added to FormMail list of approved domains. To do so, contact Web Help , or use the FormMail request form, making sure to provide the custom domain with the address of your FormMail page (i.e. http://yoursite.stanford.edu/feedback.html, or specify in the "Other Message or Comments field.)

For a complete list of FormMail features, please visit <http://worldwidemart.com/scripts/readme/formmail.shtml>