Contact Form [PHP]

Download Source Code

ContactForm.20210309-1515.zip [Downloads: 569]
SHA1: 6db9270a041c10ba2bc4c4154a1c4a92461c9217
ContactForm screen shot

The contact form enables users of your website to make contact without you having to disclose your email address publicly. The receiving email is invisible to the user, at least until you choose to answer. The user can select to get a get a copy of the mail and the sender of this mail can be set to a no-reply address. The contact form uses Google's reCAPTCHA v3 to fight abusive traffic, like spam robots.

Setup

  1. Download zip package and unpack locally on your PC.
  2. The form uses Google's reCAPTCHA v3 to protect against spam.
    Sign-up for reCAPTCHA v3 and get an API key pair for your domain: https://www.google.com/recaptcha/admin/create
  3. Edit ContactForm.php and change configuration:
    • Enter the reCAPTCHA v3 key pair: Site key and secret key.
    • The RECAP_THRESHOLD is default 0.5 and can be modified to suit your site. Also see https://developers.google.com/recaptcha/docs/v3
    • Choose language: e.g. "en_US". If your language is not available you are welcome to make a translation; use an existing language file as template.
  4. Edit index.php and set the options in the constructor for ContactForm:
    • Receiver e-mail address(es) by 'receivers': Multiple e-mails can be added comma separated. These are visible to each other but not to website users.
    • Sender e-mail address by 'sender': This is shown as the from address for all sent mail including if the user selects to get a carbon copy.
      Some webhosts require this to be an existing e-mail account on the hosting domain. Typically use a no-reply address.
    • Set the reCAPTCHA Action by 'reCapAction': This will identify the form when viewing the reCAPTCHA Admin Console: https://www.google.com/recaptcha/admin
      If not specified, the default of 'ContactFormSubmit' is used.
  5. Upload the folder to your webserver via FTP.
  6. Request the file contact/index.php in your webbrowser and test the system!