Contact Form Processing Products - for all your needs

FormMail • Form Encryption • Hosted Forms

reCaptcha version 2

For an overview of why you might want to use reCaptcha or other CAPTCHA products, please view the How-To guide on stopping bots.

These instructions are for version 2 of reCaptcha. You can also read the deprecated instructions for reCaptcha version 1.

Built-In Support for reCaptcha

Using reCaptcha with Tectite FormMail is easier than using it with other form processors. This is because Tectite FormMail has built-in support for reCaptcha.

However, you still need to perform some steps to install reCaptcha and configure your HTML forms to use it.

The reCaptcha website provides instructions for setting it up with any PHP form processor.

For Tectite FormMail, you must skip the instructions for modifications/additions to the form processor.

Please follow the instructions below for installing reCaptcha with Tectite FormMail.

Note that unlike other CAPTCHA systems, reCaptcha does not use PHP sessions. This can make it easy to get working if your server is poorly configured and you have problems with PHP sessions.

Please note the following server requirements for using reCaptcha:

  • PHP version 5.2.0 or later
  • Tectite FormMail version 9.14 or later
  • Tectite formval-v12.js (version 12) or later (if you're using Ajax forms)

Note: FormMail can use CAPTCHA to prevent incorrect or spam form submissions, as well as use it for auto responding. If you want to do both, make sure you read the section in the Autoresponding How-To guide.

Getting Started - First Step

Before you attempt to implement reCaptcha or any other spam protection, you must first get your HTML form working without these features.

This means you won't be confused by other unrelated errors or problems when you try to add in reCaptcha.

In particular, it's important that FormMail can alert you about errors. So, make sure you have set DEF_ALERT inside FormMail's configuration section and run the testalert test.

Second Step

Read how reCaptcha works.

Here's what you need to do:

  1. Signup on the reCaptcha website to obtain a public and private key.
  2. Add the reCaptcha Challenge Widget. You need to decide where in your form you want to display the Captcha request (just before the Submit button is a good place). Click to view the detailed instructions and sample HTML code.

    In case Google change the URL unexpectedly (they do that sometimes!), we've replicated their instructions below.

    Install the reCaptcha widget code into the <head> section of your page:

    <script src="" async defer></script>

    Display the reCaptcha widget in your HTML (just before your submit button, for example):

    <div class="g-recaptcha" data-sitekey="your_site_key"></div>

    Replace your_site_key with your reCaptcha site key (this is not the secret key; it's the other one.)

  3. Reload your HTML form in your browser. It should now display the reCaptcha widget.
  4. You must derive a field called "imgverify" from the reCaptcha field "g-recaptcha-response" so that FormMail receives the user's CAPTCHA input. Here's an example of this:
    <input type="hidden" name="derive_fields"
          value="imgverify=g-recaptcha-response" />
  5. Now proceed to the following steps on this page (below).

Third Step

Modify the configuration section of your copy of FormMail to include the secret key you received from the reCaptcha admin.

You need to set the RECAPTCHA_PRIVATE_KEY setting in FormMail. For example:


Fourth Step

Use the REQUIRE_CAPTCHA feature to enforce reCaptcha validation:

$REQUIRE_CAPTCHA = "Confirm you are not a robot.";

From around August 2016, reCaptcha started using larger responses. If your MAXSTRING setting is the default of 1024, you'll need to increase this to allow the reCaptcha response to be passed correctly.

$MAXSTRING = 2048;

The Final Step

Test your form now with the following separate tests (reload the form each time):

  1. click to confirm you are not a robot, and solve any problem shown by reCaptcha
  2. do not click the confirmation

Using reCaptcha to Allow Auto Responding

FormMail's auto responding feature requires CAPTCHA to protect your server from becoming a spam gateway.

To use reCaptcha for this purpose, simple derive the field called "arverify" from "recaptcha_response_field" instead of "imgverify". (In the instructions above, replace "imgverify" with "arverify".

To enforce CAPTCHA for form submission and also enable auto responding, you simply do two derivations:

<input type="hidden" name="derive_fields"
  arverify=g-recaptcha-response" />


<input type="hidden" name="derive_fields"
  arverify=imgverify" />