Spam, actions for mutt

It is possible in mutt to delete or view all messages that exceed a certain spam score. This can be done by entering the following command from within mutt's index:

D~h ^X-Spam-Score:\ .*[(][*]{5}

This will mark for deletion (D) all messages with a header (~h) that starts (^) with X-Spam-Score: (X-Spam-Score:) , followed by a space, some other characters and a left parenthesis (\ .*[(]) and finally five or more stars ([*]{5,}).

These messages can then be purged by entering


Making a macro for this pattern

This command is of course hard to type, so therefore it is easiest to define a command in ~/.muttrc:

   macro index \CA '<delete-pattern>~h ^^X-Spam-Score:\ .*[(][*]{5}

This defines a macro that will be run when Control-A (\CA) is pressed in the index. Some extra escapes are added because mutt interprets special characters in its configuration file differently.

Instead of the <delete-pattern> command, it is also possible to use <tag-pattern> so that all spam is tagged instead of deleted. Deleting all tagged messages is then done by typing ;d.

Limit messages to a certain spam score

It is also possible to limit the index to deleted messages (limit to ~Deleted)


or to limit the index to tagged messages (limit to ~Tagged)


When run just after the macro above, this shows only the messages deleted or tagged as spam, so that a cursory review is made easier. To undelete messages use U, to untag messages use t.

To return to the default index view of all messages, enter


where . is the "pattern" for all. Alternatively the "patterns" ~A and all work as well.

Contact us | Webmaster

Questions? Mail to