Hide your email address online from spam bots

Tutorial by Stuart B

24th November 2021

How to fool those pesky bots from harvesting your email address

You build a brand new shiny website and deploy it on-line. Suddenly you get emails from people using email addresses like webdesigner36572@gmail.com. Now, the email address should tell you straight away that this is a scam, and if you reply, the chances are that your mail-server will throw a wobbly and quarantine the sent email as it ended up try to send out thousands of emails.

So how did you end up getting this email in the first place? The likelihood is that you wrote your email address on your website. These pesky little bots run around the internet looking for the @ symbol with a prefix (before) and a suffix (after). An email addresses basicly.

Some time ago, and simply out of curiosity, I hid an email address on a page of my website that I don't expect users to look at, the terms and conditions page, then I sat back and started timing how long it would take to get my first spam email. It turned out that it only took 2 days and suddenly I was being bombarded by people who loved my website and would I work with them.

So, here are 3 ways to avoid this entire problem.

Example 1

In this example, we basically hide the email address from bots completely. It still sees the code but as the @ symbol is hidden away using css, it won't see it as an email address. The downside of this is that a visitor to your site will see your email address, but cannot highlight or copy it.

Example 2

The second example shows the email address and it can be highlighted and copied, but only the prefix and the suffix. The @ symbol will not copy. Again the bots don't see this as an email address.

Example 3

The third example shows the email address, and it can be highlighted and copied, even by the bot, but when it is copied, the output is the email address in reverse, making it useless.

I have included a Pen below which contains all the code that you need to administer each of these examples here for you

I hope that this helps.