I've noticed all of my Contact Form spam has a referrer that matches the form's location. Building a module is out of my comfort zone for now (not really a developer). I am currently using the Honeypot plugin, though, so I have a simple conditional in my contact page which compares the referer to the URL and if it's the same, fills the Honeypot field with a value.

The Honeypot plugin will set the isSpam flag to true, which prevents the message from being delivered. Then the form redirects to its default "Thank You" template.

What I want is for this template to display a message that the submission was flagged as spam and not delivered. I can see that /craft/vendor/craftcms/contact-form/src/Mailer.php has code that sets a message when isSpam is set to true:

if ($event->isSpam) {
   Craft::warning('Contact form submission suspected to be spam.', __METHOD__);
   return true;

…but for the life of me I can't find how to access Craft::warning or to have it output into a template. Any pointers are greatly appreciated. Thank you!


Currently not possible without forking the Contact Form plugin and changing the logic to do what you're looking for.

There are other form builder/contact form plugins that might have more options when dealing with SPAM you might want to look at as well: https://plugins.craftcms.com/search?q=contact%20form

  • Thanks Brad, that's too bad about the spam flag but I'll look into the Form code. I did comb through the other contact plugins but my needs are pretty simple compared to what is out there. :) Mar 12 '20 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.