A Web.com Partner
Sign Up / Log In
Online Support Web Hosting

How to Use PHP FormMail

PHP FormMail has many formatting and operational options, most of which can be specified through the form, meaning you don't need any programming knowledge or multiple scripts for multiple forms. More information on this script can be found in the Readme file in the download.

Terms of download. By downloading this code sample you agree to indemnify all parties involved with the development, hosting and provision against any and all disputes between yourself and any third party. You agree to indemnify, defend and hold harmless aforementioned parties against any loss or damage coming as a result of the sample code's provision.

Create a PHP Mail Form

Create your form page in HTML like this. There is no limitation to your form design.

Step 1. Download the script Jack's FormMail.php, save it to a temporary directory on your computer, then unzip the files.
Step 2. Open the formmail.php file in a code editor application. Here we are using Notepad++. Then, change the value of the $recipient variable. Change the recipient address to the email address that the FormMail results will be sent to.

For Multiple Recipients seperate the email addresses with commas (",").
editing formMail.php recipient variable
Step 3. Edit the HTML code of your form page (eg, contact.html) and define the FORM ACTION to execute the formmail.php script and make sure the FORM METHOD is POST.
setting from method to post for formMail
Step 4. Upload the formmail.php script and form mail HTML file into the directory in which you are planning to use it. (eg, /public_html) within your hosting space.
Step 5. Test the php form mail, please go to http://www.yourdomain.com/contact.html, submit the form and check your email for results. Make sure to change the yourdomain.com to your domain name.
sample of contact us form page

Congratulations! You have just created a PHP mail form. Please let us know if you need any further assistance, or if you have any questions. We’d love to help!

Was this helpful? Yes No 70% of people found this helpful.