Skip to content
All articles

Contact form: stop spam without a captcha

Stop contact form spam without picture puzzles and without Google reCAPTCHA: honeypot, time check, rate limit and privacy-friendly alternatives.

16 November 20264 min readDevrim Yilmaz
Contact form: stop spam without a captcha

As soon as the contact form is online, the first messages arrive: loan adverts, links to dubious shops, texts that make no sense. The senders are usually programs, so-called bots, that fill in forms on the web automatically. The usual answer is a captcha. But it often works without one. Here you will learn which protective measures exist, how good they are and what to watch out for regarding data protection. The legal references are to German and EU law. Not legal advice.

Why a captcha is not the best solution

A classic captcha makes visitors click on pictures or type in distorted letters. That takes time, is annoying and is hard for some people, for example with a visual impairment. Every hurdle before sending can cost you an enquiry.

With Google reCAPTCHA, data protection comes on top. The script is loaded from Google, which sends the visitor's IP address to Google. According to Google's own documentation, reCAPTCHA also sets a cookie called _GRECAPTCHA. Under § 25 TDDDG, storing information on the visitor's device requires consent unless it is strictly necessary for a service the user explicitly requested. Whether that applies to reCAPTCHA has not been finally settled. What is certain: reCAPTCHA belongs in the privacy policy. If you hide the reCAPTCHA badge, Google requires the visible notice "This site is protected by reCAPTCHA".

Five measures without a captcha

1. Honeypot

A honeypot is an extra field in the form that people cannot see. Bots like to fill in every field they find. If something is entered in the invisible field, the message is discarded. Important: the field should also be hidden from screen readers so that blind users do not accidentally type into it.

2. Time check

A person needs a few seconds to read and fill in a form. A bot often sends it immediately. So the website remembers when the form was loaded. If the message arrives faster than a few seconds, it is sorted out.

3. Rate limit

The server only accepts a limited number of messages per hour from the same address. That slows down bots that send a form hundreds of times and protects your inbox from a flood.

4. Checks on the server

All checks must happen on the server, not only in the browser. A bot can simply skip checks in the browser. Useful examples:

  • really checking required fields
  • a maximum length for every field
  • recognising suspicious patterns, such as lots of links in one message

5. Privacy-friendly checking services without puzzles

There are services that work without picture puzzles. The browser solves a small computing task in the background, called proof of work. People do not notice it, but for bots that want to send thousands of forms it becomes expensive. Two examples:

  • ALTCHA is, according to its maker, open source, can run on your own server and sets no cookies.
  • Friendly Captcha, according to its maker, also uses proof of work and no cookies. Its data centres are worldwide, an EU-only option is only available on a larger plan according to the provider.

As with every third-party service: check where data goes and name the service in your privacy policy.

A mistake you should avoid

Some forms automatically send the sender a copy of their message. That sounds friendly but is risky. A bot can enter someone else's email address and make your website send advertising to third parties, with your name as sender. A confirmation of receipt without the content of the message is safer, or leave it out altogether.

How I do it on this website

The contact form on this website works without a captcha and without cookies. It combines three of the measures above: an invisible field, a minimum time of three seconds and a rate limit per address and in total per hour. Detected bots receive a completely normal success message. That way they do not notice that their message never arrives and do not keep trying.

What the form also needs

Spam protection is only one part. A contact form also needs a privacy notice, encrypted transmission and only the fields you really need. What belongs to it is explained in GDPR-compliant contact form.

Frequently asked questions

Does a honeypot stop all spam?

No. Well-programmed bots detect hidden fields. But several measures together make it much harder for bots. What remains are often messages that people type in by hand. No filter reliably helps against those.

Is a captcha mandatory?

No. There is no obligation to protect a contact form with a captcha.

Can I simply show my email address instead of a form?

Yes. But an address in plain text is also collected by programs that send spam. Many customers also appreciate the form because they do not have to open an email program. Offering both is a good solution.

I still get spam despite protection. What now?

Check whether all checks run on the server and whether there is a rate limit. Look at the patterns in the spam, for example always the same links or languages. You can filter specifically for those.

Sources

Written by Devrim Yilmaz. Under the name DEVOSWEB I build websites for local businesses in Dietenhofen, Ansbach district, Germany. Hand-built, with care for privacy, Google and security. Meetings in person in the region or online. More about me

Questions about your website?
Free intro call, quick reply.
Send request