Clickable mailto link on site and spam

I’ve went and intergrated a secure PHP / Javascript contact form on a website, to be told be the owner after finishing the website that she wants her email address listed as well as the contact form.

Now, I guess I have options here to either go with the flow, do what she wants in the best way I can, or I try to explain the contact form is for a legit reason.

Now I’ve just have a read at And I’m thinking of just using the following JavaScript to create a mailto link that displays the actual address.

    <script language=javascript>  <br>
    <!--  <br>
    var username = "username";  <br>
    var hostname = "";  <br>
    var linktext = username + "@" + hostname;  <br>
    document.write("<a href=" + "mail" + "to:" + username +  <br>
    "@" + hostname + ">" + linktext + "</a>")  <br>
    //-->  <br>

Is this advised or what?


[FONT=Verdana]While the contact form may be there for a legitimate reason (ie preventing spam), that doesn’t mean that it’s the most user-friendly method. I would generally recommend providing the option to use either a contact form (allows people to choose the email address they want you to reply to) or an email link (people often have more confidence in an email than a contact form, it means they have a record for themselves of what they sent, and you don’t have to worry about eejits who mistype their own email address (and yes, a lot do!)).

I certainly would not recommend obfuscating the email address with Javascript, although if you’re allowing people to use a script-free contact form then it isn’t a cardinal sin, just a slightly bad one.

An easier way, which I have had reasonable success with, is to simply replace the @ with [noparse]@[/noparse] (in both the link text and the mailto address) – it comes out as the same, the link still works the same, but it does seem to be reasonably effective at disguising it from spambots. (I would still suggest putting a different email address there, which you can discard if it does start to pick up intolerable amounts of spam).[/FONT]

I use a similar approach, and run the e-mail address through this encoder. It seems to work pretty well at stopping spam, although I also do as Stevie D suggests and use a disposable e-mail address, just in case. (So far, I’ve not needed to change one. :x )

Nice… Very niffty indeeed and fair points made.

I actually seen your [noparse]@[/noparse] trick in another thread, shortly after posting this thread. I think it’s a good call, and I also like the look of the encoder to add some extra spice to it all. So, I’ll go with using ascii characters and symbols on a different email address that I can alias as I normally would.

Cheers, Chuggers!


Another Chuggington fan? I knew you were one of the good guys. :lol: [/ot]


Haha!!! Nothing like a bit of Story Time :)[/ot]