Grow your CSS skills. Land your dream job.

Obfuscating e-mail addresses [anti-SPAM]

  • # July 22, 2009 at 8:17 am

    Hi guys,

    Was wondering – how do you obfuscate the e-mail addresses on your pages? I found some really nice ideas over here:
    http://techblog.tilllate.com/2008/07/20 … -compared/
    ..but that does not cover wrapping the e-mail address in an anchor (mailto:example@example.com).. So how do you do this?

    I was actually looking for a non-javascript solution.

    Regards,

    -H

    # July 22, 2009 at 10:04 am

    There really is no solution, especially without javascript and even then there are all sorts of accessibility issues.
    I recommend people use a contact form and if they insist on having a ‘mail to’ link I just warn them to expect lots of spam.
    Whatever you do the spammers will always be one step ahead.

    # July 22, 2009 at 8:31 pm

    I seriously cannot be the only one ever to think of this?!!!!
    Maybe so. I just thought of this now, tested it and it works

    Make an anchor link go to something like http://in.com/email.php and in that have the address code:

    Code:
    < ?php header( 'Location: mailto:mattvot@domain.com' ); ?>

    You could even get adventurous:

    Code:
    < ?php
    $f = $_GET["f"];
    $d = $_GET["d"];
    $t = $_GET["t"];
    header( 'Location: mailto:' . $f . '@' . $d . $t . '' );
    ?>

    and make the anchor link hit http://in.com/email.php?f=mattvot&d=domain&t=.com

    Here’s a more compressed version of the code above to reduce file size:

    Code:
    < ?php header('Location:mailto:'.$_GET["f"].'@'.$_GET["d"].$_GET["t"].'');?>

    So your final HTML markup would look something like this:

    Or even:

    # July 22, 2009 at 9:17 pm

    You’d have to sanitize the shit out of those variables, but it’s an interesting idea for sure.

    # July 22, 2009 at 9:33 pm

    cool. I’ve just thought I may launch a web app, similar to tinyurl for this sort of thing when I get the time

    # July 22, 2009 at 9:34 pm

    This is what I’ve been doing to hide my email address.

    1. I utilize this CSS class (below) which reverts the orientation of the content from right to left.

    Code:
    .email {
    unicode-bidi: bidi-override;
    direction: rtl;
    }

    2. Then, I convert ASCII characters to Unicode at http://www.mikezilla.com/exp0012.html

    3. The final code looks like:

    # July 22, 2009 at 11:13 pm

    Chris,

    I’m a hack when it comes to PHP. I understand what’s going on with the code here but can you explain "sanitize the shit out of those variables" please?

    thx
    -Michael

    # July 23, 2009 at 5:10 am
    "mvaughn" wrote:
    Chris,

    I’m a hack when it comes to PHP. I understand what’s going on with the code here but can you explain "sanitize the shit out of those variables" please?

    thx
    -Michael

    The PHP code from above takes GET variables and uses them to execute a bit of code, but because GET variables are very easy to manipulate you should always limit the input possibilities (‘sanitizing’). This security thingie is similar to SQL injection (the Wikipedia article explains more)

    @danilolee: There are crawlers/bots out there that can read out ASCII characters…

    @mattvot: your PHP solution sounds like something, but I’ll have to keep looking for a non-PHP solution as some of my clients have a hosting provider that does not support php :-/.
    I like your idea of the web app, I’d be glad to help you set up something for that. Just shoot me a PM.

    # July 23, 2009 at 7:29 pm

    danilolee,
    You can use this PHP function I wrote to convert to ascii.

    <?php
    # http://bcdc.us
    function mailacsii($name, $domain, $link=NULL) {
    $email = $name . ‘@’ . $domain;
    if (!$link): $link = $email; endif;
    foreach (str_split($email) as $obj)
    {
    $ascii .= ‘&#’ . ord($obj) . ‘;’;
    $output = ‘<a href="mailto:’ . $ascii . ‘">’. $link .’</a>’;
    }
    return $output;
    }
    ?>
    <html>
    <!– usage examples –>
    example a) <?php echo mailacsii(‘hello’, ‘world.com’, ‘Send Email’); ?><br />
    example b) <?php echo mailacsii(‘hello’, ‘world.com’); ?>
    </html>

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".