Skip to content

Protecting email addresses

Working with or without javascript it’s combine two technique for email protection ROT13 and CSS

function mail($email, $text = null) {
return '<script type="text/javascript">document.write("' .
addslashes(
str_rot13(
'<a href="mailto:' . $email . '" rel="nofollow">' . ($text ? : $email) . '</a>'
)
) . '".replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));</script>' .
'<noscript><span style="unicode-bidi: bidi-override; direction: rtl;">' . strrev($email) . '</span></noscript>';
}