The "mailto:" Tag

Back to Technical FAQ
How can I avoid using the "mailto:" tag on my website to prevent spam?

Spam Robots or Spiders "crawl" the Internet searching for "mailto:" tags. To create a clickable "mailto:" hyperlink that is spam resistant, use the following JavaScript on your web pages.

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
user = "myusername";
site = "myhost.com";
document.write('<a href=\"mailto:' + user + '@' + site + '\">');
document.write('Email me!' + '</a>');
// End -->
</SCRIPT>

This will result in a "mailto:" like this: Email me!

Steps to create a clickable "mailto:" hyperlink:

  1. Copy and insert the above JavaScript into your html source code at the mailto: insertion point.
    Note: Some html authoring tools may require you to use an automated tool for inserting the JavaScript
    (e.g., Insert > Script Object in Dreamweaver).
     
  2. Edit the script to include the user name and mail host.
    For example, suppose email should be sent to jdoe@cs.stu.edu. Within the script, the lines that read:
    user = "myusername";
    site = "myhost.com";
    must be changed to:
    user = "jdoe";
    site = "andrew.stu.edu";
     
  3. Save your html file. The JavaScript will generate a clickable link that reads "Email me!".




Department of Computer Science • Stony Brook University, Stony Brook, NY 11794-4400 • 631-632-8470 or 631-632-8471