Can I make a Rule that will check content of an email sent from a contact form and block the send if a condition is met?

I was hoping I could set up a Rule to react on event Before Email Send, or something of that kind and then check the content, but that event doesn't exist: could I create it? Or is there a better way?

Context: I have a content type where each node is an advert for a local attraction. I have an email field which is set to display as an email contact form which can be submitted by anonymous users. I am using Mail System and Mandrill to send the emails.

Although I have Spamicide module and Captcha already installed, the odd spam email is creeping through the form. The spams are usually highly obvious and would be simple to eliminate if I could set up a keyword blacklist, but I am not sure how best to create one.

1 Answer 1


Using hook_mail_alter https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_mail_alter/7 you can check/change all mails before they are being sent.

Setting $message->send = FALSE; will stop the mail system from sending out the mail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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