SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Problem using "%40" instead of "@" in mailto link

    I had used the following code which was supposed to help stop e-mail collection & spam.

    Code:
    mailto:joe%40example%2ecom
    Then someone said the link was not working with their iPad. So I reverted to plain old @ and .com to get it working.

    Is this bad practice?
    Why would their iPad not parse the html properly?
    Is there another "easy" method to stop spam when a mailto link is necessary?

    Appreciate any comments.

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,882
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by zot View Post
    I had used the following code which was supposed to help stop e-mail collection & spam.

    Code:
    mailto:joe%40example%2ecom
    Then someone said the link was not working with their iPad. So I reverted to plain old @ and .com to get it working.

    Is this bad practice?
    Why would their iPad not parse the html properly?
    Is there another "easy" method to stop spam when a mailto link is necessary?

    Appreciate any comments.
    If you use @, that should have the same effect as @. As far as I know, it should work on all devices, but I don't have an iAnything so I can't check it...

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Stevie D View Post
    If you use @, that should have the same effect as @.
    only in HTML - not in URLs and the mailto: on the front of the address indicates that it is supposed to be a URL rather than HTML.

    Anyway with the mailto: there you may as well use @ since the mailto identifies it as an email address regardless of any obfuscation applied.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    I put much thought into this a while back. There are three perfect ways to do this. Option one is preferred by me. In short you hide it with JS. But if JS is off plain text shows. Most the the css hiding ways don't work as explained in the article. http://www.websitecodetutorials.com/...n-tutorial.php

    I don't get any spam using this. Knowbody would.

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Stevie D and felgall for your replies. Thanks Picnic for your link - that's quite a comprehensive list! I like solution 2 and will try that next time I need.

  6. #6
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zot View Post
    Thanks Stevie D and felgall for your replies. Thanks Picnic for your link - that's quite a comprehensive list! I like solution 2 and will try that next time I need.
    Why your just going to use the masked @? FYI that may trick 1 out of 20 bots.

  7. #7
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    only in HTML - not in URLs and the mailto: on the front of the address indicates that it is supposed to be a URL rather than HTML.
    Presumably the URL is supposed to be in an attribute value, where entities work fine and are perfectly allowed in all versions of HTML.
    Simon Pieters

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by zcorpan View Post
    Presumably the URL is supposed to be in an attribute value, where entities work fine and are perfectly allowed in all versions of HTML.
    The %40 should also work in an attribute value that is allowed to contain a URL so that it isn't working is an indication that it is not being used in an HTML attribute.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  9. #9
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    If you want to encode the HTML characters and still use a mailto link, you will also need to encode the "mailto:" as well. For some reason, you can't mix the two.

    PHP Code:
    function string_to_html_ascii($string)
    {
        
    $ascii NULL;
         
        for (
    $i 0$i strlen($string); $i++)
        {
        
    $ascii.= '&#'.ord($string[$i]);
        }
         
        return(
    $ascii);
    }


    $mailto_ascii='&#x6d;&#x61;il&#x74;o&#00058';

    $email string_to_html_ascii('name@example.org');

    echo 
    '<a href="'.$mailto_ascii.$email.'">email me</a>'
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    The %40 should also work in an attribute value that is allowed to contain a URL so that it isn't working is an indication that it is not being used in an HTML attribute.
    "mailto link" in the subject indicates otherwise.

    That %40 isn't working could just be a bug in the browser or the email app or the OS glue.
    Simon Pieters


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •