Elegant Email Hyperlinks

This elegant hyperlink protects you and your Web site users from email spam.

Readers

June 3, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today


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 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

and write a simple JavaScript function that reassembles the link in the mailto@domain 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.

—Deepak Kumar Vasudevan
[email protected]

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like