Martin Geber
Martin is student at EUFH, Cologne, DE
working casually at DataCollect & EWE
who loves economies, web-technology
and all things J.K. Rowling.
Learn More.
Everybody knowes these nasty little emails trying to sell you Viagra and stupid
stuff like this. Everybody hates those emails, which were send by a mass-sender
which got your email address from the WWW.
These spam senders are crawler like Google or
Yahoo! but they are just looking for data which matches
this sheme: anything@domain.top-level-domain.
So there are pages like PHP.net which totally don't link
any correct email addresses at all, they makes it necassery to edit the address
in your email program. At the page of PHP Classes
is this sheme used: anything at domain . top-level-domain. Both pages trys
to protect the email addresses of their users, what is laudable, and necassery.
But in my opinion this isn't the right way to save email addresses, as it forces
you to type manually an address to your email program. But how can we sheet the
crawlers of those spam engines in a way which doesn't make it necassery to edit
anythink after clicking the link? There are some huge JScripts which use the
document.write() function and variables, but this is difficult for PHP
generated websites and takes a longer execute time for the HTML on clients side,
there must be another way.
And there is one, indeed. The German page php4u.net published a very useful function, which encrypts all email addresses into a charset the spam engine wouldn't understand but which is accepted by the programs: You will see the correct address by hovering the link as well as you see it when you click the link. Here is the pretty short code:
<?php /** * Encode E-Mail Addresses. * * @param string $mail: E-Mail Address * @return string Encoded E-Mail Address */ function no_spam($mail) { $str = "" $a = unpack("C*", $mail); foreach ($a as $b) $str .= sprintf("%%%X", $b); return $str; } // Usage $mail = no_spam('test@mail.com'); $link = '<a href="mailto:' . $mail . '">Email</a>' echo $link; // A subject is also possible: $mail = no_spam('test@mail.com'); $link = '<a href="mailto:' . $mail . '?subject=Test%20Subject">Email</a>' echo $link; ?>
When your email address would be test@mail.com, the returned string will be:
%74%65%73%74%40%6D%61%69%6C%2E%63%6F%6D So your link would be:
<a href="mailto:%74%65%73%74%40%6D%61%69%6C%2E%63%6F%6D">Email</a>.
I'm using this function for my page Emma Watson Empire and as long as I didn't gave my email address to anyother page, I didn't get any spam. Just try to use this function, you and your vistors will love it.
Help to tidy up the inboxes of your vistors and your own!
Python Code is Poetry
© Copyright 1987-2008
Martin Geber
Django | XHTML 1.1 | CSS | Imprint