Best Practices for Email Obfuscation To Stop Email Scraping

At Ecenica Hosting, we understand how frustrating it can be to deal with unwanted spam emails. Protecting your privacy and ensuring your online experience is safe and secure is a top priority for us. While no solution is perfect, there are several effective methods to obfuscate your email address in HTML, making it more challenging for spambots to harvest your information.

Why Obfuscate Your Email Address?

Email addresses posted in plain text on websites can be easily collected by bots, leading to an influx of spam. Obfuscating your email address is a technique used to hide it from these bots while still making it accessible to real users.

Methods to Obfuscate Your Email Address

1. HTML Character Entities

Convert your email address into HTML character entities. For example, the email example@example.com becomes:

example@example.com

The provided HTML code will render the following HTML:

example@example.com

For a clickable link:

<script type="text/javascript">
  // Decode HTML character entities
  function decodeHtmlEntities(encodedStr) {
      let textarea = document.createElement('textarea');
        textarea.innerHTML = encodedStr;
        return textarea.value;
      }

       // HTML character entities for email
       let encodedEmail = '&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#64;&#101;&#120;&#97;&#109;&#112;&#108;&#101;&#46;&#99;&#111;&#109;';
       let email = decodeHtmlEntities(encodedEmail);

  // Write clickable mailto link
  document.write('<a href="mailto:' + email + '">' + email + '</a>');
</script>

The provided JavaScript code will render the following HTML:

<a href="mailto:example@example.com">example@example.com</a>

2. JavaScript Encoding

Use JavaScript to dynamically display your email address. Here’s a simple script:

<script type="text/javascript">
  let user = "example";
  let domain = "example.com";
  document.write('<a href="mailto:' + user + '@' + domain + '">' + user + '@' + domain + '</a>');
</script>

This technique requires the bot to execute JavaScript, which many do not.

The above code will render the following HTML:

<a href="mailto:example@example.com">example@example.com</a>

3. ROT13 Encoding

ROT13 is a simple encoding method that shifts characters. You can use JavaScript to decode and display your email:

<script type="text/javascript">
  function rot13(str) {
    return str.replace(/[a-zA-Z]/g, function(c) {
      return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
    });
  }
  let email = rot13("rknzcyr@rknzcyr.pbz");
  document.write('<a href="mailto:' + email + '">' + email + '</a>');
</script>

The above code will render the following HTML:

<a href="mailto:example@example.com">example@example.com</a>

4. CSS

Separate the email address into different HTML elements:

<span class="user">example</span><span class="at-symbol">@</span><span class="domain">example.com</span>
<style>
  .user, .at-symbol, .domain {
    display: inline;
  }
</style>

This method makes it difficult for bots to piece together the full email address.

The above code will render the following HTML:

example@example.com

5. Image Replacement

Replace your email address with an image displaying the address:

<img src="email.png" alt="Contact Us">

This approach prevents bots from reading the text altogether.

  1. Base64 Encoding

Encode your email in Base64 and use JavaScript to decode it:

<script type="text/javascript">
  function decodeBase64(encoded) {
    return decodeURIComponent(atob(encoded).split('').map(function(c) {
      return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
    }).join(''));
  }
  let encoded = "ZXhhbXBsZUBleGFtcGxlLmNvbQ==";
  let email = decodeBase64(encoded);
  document.write('<a href="mailto:' + email + '">' + email + '</a>');
</script>

The above code will render the following HTML:

<a href="mailto:example@example.com">example@example.com</a>

Advanced Anti-Spam Features with Ecenica Hosting

In addition to these methods, we offer advanced anti-spam features as part of our hosting services. Our state-of-the-art spam filters, email authentication protocols, and security measures help keep your inbox clean and secure. If you haven’t already, we highly recommend enabling these features in your Ecenica Hosting control panel to further protect yourself from spam.

Conclusion

While these obfuscation techniques can reduce the risk of your email address being harvested, they are not foolproof against advanced scraping methods. Combining these methods with our advanced anti-spam features provides a robust defense against unwanted emails. If you need assistance, our support team is always here to help!

Further Reading

For more information on email obfuscation and spam prevention, check out these resources:

  1. Ecenica Support – How to Obfuscate Your Email Address in HTML
  2. W3Schools – HTML Character Entities – Learn more about HTML character entities and how to use them to protect email addresses.
  3. Mozilla Developer Network (MDN) – Email Obfuscation – A guide to creating mailto links and tips on obfuscating email addresses in HTML.
  4. OWASP – Email Obfuscation – Security-focused overview of email obfuscation techniques and their effectiveness.
  5. SpamAssassin – Email Filtering – Information about SpamAssassin, an open-source project for filtering spam.
  6. Stack Overflow – Best Practices for Email Obfuscation – Community discussion and advice on the best practices for email obfuscation.
  7. Google Web Fundamentals – Protecting Your Users from Spam – Google’s recommendations on safeguarding users from spam and protecting privacy.
This entry was posted in Web Hosting 101. Bookmark the permalink. Both comments and trackbacks are currently closed.