I thought of a methode, to obfuscate an EMail adresss via the database:
I store the real addresses together with a key in a db table. In the document, where you want to show a mail-link, there is a <a href=....> link which calls a php-script with the db-key to the mailaddress as parameter. The script retrieves the mailadress from the dbase. Then it composes a js-script, that starts the users mailclient with the real address inserted. To make it easier for webusers, the <a href=...> link can be inserted by a little snippet.
I think, this method minimizes the additional server load: addional work has to be done when a user hits a link only. As disadvatage, it is less adequate for unexperienced webredactors: You need access to the dbase to add a new mailadress and you have to use a snippet-call, to create a mailto-link.
Here are the details:
1. Using phpadmin, create a new table, named "mail_adr" with two varchar fields: "mail_id" and "mail_address".
Insert your mail-adresses together with a identifying key (I use initials).
2. Create a new snippet named "MyMail" and insert the following code:
<?php
$output = '<a href="assets/snippets/my_mail/get_mail_adr.php?adr_id=' ;
$output .=$key ;
$output.='">' ;
$output.=$display ;
$output.='</a>' ;
return $output;
?>
3. Creat a new folder "my_mail" in assets/snippets. Create a file inside this folder, name it "get_mail_adr.php" and insert the following code:
<?php
include "../../../manager/includes/config.inc.php";
$noscript_out = '<div> <noscript>';
$noscript_out .= '<p>To use this mail function, you have to enable Javascript. </br>';
$noscript_out .= 'Please click back on your browser menu, to return to the website. </p>' ;
$noscript_out .= '</noscript></div>';
echo $noscript_out;
$key = $_GET[adr_id]; //key for mail adress in dbase
//Connect to dbase
$dbase = str_replace('`','',$dbase);
$my_db_serv = mysql_connect($database_server, $database_user, $database_password);
$my_db = mysql_select_db($dbase);
//Query dbase
$sql = "SELECT mail_address FROM mail_adr WHERE mail_id = '$key' ";
$ergebnis = mysql_query($sql);
if(!$ergebnis)
{ die( "Error accessing data - ".mysql_error()); }
else {
// extract mail adress
$row = mysql_fetch_assoc($ergebnis);
$mail_adresse=$row['mail_address'];
// compose JS-Script
$command = '<script type="text/javascript">';
//Not found -> produce an alert
if ($mail_adresse=='') {
$command .="alert('Mailadresse unbekannt');";
}
//open mail Client and insert mails adress
else {
$command .='location.href="mailto:';
$command .= $mail_adresse.'";';
}
$command .= 'history.back();';
$command .='</script>';
echo($command);
}
?>
4. In your documents or templates put the snippet call
[!MyMail? &key=`your db-key of recipient` &display=`Your link message to display on page`!]
where you want to show an Email link.
I tested the code in FF and IE7. It is my second ever php-script - be kind