The cost of spam hitting contact and quote forms isn’t just a full inbox. The sales team misses the real request among hundreds of junk entries, notification emails land in the spam folder, and automatic replies sent through the form erode the domain’s reputation. Adding a single CAPTCHA is either not enough or wears out real users. The approach below is layered: it starts with invisible checks, continues with server-side limiting and ends with reliable delivery of the notification.
Types and sources of form spam
The right measure depends on how the spam is produced. The first places to look are the form entries and the server access log; POST requests from the same IP seconds apart and occasional entries scattered across the day point to different types.
| Type | Behavior | Effective layer |
|---|---|---|
| Simple bot | Sends a POST directly to the form endpoint without opening the page | Honeypot, token, time check |
| Browser-based bot | Loads the page with a headless browser, runs JavaScript | Turnstile/reCAPTCHA, rate limit |
| Hand-submitted spam | Real people fill in the form by hand, usually including links | Content filters, moderation |
| Notification abuse | Fills in the form with someone else’s email address to trigger an automatic reply | Limiting the automatic reply, rate limit |
| Header injection | Tries to change email headers by adding line breaks to fields | Server-side validation |
Pay particular attention to notification abuse. If the form sends a “We’ve received your request” email to the address the visitor typed, an attacker can use the form to send bulk email to other people’s addresses. The target isn’t the site but third parties. The complaints, however, are filed against your domain.
Protecting real users is part of the job too. Every layer costs a customer request when it produces a false positive. That’s why the order is: first the checks the user doesn’t see, visible verification only when needed.
Invisible checks: honeypot and time threshold
Honeypot field
A honeypot is a field the real user doesn’t see but that sits in the form’s HTML. Bots that fill in fields automatically fill this one too; if the field is filled, the server silently rejects the submission. For an effective honeypot:
- The field is moved off-screen with CSS; since some bots skip
type="hidden"fields and fields hidden withdisplay:none, these methods are less effective on their own. - The field name looks plausible (for example “website” or “company_web”) but doesn’t clash with the form’s real fields.
- For screen reader and keyboard users, the field is kept in a container with
aria-hidden="true"and out of the tab order withtabindex="-1";autocomplete="off"is added against browser autofill. Since browsers don’t always respect this value, the field name isn’t chosen from typical autofill names like “email” or “phone”; otherwise the real user’s browser fills in the field and the request is silently lost. - A success response is returned for a rejected submission; the bot shouldn’t learn what was caught. Rejected submissions are written to a separate log so false positives can be examined.
Time threshold and signed token
A human can’t fill in a form in less than a few seconds. A timestamp generated when the form loads is checked on submission; submissions that are too fast (for example under 3 seconds) or too old are rejected or routed to an extra check. Since the stamp can be changed on the client, it’s signed on the server side with a secret key:
<?php
// When generating the form
$ts = time();
$token = $ts . '.' . hash_hmac( 'sha256', (string) $ts, FORM_SECRET );
// On submission
[ $ts, $sig ] = array_pad( explode( '.', $_POST['form_token'] ?? '', 2 ), 2, '' );
$expected = hash_hmac( 'sha256', $ts, FORM_SECRET );
$elapsed = time() - (int) $ts;
if ( ! hash_equals( $expected, $sig ) || $elapsed < 3 || $elapsed > 7200 ) {
// Reject silently and write to the log
}
hash_equals() compares in constant time against timing attacks. The trap we see most often in the field is caching: if the page is kept in a full-page cache (WP Rocket, Cloudflare APO or a server cache), the token carries the stamp of the moment it was cached and the same value goes to all visitors. The same problem applies to WordPress nonces; since nonces are time-bound (default lifetime 24 hours), the nonce on a page that stays in the cache for a long time becomes invalid after a while. The symptom is familiar: the form works one day and gives everyone an error the next. The fix is to fetch the token with a small REST or AJAX request after the page loads, or to exclude pages containing forms from the cache. For how the layers interact, see the Cloudflare, WP Rocket and Redis guide.
Comparison of CAPTCHA options
Invisible checks filter out most simple bots; for bots that open the page in a real browser, a verification service is needed. Options commonly used in forms on corporate websites:
| Option | User experience | Server verification | Point to watch |
|---|---|---|---|
| Cloudflare Turnstile | Mostly non-interactive | siteverify API, single-use token | Data transfer to Cloudflare |
| reCAPTCHA v2 | Checkbox, image puzzle when needed | siteverify API | Puzzles can make accessibility harder |
| reCAPTCHA v3 | Non-interactive, score between 0.0 and 1.0 | The site sets the score threshold | Threshold setting and what to do on a low score |
| hCaptcha | Checkbox or puzzle | siteverify API | Puzzle frequency |
Whichever service is chosen, the rule is the same: the token must be verified on the server side. Loading the widget only on the client provides no protection; the bot sends requests directly to the form endpoint without the widget. This is the most common reason for the complaint “there’s a CAPTCHA but spam still comes in”. For Turnstile, verification is done by POSTing the secret key and the token to https://challenges.cloudflare.com/turnstile/v0/siteverify; according to the Cloudflare documentation, the token is single-use and valid for a short time (300 seconds). For reCAPTCHA, the endpoint is https://www.google.com/recaptcha/api/siteverify. Details are in the Cloudflare Turnstile documentation.
In reCAPTCHA v3, the score threshold alone shouldn’t be a rejection decision. Flagging a low-score submission as “suspicious” and moving it to a separate queue instead of deleting it keeps false positives from being lost to the sales team.
These services pass data such as the visitor’s IP address and browser signals to a third party. Under KVKK (Turkish data protection law), the service should be chosen together with the legal team for the privacy notice and the cross-border transfer assessment; the data processing side is covered in the KVKK-compliant contact form article.
Server-side rate limiting and content filters
Rate limit
Many submissions from the same IP in a short time are either a bot or notification abuse. Limiting can be done on the web server, at the CDN/WAF layer or in the application. In Nginx, a separate zone for the form endpoint is defined with the limit_req module. The example is for Contact Form 7’s REST endpoint; since Elementor Pro forms are submitted via admin-ajax.php, a different match is needed there:
# http block: 5 requests per minute per IP
limit_req_zone $binary_remote_addr zone=forms:10m rate=5r/m;
# server block
location ~ ^/wp-json/contact-form-7/v1/contact-forms/\d+/feedback$ {
limit_req zone=forms burst=3 nodelay;
limit_req_status 429;
try_files $uri /index.php?$args;
}
This block routes requests to index.php; PHP processing continues in the server’s existing location ~ \.php$ block. If Cloudflare or another proxy sits in front, $binary_remote_addr may show the proxy’s IP rather than the visitor’s. Configure the real_ip module correctly first; otherwise all visitors are limited as a single IP and real users get 503. In Elementor Pro forms, the form action’s name is carried in the POST body, not the URL, so an Nginx location match can’t tell form submissions apart from other admin-ajax.php calls; putting a low limit on all admin-ajax.php traffic breaks other functions of the site. In that case, limiting is done at the application layer (the form plugin’s hook) or with a WAF rule that can inspect the request body. The parameters are explained in the nginx limit_req documentation.
Content filters
Spam submitted by hand passes all the technical checks. This is where content rules come in:
- An upper limit on the number of links in the message; more than one URL in a quote form is rarely legitimate.
- Validation that fits the field type: only digits and permitted characters in the phone field, no URLs in the name field.
- Rejecting line break characters (
\r,\n) in the email field; this is the basic defense against header injection. - Flagging suspicious entries with a content classification service such as Akismet.
- Moving submissions caught by a rule to a moderation queue instead of deleting them.
The general rules of client- and server-side field validation are explained in detail in the client- and server-side form validation guide.
Reliable delivery of form notifications
Stopping spam is half the job. Real requests mustn’t get lost. Common delivery problems and their fixes:
- From address: The notification is sent from an address on the site’s domain, not from the visitor’s address. The visitor’s address goes in the
Reply-Toheader. Otherwise the receiving server may reject the email in the SPF and DMARC checks. - Authenticated sending: Authenticated SMTP or an email service’s API is used instead of PHP
mail(); SPF, DKIM and DMARC records must be defined for the sending domain. - Keeping the record independent of email: Every submission is also written to the database, the CRM or a ticketing system. Even if the email can’t be delivered, the request isn’t lost.
- Limiting the automatic reply: The confirmation email to the visitor is either removed or sent, in limited numbers, only for submissions that pass all checks.
- Delivery monitoring: Error logs of notification emails and DMARC reports are reviewed regularly.
Before tightening the domain’s DMARC policy, all legitimate sending sources, including form notifications, should be inventoried. If the inventory is incomplete, the first victim of p=reject is the form notification. The process is explained in the moving to p=reject in DMARC guide.
Spam prevention checklist
- The honeypot field is off-screen and defined with accessibility attributes; rejections are logged.
- A signed time token is used and doesn’t conflict with the page cache.
- The CAPTCHA token is verified on the server side; the choice of service was assessed in terms of KVKK.
- There’s an IP-based rate limit for the form endpoint; behind a proxy, the real IP is obtained correctly.
- Link count, field type and line break checks are applied on the server side.
- Suspicious entries aren’t deleted; they’re moved to a moderation queue.
- Notifications go from a domain address with authentication; the visitor’s address is in Reply-To.
- Every submission is recorded independently of email.
- The automatic reply to the visitor is limited or turned off.
- Each month, samples of rejected and accepted submissions are taken and false positives are checked.
To connect forms to request, approval and CRM flows, see the form, request and approval systems service page; for data processing and retention, see the KVKK-focused web forms service page.
Frequently asked questions
Does a honeypot field block spam on its own?
It filters out a large share of simple bots; it isn’t enough for advanced bots that load the page in a browser or for spam submitted by hand. A honeypot should be used together with time checks, CAPTCHA, rate limiting and content filters.
Why am I still getting spam after adding Turnstile or reCAPTCHA?
The most common reason is that the token isn’t verified on the server side. If the widget is only loaded on the client, the bot sends requests directly to the form endpoint. Spam submitted by hand passes the CAPTCHA anyway; that needs content filters and moderation.
Why do form notification emails end up in the spam folder?
Usually because the email is sent with the visitor’s address in the From field, or without authentication via PHP mail(), so the SPF and DMARC checks fail. Send the notification from an address on the site’s domain via authenticated SMTP or an API; put the visitor’s address in Reply-To.
How does page caching affect form security tokens?
The time token or WordPress nonce of a page in the full-page cache goes to all visitors with the same value and may become invalid after a while. Fetch the token with a separate request after the page loads, or exclude pages containing forms from the cache.