View Full Version : Prevent E-mail Address from being Harvested
I read somewhere that it was easy to prevent e-mail addresses from being harvested using php, but I forgot where & how.
Is there an easy way using php?
Thanks!
You can obfuscate (sp?), by inserting text and replacing characters.
eg:
joemamma@myhouse.com
becomes
joemamma no spam at myhouse dot com
however this means you can't click the link. You have to intuit the actual address.
I use a combination of javascript and php that is more functional. This script will display an email link that cannot be harvested. The first argument is the address, the second is optional and is the displayed text.
eg: contact("joemamma@myhouse.com", "Joe Mamma");
function contact($email, $display="hot_tuna")
{
if( $display == "hot_tuna" )
{
$display = "
display1 = \"" . substr($email, 0, 3) . "\"
display2 = \"" . substr($email, 3) . "\"
document.write(display1 + display2);
";
}
else $display = "document.write(\"$display\");";
$domain = strstr($email, "@");
$name = substr($email, 0, strpos($email, "@") );
$out_put = "
<script language=\"Javascript\">
<!--
emailname = \"$name\"
emailserver = \"$domain\"
document.write(\"<a href='mailto:\" + emailname + emailserver + \"'>\");
$display
document.write(\"</a>\");
//-->
</script>
";
return $out_put;
}
Or just use a simple reply form - which looks more professional and has no email address exposed. There is an example of a one file form mailer on my Tips & Scripts page (link in my sig). It also has simple validation and offers some protection against mail bombing.
vBulletin v3.6.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.