You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

How do I use SpamAssassin with procmail?

Edit or create a .procmailrc file in your home directory containing the below lines. If you already have a .procmailrc file, add the lines to your .procmailrc file:

:0fw:spamassassin.lock
* < 256000
| spamassassin

:0e
{
  EXITCODE=$?
}

:0:
* ^X-Spam-Flag: Yes
caughtspam

The first stanza filters all incoming mail through SpamAssassin and tags probable spam with a unique header. This rule will use a lock file (spamassassin.lock); this is a good idea if there will be more than one instance of SpamAssassin working on a message. The next stanza protects against errors. If spamassassin returns an error, it is passed back to the mail transfer agent; this improves robustness of mail delivery.

Most people prefer to have spam blocked and saved to a file in their mail directory. The next stanza instructs procmail to save any tagged messages to a "caughtspam" folder in your procmail MAILDIR directory.

For a more complicated example see the procmailrc.example file in the distribution:

http://spamassassin.org/dist/procmailrc.example

The spamc client program can be used instead of spamassassin, if you intend to install and use the spamd server system-wide.

Read 'man procmailrc' and 'man procmailex' for futher details and explanation.

  • No labels