Banning visitors from sending emails through Contact Form 7

Tips and Guides/ 13th Sep 2017/Jamie Hoyles

Following on from my previous post, How to stop spam emails being sent through Contact Form 7, sometimes a user may wish to permanently exclude a visitor from submitting information through the plug in. This article tells you how to block a user from sending mail via the form…

The reasons for doing so can be varied – unsolicited marketing mail, hoax enquiries or malicious emails.

What we are going to do is find the user/bots IP address and exclude them from publishing comments.

First of all we’ll need to capture the problematic poster’s IP address. This can be done by adding a piece of code to the contact form. To do so navigate to Contact > Contact Forms from the left hand menu.

Next, select an enquiry form you wish to capture a user’s IP, then click the ‘Mail’ tab in the window that loads:

Scroll down the page and you will see a section titled ‘Message Body’ in this part we need to add the code:

IP: [_remote_ip]

Now when a submission is made, the contents of the email received will include the sender’s IP address.

To ban the poster from using your contact form we need to add it to a blacklist.

Navigate to Settings > Discussion

Now scroll down to ‘Comment Blacklist’ and enter the offending IP address.

Ban Visitors Contact Form 7

It’s important to note that this should only be done if you are sure you do not wish to receive contact from users using this particular IP address. Once the details are entered, the submitter will receive a fail message when hitting the send button.

If you wish to go one step further and ban the IP address from your site this can be done via your cPanel account. In cPanel’s Security tab is an icon titled ‘IP Blocker’ If an IP is entered here anyone attempting to view the website will find it inaccessible.

If you have an accounts query it is likely Jamie will be the one to help you resolve it...! Away from the office he is a condemned supporter of Blackburn Rovers, enjoys watching and playing cricket and appreciates a good meal out.
We have a very strong team here at Clook and we build on everyone's strengths and weaknesses, you have to be able to make a good brew too!

Chris James

Customer Login

Forgot Password? Cancel