How do I add a form to my website and have submissions emailed to me?

The form itself can be added to CMS pages by pasting form code into a content area. Launch the editor by clicking the "edit content" button. Then click the Edit HTML Source button. Paste your form code and save your changes. An example form might have code that looks like this:

<form action="sendmessage.php" method="post">
   <input type="hidden" value="" name="send_to" />
   <input type="hidden" value="" name="send_from" />
   <input type="hidden" value="thank-you.html" name="redirect" />
   <input type="hidden" value="Contact Form Submission" name="subject" />

   <p>Name<br />
   <input type="text" name="name" /></p>

   <p>Email<br />
   <input type="text" name="email" /></p>

   <p>Phone<br />
   <input type="text" name="phone" /></p>

   <p>Comments<br />
   <textarea type="textarea" name="comments"></textarea></p>

   <input type="submit" value="Submit" />

If you don't want to manage your own forms or deal with scripting, check out Wufoo:

In order to send form data to an email address, you'll need to have a script file on your server that can accept the form contents and package them up in an email message. Depending on your hosting environment, the script file may need to be either PHP or ASP. Because PHP is one of the most popularly supported languages on hosting servers, I'll provide you with the code in PHP.

Save this code into a file called sendmessage.php or some other intuitive, meaningful name.

    /* This script emails whatever is posted to it and
    * requires the form to have a hidden input named "redirect"
    * Alternatively, the $_POST array can be set to $_GET in
    * order to compose a message from variables in the query string.

   // The redirect url is required and prevents non-form-posted processing.
   if (isset($_POST['redirect']))
      // Set up message
      $send_to = $_POST['send_to'];
      $send_from = $_POST['send_from'];
      $subject  = $_POST['subject'];
      $redirect  = $_POST['redirect'];

      // Set up the header
      $header  = "From: " . $send_from . "\r\n";
      $header .= "X-Mailer: PHP/" . phpversion();

      // Build the message
      foreach ($_POST as $key=>$value)
         $message .= $key . ": " . $value . "\r\n";

      // Send the email
      // The '@' surpresses errors.
      @mail($send_to, $subject, $message, $header);

      header("Location: " . $redirect);

Once you've created your new PHP file, upload it into your System Files library which is located in the same menu section in the CMS as your images, documents, etc.

The final step you'll need to take is to set a few values in your form so that it correctly posts to this new script file. Here are the values you'll need to set:

  1. Set the form's action to the name of your PHP file, sendmessage.php in our example.
  2. Create a hidden form field with name="redirect" and value="someURL" replacing "someURL" with the URL of the page you wish to display after the user successfully submits their form data.
  3. Create a hidden form field with name="send_to" and value="someEmail" replacing "someEmail" with the email address you want the form contents sent to.
  4. Create a hidden form field with name="send_from" and value="someEmail" replacing "someEmail" with the email address you want used as the "from" address on the email message.

If you've done all of the above and are having problems, here are a few things to try:

  • Make sure your hosting provider supports PHP.
  • Make sure your hosting provider supports PHP's mail() function.
  • Contact your hosting provider for further tech support.
  • Check the junk mail folder of the receiving email account to ensure the message isn't hiding there.
  • Hire a developer to troubleshoot your code