Have you noticed an alarming increase in the amount of spam you\’ve been receiving in the last 6 months? Part of the reason could be you\’ve fallen victim to the droves of email harvesting bots that scour the web.
What\’s the solution? Email obfuscation – use the following simple function to protect your email address so it becomes unreadable to the bots but still looks fine to humans:
function emailObfusc($email) {
$encoded = bin2hex($email);
$encoded = chunk_split($encoded, 2, \’%\’);
$encoded = \’%\’ . substr($encoded, 0, strlen($encoded) – 1);
return $encoded;
}
August 12th, 2002 at 3:53 am
I understand the concept of how the escape work, and how the routine works to get the output… so why doesn\’t it show up as text when I implement it?
$email2 = emailObfusc($email);
echo \"$email2\";
output is
%6a%61%6d%67%69%6e%65%40%79%61%68%6f%6f%2e%63%6f%6d
jamgine AT yahoo.com
August 12th, 2002 at 4:23 pm
that\’s the correct output ! use it in your email link as you normally would, like:
<a href=\"mailto:%77%65%62%6d%61%73%74%65%72%40%70%68%70%6b%69%74%63%68%65%6e%2e%63%6f%6d\">feedback</a>
when viewed in a browser it will display a human readable email link 🙂
for proof view the source of this page, completely at the bottom; this technique is used to display the webmaster\’s address.
August 13th, 2002 at 1:31 am
Doh!
Okay, I just set it up and the link info does show the escaped text! way cool… I have a website mod ahead of me tonight.
My test response to the mailto: hasn\’t hit my server yet, though. Which may be a Yahoo thing, or it may be something else. Can an obfuscated e-mail address be used in a mailto: link?
Amgine
August 13th, 2002 at 7:59 am
absolutely, as I pointed out in the last comment, the obfusc function is used at the bottom of every page in this site for the webmaster mailto link. View source and search for \’feedback\’.
August 13th, 2002 at 2:24 pm
Yes, found my test e-mail this morning, and did the view source… My work last night didn\’t work quite so nicely, but I\’ll be back at it soon. I\’ll also be suggesting this as an element for the user module on the project (phpWebSite), if that\’s okay with you.
How should I credit this in my source code?
Amgine
August 13th, 2002 at 10:19 pm
Thanks Amagine, but there\’s no need for credit – I grabbed this myself I can\’t even remember from where 😉
October 27th, 2002 at 5:04 pm
being new to php, i\’m not knowing how to use this code snippet, could
anyone walk me through it please?
February 3rd, 2003 at 11:00 pm
This code does not prevent harvesters from getting the address. The hex coding is easily converted back to text and the address is harvested.
Stan Rambin