Search code examples
emailmailto

Is it ok to use mailto links?


I always thought the best thing to do is to avoid using them on your site since bots can easily pick up on them and collect your email. Up until now, I've always used contact forms for this reason. However, these days I'm noticing sites that use mailto links, and not just any sites but big design firms like Huge. I'm curious if it's "ok" to use these links. Will spammers pick up on them?


Solution

  • If it's on the internet, someone could get it with an automated process. However, you can use JavaScript to load your email address anywhere you need it on the page. This prevents the email address from being seen by a bot in most cases since you email address is not part of the source of the page.

    Here is a simple example:

    <script language="JavaScript">
        var username = "[your_username]";
        var hostname = "[your_mail_account_domain]";
        var linktext = username + "@" + hostname ;
        document.write("<a href='" + "mail" + "to:" + username + "@" + hostname + "'>" + linktext + "</a>");
    </script>