
To stop contact form spam without annoying real customers, combine several light defences: a hidden honeypot field that bots fill in, a minimum time check so the form rejects instant submissions, an invisible challenge such as Cloudflare Turnstile or reCAPTCHA v3, server-side validation and rate limiting, and optionally a spam filter such as Akismet. Visible puzzle CAPTCHAs should be a last resort, because they reduce genuine enquiries and are hard for some users. Also, this guide explains each method with code and WordPress options.
- Start with a honeypot and a time check; they stop most bot spam invisibly.
- Add Turnstile or reCAPTCHA v3 if spam continues; both are usually invisible to humans.
- Always validate on the server. Bots skip your JavaScript.
- Human-written spam needs filters, rate limits and keyword rules, not CAPTCHAs.
Stop contact form spam: types of form spam
| Type | Signs | Best defence |
|---|---|---|
| Simple bots | Every field filled, instant submits, random text | Honeypot, time check |
| Smarter bots | Run JavaScript, mimic browsers | Turnstile, reCAPTCHA v3, rate limiting |
| Human spam (SEO, marketing offers) | Well-written pitches, real emails | Akismet, keyword and link rules, block repeat senders |
| Abuse of your form to send email | Your server sends spam to others | Never send the user's message to their own email automatically |
Stop contact form spam: 1. Honeypot field
Then add a field that humans cannot see. Bots usually fill every input, so the server rejects any submission with a value:
<div class="hp" aria-hidden="true">
<label for="website">Leave this empty</label>
<input id="website" name="website" type="text" tabindex="-1" autocomplete="off">
</div>
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
<?php
if (!empty($_POST['website'])) { http_response_code(200); exit; } // pretend success
Hide it with CSS positioning rather than type="hidden", which bots recognise. Returning a normal success response stops bots from learning that they were caught.
2. Minimum time check
Humans take several seconds to fill in a form; bots submit instantly. Store the time the form was shown and reject submissions faster than about 3 seconds:
<?php
// When rendering the form
$_SESSION['form_t'] = time();
// When processing
if (time() - ($_SESSION['form_t'] ?? 0) < 3) { http_response_code(200); exit; }
A signed timestamp in a hidden field works too if you do not use sessions.
3. Cloudflare Turnstile or reCAPTCHA v3
Cloudflare Turnstile is free, privacy-friendly and usually invisible; it does not require using Cloudflare for your DNS. reCAPTCHA v3 gives each request a score from 0.0 to 1.0 without a puzzle, and you choose the threshold (0.5 is a common starting point).
Both require a server-side check of the token:
<?php
$res = file_get_contents('https://challenges.cloudflare.com/turnstile/v0/siteverify', false,
stream_context_create(['http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query([
'secret' => getenv('TURNSTILE_SECRET'),
'response' => $_POST['cf-turnstile-response'] ?? '',
'remoteip' => $_SERVER['REMOTE_ADDR'],
]),
]]));
if (!json_decode($res, true)['success']) { exit('Verification failed'); }
Keep the secret key on the server, never in the page.
4. Server-side validation and rate limiting
- Validate every field on the server: required fields, length limits, a valid email format, a plausible phone number.
- Reject messages with many links, or any links at all if your customers never send them.
- Limit submissions per IP, for example five per hour, and block repeat offenders.
- Strip HTML from messages and never use user input in email headers, which prevents header injection.
5. Content filters for human spam
- Akismet (WordPress) checks submissions against a large spam database. It is free for personal sites and paid for commercial use.
- Block common spam phrases ("SEO services", "guest post", "crypto") if they never appear in real enquiries.
- Flag rather than delete, at least at first, so a genuine message is not lost.
Stop contact form spam: WordPress form plugins
| Plugin | Built-in spam options |
|---|---|
| Contact Form 7 | reCAPTCHA v3 and Turnstile integrations, Akismet; honeypot via add-on |
| WPForms | Anti-spam token, Turnstile, reCAPTCHA, hCaptcha, Akismet, country and keyword filters |
| Gravity Forms | Honeypot, reCAPTCHA, Akismet |
| Fluent Forms / Formidable | Honeypot, Turnstile, reCAPTCHA, Akismet |
Enable the honeypot first, then add one invisible challenge. Stacking several CAPTCHAs hurts real users more than bots.
Stop contact form spam: make sure real enquiries arrive
Spam filters on your inbox can also catch real form emails. Send form notifications through an authenticated SMTP service with SPF, DKIM and DMARC set (see our business email guide), store submissions in the database as a backup, and test the form monthly.
Stop contact form spam: frequently asked questions
Why am I still getting spam with reCAPTCHA?
Humans, or services that solve CAPTCHAs, send some of this spam. Add content filters and rate limits, and check that the token is verified on the server.
Do CAPTCHAs hurt conversions?
Visible puzzles can. Invisible options such as Turnstile, reCAPTCHA v3 and honeypots have little effect on genuine users.
Should I hide my email address on the site?
Bots harvest plain email addresses. A form or a WhatsApp button reduces this; see our WhatsApp button guide.
Related guides: Favicon Size Guide, Website Width and Common Screen Resolutions and Best Image Size for Websites.
For official guidance, see MDN Web Docs.
Spam taking over your inbox?
We build secure, spam-protected forms with reliable delivery as part of our web development and maintenance services. Contact us.
Written by the ItsWebExpert team, a web design and development company in Karachi building websites, online stores and apps for businesses across Pakistan.
Ask a Question on WhatsApp