PHP Contact Form Mailer

Many websites have a Contact Us form that emails the form contents to a specific email address. This example of a PHP contact form mailer requires that your webserver have PHP and PEAR installed. (PEAR is usually installed with PHP4, or you can find it here.)

This particular contact form uses SMTP instead of sendmail to avoid common issues that are commonly found in the latter.

This site uses two separate pages, one for the contact form and another that receives the form and sends it's contents as an email. Note that you can combine the two into one page as we initially did, but this complicated measuring how many people actually filled out the form and it made the single page a bit messier. We have opted for the two-page system described here.

The Contact Form

This is a very basic form to get you started and serve as an example. Note that the form page does not need to be PHP. You can either click on the link and "view source" or save the link to your computer.

The Form Processing Page

Save the following to your computer, removing the ".txt" on the end. You will find comments within it to guide you. Note that it requires a server with PHP and PEAR. PEAR is usually installed on modern PHP servers, but if not, check with your hosting provider or install it yourself.

We welcome your comments.

Also see our email address encoder.

If you like this tool, please rate it at Hotscripts.com.