Menu

Free Sendmail PHP Script with Google Captcha.

This is a basic email send PHP script that uses Google Captcha. The form is in HTML and uses java to show a thank you message if the email sends successfully. It also uses Java to contact Googles verification site which is required for Captcha. The PHP sanitizes the input for security. Designed to hide your email from bots.

To setup the script:

1.) First, go to Google Captcha and sign up. Setup your site for captcha to retrieve the needed keys.

2.) Upload the PHP script to an accessible directory.

3.) Open the script using an editor and change the “SecretKey” for Google Capcha and change the email address.

4.) The sendmail functions uses “/usr/sbin/sendmail.” This is default in most places but change to what your server requirements are.

5.) Paste the HTML/Java code on your page and edit for your layout if needed and change the “SiteKey” to yours (different than SecretKey in the PHP file).

If using a public directory be sure to use an .htaccess file to control security and to use robot.txt in your home directory to not index the directory your php script sits in.

Updated script and improved security on 3/29/2024.

Download the Send Mail with Google Captcha zip file here.

File contents:
  • emailform.php
  • HTML-code.txt
  • instructions.txt
  • optional-config.php
  • optional-htaccess

See an example below:

email form sample

License: Open Source.

A donation is always appreciated in crypto.