Sending Mail From a Form
Birdhouse makes it very easy for web developers to send mail from a web form by providing a system-level mail sending script, which is a variant of the popular FormMail.cgi script from Matt’s Script Archive. Because FormMail.cgi has historically been exploited by spammers, and because we have a very strict anti-spam policy, we do not allow users to run it. By using our system-level variant, our users won’t be on the hook for any problems.
One important note about using the server-wide FormMail script: You must send the contents of the form to an address that is on your domain name. If you need the mail sent to an external address, you can set up a Forwarder to forward any mail to your off-site email address.
You’ll find that working with the script is very similar to working with Matt’s famous FormMail.cgi. First, set up a simple form like this:
<form name="test" action="/cgi-sys/formmail.cgi" method="post" id="test"> <input type="hidden" name="recipient" value="email@domain.com"> Enter your Name: <input type="text" name="name"><br> <input type="submit"> </form>
The important bits are:
action=/cgi-sys/formmail.cgi
and
<input type=”hidden” name=”recipient” value=”email@domain.com”>
(where email@domain.com is an address or forwarder already set up on your domain).
Here’s another example utilizing more of the script’s features:
<form name="test" action="/cgi-sys/formmail.cgi" method="post" id="test"> <input type="hidden" name="recipient" value="email@domain.com"> <input type="hidden" name="subject" value="This is a test"> <input type="hidden" name="redirect" value="http://yourdomain.com/redirect.html"> <input type="hidden" name="required" value="email,realname"> E-Mail Address: <input type="text" name="email"><br> Name: <input type="text" name="realname"><br> Favorite Color: <input type="text" name="color"><br> <input type="submit"> </form>
Note the use of the free-form “color” field – feel free to use as many arbitrarily named fields as you like – just make sure they’re unique. There are other INPUT TYPE=”hidden” types, as listed below:
- subject — The subject line of the email. Use the quotation marks if more than one word.
- redirect — The URL of the page you want the visitor to be taken to after successfully completing the form. Specify the full URL.
- required — A list of required fields that must be filled out in order for the form to be processed.
- email — Who the form will appear that it was sent from. This is useful so recipients can hit the Reply button to respond.
- realname – Instead of the mail appearing to come from just the said email address, this name will appear to the email address.
Again, these are optional parameters. The only requirements are that ACTION=”/cgi-sys/formmail.cgi” is in your FORM tag and <INPUT TYPE=”hidden” NAME=”recipient” VALUE=”email@domain.com”> is listed below the opening FORM tag.
For full documentation, see the original docs at Matt’s Script Archive.
If you prefer to create a home-brew mail sending script with PHP, please see our Sending Mail from PHP FAQ, but keep in mind that using our centralized script affords a good deal of additional security.


