Community Documentation

Spam module (4.x, kerneltrap.org)

Last updated June 21, 2009. Created by LeeHunter on April 28, 2006.
Edited by gnassar, keith.smith, Amazon, sillygwailo. Log in to edit this page.

Important note: this documentation is for the Spam module that was at kerneltrap.org, not the module hosted at Drupal.org. Most of that code has been moved over to the current Spam module in its 5.x and 6.x versions.

Set the permissions for administering spam. It's best to let trusted administrators with this, since it potentially involves the automatic deletion of comment and/or Trackbacks.

Configure the Spam Module

  1. click administer » settings » spam
  2. select which content to filter. The list you will depend on what modules are enabled, but will include all content types that are enabled and, if the respective modules are enabled, comments and Trackbacks.
  3. select whether to flag content and comments as spam if URLs that appear in the URL filters setting (see the "Create automatic spam filters based on URLs" section for how to do this)
  4. choose settings for the limits, such as maximum number of URLs, repeat URLs, duplicate content, and how many spam postings before banning the IP.
  5. choose settings for Actions:
  • Unpublish spam means that the "Published" setting for the content is unset automatically. To review spam, click administer » spam » content tab.
  • select whether the user gets notified that their content has been flagged as spam. This help reduce confusion from the user's point of view (i.e. if their comment is not immediately published they will get a reason why).
  • select whether the administrator gets notified of spam content. This setting may cause the administrator to receive many notifications depending on the amount of spam content.
  • choose a setting for the length of time after which the content is "expired" i.e. deleted. There is no way to recover content older than the setting for this, so make sure you review content and comments within that time frame to catch any potential false positives.
  • choose the level of log details you wish to keep. The "everything" setting will slow down your site, but will give you more information if you wish to investigate what's going on. The "major events" combined with a short length of time after which logs are discarded (see next item) are recommended.
  • choose the amount of time after which the logs will get deleted. This will depend on how often you think you'll be checking the logs as well as how far back you want to have information for. The higher the setting the slower your site performance may be.
  • choose whether to display the probability of whether the item (content or comment is spam). Enable this if you want more information in deciding what probability level to choose for the "Match effect" (see step #5 in the "Create Automatic Spam Filters Based on Keywords" section)
  • Marking Individual Comments as Spam

    When reading comments on a post, you may come across something that is clearly spam. If you have the "administer spam" permission, you should see two links beneath each comment: "mark as spam" and "mark as not spam":

    • If you come across one that is definitely a spam, click the "mark as spam" link underneath the comment. That will set the comment to unpublished and will help the spam module "learn" what should be flagged as spam in the future.
    • If something you know is definitely not spam, you can click the "mark as not spam" link. Even thought it's already published, it will help the module correctly determine which comments should not be flagged as spam.

    Bulk Removal of Spam Using Custom Filters

    If you have hundreds or thousands of comments or posts that are clearly spam, use the custom spam filters to quickly flag them all—or almost all of them, as you may need to create some additional filters (see next section)—as spam.

    1. click administer » spam » custom filters tab
    2. click the "scan" link next to each filter.
    3. either click "select all" (which will check every box you see) or individually select which comment you wish to make a change to
    4. choose one of:
    • "Mark the selected comments as spam"
    • "Mark the selected comments as not spam"
    • "Unpublish the selected comments"
    • "Publish the selected comments": for comments that are definitely not spam and that you wish to make public.
    • "Delete the selected comments (no confirmation)": by selecting this option you will not be asked to confirm the deletion. Use with care since there is no 'undo' for this action.
  • click "Update scanned comments"
  • repeat steps 3-5 for each page of comments.
  • Create Automatic Spam Filters Based on Keywords

    If spammers start using words or phrases that the module is not picking up as spam (or if you want to make sure certain words or phrases make content or comments flagged as not spam), you can add custom spam filters to the list of existing ones.

    1. click administer » spam » custom filters tab.
    2. decide whether you're going to use plain text or a regular expression.
      • Plain text is useful when it's just one word or phrase that you want to have flagged as spam.
      • Regular expressions are a little more advanced, and have a different syntax than entering just one word or phrase, but allow you to include checks for the start of words or multiple words.
    3. in the "Custom filter", type in a word if you're using 'plain text', or a regular expression if you choose that option.
    4. choose whether to filter by header (which means either the title content or the subject of a comment) or by the body are scanned for spam. Choosing "everything" means both the header and body get scanned.
    5. select the "Match effect". You can select "always spam" or "never spam", with the settings in between meaning that the chances that they are either are increased but not necessarily absolute.
    6. select whether you wish to disable email notification when the filter matches. This overrides the email setting under administer » settings » spam.
    7. select whether spam automatically deletes as the result of the filter. This is generally not recommended since it's best to periodically review whether the spam module is working correctly.
    8. create automatic spam filters based on URLs
    9. click administer » spam » url filters tab
    10. type in a domain for the URLs that you notice are commonly used in spam. For example, if the URLs you're noticing are http://example.com/pills-for-sale then type in example.com.
    11. click "Add URL filter".

    About this page

    Drupal version
    Drupal 4.5.x or older, Drupal 4.6.x
    Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.