A modern, secure, and customizable contact form for any PHP project.
Built with Bootstrap 5, powered by AJAX, PHPMailer, and Google reCAPTCHA v3 — no jQuery, no bloat.
🔐 Designed for performance, accessibility, and clean code.
- PHP 8+ Ready – Strictly typed and future-proof
- Bootstrap 5 UI – Responsive and accessible
- AJAX Submission – No page reloads
- Google reCAPTCHA v3 – Invisible spam protection
- SMTP Delivery with PHPMailer – Secure emails
- Auto-reply to users – Confirm receipt
- Disposable email detection – Block throwaway addresses
- Honeypot spam traps – Catch bots
- Session-based rate limiting – Prevent abuse
- Easy customization – Tailor fields and styles
- Clone the repository :
git clone https://github.com/raspgot/Contact-Form-PHP.git
Or download as ZIP.
- Run it locally :
Use a local PHP server like XAMPP, MAMP or PHP's built-in server:
php -S localhost:8000
Get your reCAPTCHA secret key at Google reCAPTCHA.
In AjaxForm.php
, edit:
const SECRET_KEY = 'your_recaptcha_secret_key';
const SMTP_HOST = 'smtp.yourprovider.com';
const SMTP_USERNAME = 'you@example.com';
const SMTP_PASSWORD = 'yourpassword';
const SMTP_SECURE = 'tls'; // 'tls' (recommended) or 'ssl'
const SMTP_PORT = 587;
Note: Enable
php_curl
inphp.ini
:extension=curl
In AjaxForm.js
:
const RECAPTCHA_SITE_KEY = 'YOUR_RECAPTCHA_SITE_KEY';
And in index.html
:
<script src="https://www.google.com/recaptcha/api.js?render=YOUR_RECAPTCHA_SITE_KEY"></script>
Edit the messages in index.html
:
<div class="valid-feedback">Looks good !</div>
<div class="invalid-feedback">Please provide a valid name.</div>
- Regex-based User-Agent detection (blocks common bots)
- DNS and disposable email validation (rejects throwaway emails)
- reCAPTCHA score filtering (requires min. score 0.5)
- Honeypot hidden field (traps bots)
- Session rate limiting (max 3 submissions per hour)
- Input sanitization to prevent header injection and XSS
- Automatic user acknowledgment email
- Customizable email template with dynamic data
Feel free to open issues or submit pull requests :)
Developed by Raspgot — contact@raspgot.fr
If you find this project useful, please ⭐ star the repository !