Elegant Email Hyperlinks


My company typically uses mailto hyperlinks in our Web site so that visitors can use their favorite desktop email clients to automatically send us email. Unfortunately, these hyperlinks put our Web sites' email addresses for both the Webmaster's and users' mailboxes at risk for being spammed. Spammers typically use robot software that's similar to a search engine to crawl the Web and search for <a href="mailto:"></a> patterns. When the software finds such patterns, it adds the corresponding link targets to the spammers' databases. The spammers then send bulk email to all the addresses they collect. To avoid this risk, you can use the hyperlink

<a href="javascript:clickmail(domain,mailto)"></a>

and write a simple JavaScript function that reassembles the link in the [email protected] format, then triggers the link. For example, consider the link code that Listing 1 shows. You can rewrite this link, as Listing 2 shows, then use the JavaScript function that Listing 3 shows to reassemble and trigger that link. You can take this type of security to a higher level by removing the JavaScript code from the .htm page and maintaining it as a separate JavaScript file, which safeguards the email addresses we publish on our Web sites.

You can further extend the JavaScript function to automatically use the mailto hyperlink's other interesting features. For example, in a mailto link, you can fill the To, Cc, Bcc, Subject, and Body fields in the message box that the email client opens. Netscape Messenger goes one step further by letting you set the email priority.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.