Last updated 12 July 2016. Created on 28 October 2014.
Edited by undersound3, PsyCode, peterx. Log in to edit this page.

The SpamSpan module obfuscates email addresses to slow down spambots. SpamSpan implements the technique at Future versions could also hook up with the Email Field module and Webforms for a better solution.

Contact data connected to content

Spamspan processes email addresses in content. For most content, the only email address is a contact address. Given the lack of support for the Spamspan module, a better approach is to attach the contact data as fields then format the content to put the contact data up the top or down the bottom.

Use the Email Field module to create the email address. The Email Field module has an option to use Spamspan for display of the email address and a safer option to replace the address with a form.

November 2014 rewrite

The Drupal 7 version was rewritten in November 2014 to reduce memory usage on regular page loads. The full code is loaded only for the admin page and content editing. See version 7.x-1.2.

Drupal 6

The Drupal 6 version is not supported. The November 2014 maintainer worked only on Drupal 7 and 8 sites. The D6 version has thousands of users and could use a co-maintainer who works on Drupal 6.

There was an unsupported Drupal 5 version used on only 140 sites. The D5 version was dropped in November 2014.

Internal problems

The Spamspan code depends on a regular expression. Changing regular expressions are painful, it's up there with kidney stones. There are several requests for extra features that individually would make the regular expression astronomically difficult and combined might never work.

If someone wants to work on enhancements in this area, the best approach would be to keep the current regex and add an option to experiment with a more complex regex. Users needing extra features could switch on the complicated version then switch it off when their Web server bursts into flames.

Test page

The module now includes a test page. Follow the Config link after you switch the module on. The page lists the built in defaults and provides a basic form for testing the output() function that alters links.


The following text is from the README.txt file.

The problem with most email address obfuscators is that they rely upon
JavaScript being enabled on the client side. This makes the technique
inaccessible to people with screen readers. SpamSpan however will produce
clickable links if JavaScript is enabled, and will show the email address as
example [at] example [dot] com if the browser does not support
JavaScript or if JavaScript is disabled.


1. Create a directory in your Drupal modules directory (probably
sites/all/modules/) called spamspan and copy all of the module's
files into it.

2. Go to the Modules administration page (admin/modules), and enable the spamspan module (under Input Filters)

3. Go to the Text Formats Configuration page (admin/config/content/formats) and configure the desired input formats to enable the filter.

4. Rearrange the Filter processing order to resolve conflicts with other
filters. NB: To avoid problems, you should at least make sure that the
SpamSpan filter has a higher weighting (greater number) than the line break filter which comes with Drupal ("Convert line breaks into HTML" should come above SpamSpan in the list of Enabled filters). If you use HTML filter ("Limit allowed HTML tags"), you may need to make sure that is one of the allowed tags. Also, URL filter ("Convert URLs into links") must come after SpamSpan.

5. (optional) Set available options under "Filter Settings".

Usage in theme/module

To make use of the functionality in your theme or module one could use;

if (module_exists('spamspan')) {
  print spamspan($elements['#account']->mail);

Looking for support? Visit the forums, or join #drupal-support in IRC.