January 9, 2014 11:50 am

How to Hide your Email Address from spam bots

As a Web Developer you have to mention your email address in contact us pages or any pages and now days spam bots can easily copy that emails and send spam promotions on your email address, so in this article I am going to show you few settings in which no any spam bot can get your actual email and failed to spam your inbox. Have a look on blow explanation and integrate in your web applications.

Hide your Email Address from spam bots

How spammers work to get your email address:

Mostly spammers look for “@” sign in your HTML page and grab words before and after “@” sign like [email protected] and that email address match with there pattern-search and store it in there database and use it for spamming.

1. Hide your email with CSS

Here I used  ::before and ::after pseudo-elements in CSS to insert email id and domain in mail-data element using this method only shows email in browser bot cannot see your email address.

An other CSS example to hide actual email.

Above example can hide extra tags text with CSS attribute display: none; and show original email on webpage but spammers get wrong address and not gonna send email on that email.

2. Render Email through JavaScript:

If you want to create mailto hyperlink and don’t want to spammers get your email address then above example is the best for you and it works on your onclick event replace __AT with “@” and __DOT with “.” to complete proper email address. Example: Contact Us.

If you are using WordPress there is a predefined function in WordPress to handle spam bots.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.

Tutorial Categories:
  • Nice snippents 🙂

    David Walsh’s email encoding function is nice too.

    function encode_email($e) {
    for ($i = 0; $i < strlen($e); $i++) { $output .= '&#'.ord($e[$i]).';'; }
    return $output;

    echo(encode_email('[email protected]'));