Website Spam Protection for Contact Forms
Almost every public contact form attracts spam sooner or later: automated bots posting links, scam offers, and junk. Left alone, it buries real enquiries and can even damage your email reputation. The best defense is a few light layers that stop bots without annoying people.
Why forms get spammed
Bots crawl the web looking for forms and submit them automatically at scale. Some try to promote links, some test for ways to send email through your server, and some probe for weaknesses. A form that sends emails directly can be abused to send junk if it is poorly built.
Layered defenses
No single method catches everything. Use a few that fit your setup.
1. Honeypot field
Add an extra field that real people cannot see, but bots fill in. If it has a value, discard the submission. Many form services support this out of the box; Formspree, for example, documents a hidden field called _gotcha for this purpose, so check your provider's current instructions for the exact name. Hide the field so that screen reader users and keyboard users do not encounter it. See accessible CAPTCHA alternatives.
2. Time checks
Bots often submit instantly. Rejecting forms completed within a second or two of loading catches some, as long as you leave generous room for real fast typists and autofill.
3. Server-side validation
Always check input on the server, not only in the browser. Verify email formats, limit lengths, and reject unexpected fields. Some spam contains many links; you can limit or flag messages with more than a couple.
4. Rate limiting
Limit how many submissions a single source can make in a given time. This also slows attempts to abuse the form.
5. Challenge services, used carefully
Some services check visitors in the background and only show a challenge when something looks suspicious. These can work well, but they involve third-party scripts and data collection, and some challenges exclude users with disabilities. Check privacy and accessibility, mention the service in your privacy information, and offer an alternative way to contact you. See privacy policy and cookie banner basics and third-party scripts and website speed.
6. Filtering and review
Many form tools and email systems have spam filters and let you review flagged messages. Make sure real messages are not being filtered out by checking the spam folder regularly.
Protect the email side
- Use a form service or backend that sends from an authenticated domain. See email for your domain: SPF, DKIM, and DMARC
- Never let visitors control the "to" address or headers of the email your form sends
- Do not publish your email address in plain text where scrapers find it, if spam to your inbox is a problem
Avoid making things worse for real people
- Keep forms short. See form field reduction: what to ask for
- Do not require puzzles to send a simple message
- Give clear error messages if a legitimate submission is rejected. See error messages and empty states
- Offer a phone number or email alternative. See how to write a contact page
Test and monitor
Submit the form yourself on desktop and mobile, with keyboard only, and with a screen reader. Check that real messages arrive. Review your spam rate over time, and adjust. See how to design a contact form that gets filled in.
Common mistakes
- Relying only on a client-side check
- Visible honeypot fields that real users fill in
- Aggressive filters that block real enquiries
- Letting a form send email without authentication
Once your forms and accounts are secure, keep an eye on the whole site. Read how to keep your website secure.