How to Make SpamAssassin Mark Spam in the Subject

Change this one setting to customize the Subject of every spam email

Cans of SPAM
Justin Sullivan / Getty Images

SpamAssassin includes a file called that can be edited to show a particular word or phrase in the Subject line of any email marked as spam.

It's a good idea to have a glaring word or phrase stamped on spam messages to make sure you don't open file attachments in those emails, which could end up being malware. It's also useful for easily identifying which emails you should delete, or at least watch out for.

Another smart use of this setting is so that all spam messages will look identical in the Subject so that you can set up your email client to auto-delete spam based on Subject filters.

How to Make SpamAssassin Mark Spam in the Subject

Carefully follow these steps to customize SpamAssassin to put anything you want into the Subject of spam emails:

  1. With a text editor, open the file from the SpamAssassin installation folder. Depending on your version, it might be in /rules/ or /etc/mail/spamassassin/.

    Note: Not sure what text editor to use? See our Best Free Text Editors list for our favorites.
  2. Locate the rewrite_header Subject *****SPAM***** line in the file.

    Note: If you don't see this line, you're using an older version of SpamAssassin. Read the tip at the bottom of this page.
  3. Change *****SPAM***** to be however you want the Subject line to read for spam messages. Be sure to keep the rewrite_header Subject text unchanged.

    Here's one example of what you could do: rewrite_header Subject DELETE IMMEDIATELY.
  1. Just to the left of this line is a # symbol. Delete it so that the word "rewrite" is butted up against the left margin. Doing this will remove the comment (#) and actually enable the new spam setting.
  2. Save and exit the file.


Here are some things to keep in mind when making this change to SpamAssassin's settings:

  • If you don't see the rewrite-header line, it means that the version of SpamAsssassin you're using is not the most recent version. As you can read here, older versions use rewrite_subject 1 subject_tag instead. If your file uses that syntax, add rewrite_subject 1 to it. If your SpamAssassin preferences file already has rewrite_subject 0, just change it to include the "1" instead.

    Since your personal SpamAssassin configuration file (~/.spamassassin/user_prefs/) overrides all settings in, make sure "rewrite_subject" either is not in your personal configuration file or is set to "1", too.
  • Don't forget to remove *****SPAM***** or your custom Subject text from the email if you end up replying to the spam message. 
Was this page helpful?