A tool that encodes email addresses

Leaving your email address somewhere on the web is like asking for spam to be delivered into your inbox, however customers often feel comfortable when there’s more than a phone number or simple contact form shown on your contact page. Moreover once you submit your websites into say 10 or 20 various web directories, I would put my money there’s at least one spammer behind one of those directories waiting for email addresses to be collected and misused. In order to elimitate chances of first of the mentioned options, the proper way how to display email address is by using encoded characters.

spam is unsolicited e-mail.

 

Code example

<?php //encodes email address //function to encode characters function zakoduj_znaky($in) { $l = strlen($in); $ret = ""; for($i=0;$i<$l;$i++) $ret .= "&#".ord($in[$i]).";"; return $ret; } //function to convert apostrophes function konvertuj_vystup($in) { $najdi[] = "’"; $vymen[] = "’"; $cnt = count($najdi); for($i=0;$i<$cnt;$i++) $in = str_replace($najdi[$i],$vymen[$i],$in); return $in; } $str[] = "someone@server.com"; //address $str[] = "visible email address, i.e. email me"; //visible address $str[] = "title tag - hover"; //title tag $str[] = "subject of email"; //subject $cnt = count($str); for($i=0;$i<$cnt;$i++) $kod[] = zakoduj_znaky($str[$i]); //<a href="mailto:$str[0]?subject=$str[3]" title="$str[2]">$str[1]</a> $email[’display’] = "<a href=\"mailto:".(zakoduj_znaky($str[0]))."?subject= ".(zakoduj_znaky($str[3]))."\" title=\"".(zakoduj_znaky($str[2]))."\">". (zakoduj_znaky($str[1]))."</a>"; echo "<div><h2>Use following when displaying your email address on the web</h2> <textarea cols=\"100\" rows=\"10\" readonly>".($email[’display’]). konvertuj_vystup("</textarea><p>It will appear as ". htmlspecialchars_decode($email[’display’])."!</p></div>"); ?>

Other tools & help

If you need help with PHP scripting, Apache setup and server-related situations, drop me a line. You’re also welcome to visit other tools - they’re listed below.