Obfuscating E-mail Addresses

Do you ever wonder how your E-mail address gets on so many spam mailing lists? One way spammers collect E-mail addresses is from web pages. To help combat this problem, you can make your E-mail address show up in a scrambled looking form in the HTML source, yet it it will look and work correctly in the browser. This is done with the escape modifier.

Example 10-9. Example of Obfuscating an E-mail Address


index.tpl
---------

Send inquiries to
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>

OUTPUT:

Send inquiries to 
<a
href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">&#x62;&#x6f;&#x62;&#x40;&#x6d;&#x65;&#x2e;&#x6e;&#x65;&#x74;</a>

Although this looks like a mess in the HTML source, it will render correctly in your browser, and the mailto: hyperlink will go to the correct address.

Technical Note: This method isn't 100% foolproof. A spammer could conceivably program his e-mail collector to decode these values.