Obfuscating an Email Address

Problem

You want to obfuscate an e-mail address to prevent spam-bots from sniffing it.

Solution

Use the HTML::email() method.

This method takes one argument, the email address.

$email = HTML::email('me@local.com');

Now $email will display correctly in browsers, but it will randomly contain characters that make it hard to read.

Email is <b>&#x6d;e&#x40;l&#111;ca&#x6c;.c&#x6f;m</b>

Discussion

This method uses the HTML::obfuscate() method to obfuscate the email address.

See Obfuscating a String.

comments powered by Disqus