Contact Forms

Available with CloudCannon hosting.

Create contact forms for your sites. CloudCannon sends named form data to email addresses of your choosing.

To create a contact form:

  1. Add an HTML form to a file
  2. Set the method attribute to post
  3. Set the action to where the visitor is redirected after the form submission
  4. Add form fields with name attributes to collect data from visitors
<form method="post" action="/success.html">
  <label>Email Address</label>
  <input type="text" name="email">

  <input type="text" name="name">

  <textarea name="message"></textarea>

  <input type="checkbox" name="urgent">

  <label>Type of Enquiry</label>
  <input type="radio" name="_subject" value="Sales Enquiry"> Sales
  <input type="radio" name="_subject" value="General Enquiry"> General

  <input type="hidden" name="_to" value=",">
  <input type="hidden" name="_cc" value="">
  <input type="hidden" name="_hook" value="">
  <input type="text" name="_gotcha" style="display: none;">

  <input type="submit" value="Send Message">

Special Fields

Use these fields to customise the email CloudCannon sends through the form. The fields can be hidden or visible depending on your requirements.


The address (or addresses) that CloudCannon sends the email to. Send the email to multiple addresses by separating them with commas.

If a _hook is defined, this field will not be used.

<input type="hidden" name="_to" value="">

_replyto or email

The value used for the Reply-To header in the email. Use this to ensure clients reply to the visitor rather than a default CloudCannon address.

  Your Email Address
  <input type="text" name="_replyto">


The subject of the email.

<select name="_subject">
  <option>General Enquiry</option>
  <option>Quote Request</option>


The value used for the CC header in the email. Use this to send a copy in another address (or addresses) without sending it directly. Send a copy of the email to multiple addresses by separating them with commas.

<input type="hidden" name="_cc" value="">


Instead of sending an email, a webhook can be supplied for the data to be sent to. 

<input type="hidden" name="_hook" value="">

See Webhooks.


Honeypot field for preventing untargeted spam. CloudCannon does not send the email if this field has a value. Hide it with CSS to prevent visitors filling it out.

<input type="text" name="_gotcha" style="display: none;">

For better spam prevention try using Google reCAPTCHA.

Submitting with AJAX

Submitting a form with JavaScript saves a page load after sending a message, providing a more seamless experience. Viewers without JavaScript enabled fall back to the normal flow.

To submit your contact form with JavaScript:

  1. Build and test your contact form
  2. Override the submit event on your form
  3. Change the page to notify your viewers the message was sent

Start with this JavaScript snippet and adapt it for your site:

// Helper function to get form data in the supported format
function getFormDataString(formEl) {
  var formData = new FormData(formEl),
      data = [];

  for (var keyValue of formData) {
    data.push(encodeURIComponent(keyValue[0]) + "=" + encodeURIComponent(keyValue[1]));

  return data.join("&");

// Fetch the form element
var formEl = document.getElementById("contact-form");

// Override the submit event
formEl.addEventListener("submit", function (e) {

  if (grecaptcha) {
    var recaptchaResponse = grecaptcha.getResponse();
    if (!recaptchaResponse) { // reCAPTCHA not clicked yet
      return false;

  var request = new XMLHttpRequest();

  request.addEventListener("load", function () {
    if (request.status === 302) { // CloudCannon redirects on success
      // It worked
  });, formEl.action);
  request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


To protect your information and prevent spam these fields are encrypted before being served to the user.

  • _to
  • _cc
  • _hook


The _hook field allows you to supply a webhook that you control in order to process the form submission outside of email. The data is sent as a POST request with the Content Type application/json.

For security, we currently allow hooks from the following platforms to be used:

If you have use cases beyond these platforms, send us a message.


Note that IFTTT does not support custom JSON keys. Webhook Applets have access to the three keys value1, value2 and value3, the quantity and naming of which is fixed. This means that you will have to reflect this structure in your form, i.e.

<label>Email Address</label>
<input type="email" name="value1">

Zapier and Automate do not have a limitation on the number of fields or custom keys.

Google reCAPTCHA

reCAPTCHA embeds a CAPTCHA in your page preventing targeted and untargeted spam. CloudCannon does not send the email if the CAPTCHA fails to validate. reCAPTCHA requires additional configuration in the Site Settings.

reCAPTCHA Example

To add reCAPTCHA to your site:

  1. Sign up for an API key at
  2. Add the form element by following the instructions at the reCAPTCHA documentation.
  3. Add the secret and key to Site Settings / Forms

reCAPTCHA Configuration

Once configured, any form submissions that fail to validate will return a 401 error page.

401 Error Page