In my opinion, the best way to protect your e-mail address is to encode it in an image. This is still not 100% fool proof, but the majority of bots cannot crawl and look at the text contents of an image. I couldn’t find a simple script available online that would encode an email address as an image, so I wrote a PHP script that would do the trick.
/** * @file email.php * This script generates the e-mail address text and acts as a PNG image. */ header( "Content-type: image/png" ); define("SITE_EMAIL", "email@example.com"); define("EMAIL_FONT_SIZE", 4); $intEmailLength = strlen( SITE_EMAIL ); $objImage = imagecreate( imagefontwidth( EMAIL_FONT_SIZE ) * $intEmailLength, imagefontheight( EMAIL_FONT_SIZE ) ); $intBackgroundColor = imagecolorallocate( $objImage, 255, 255, 255 ); $intTextColor = imagecolorallocate ( $objImage, 0, 0, 0 ); imagecolortransparent( $objImage, $intBackgroundColor ); imagestring ( $objImage, EMAIL_FONT_SIZE, 0, 0, SITE_EMAIL, $intTextColor ); imagepng( $objImage );
Of course, define
SITE_EMAIL with your e-mail address and
EMAIL_FONT_SIZE with the size of the font that you’d like (it was 4 in my case).
This PHP script will generate the image, so all you need to do is link to it in the following way to display it on your web page:
<img src="email.php" />