1

I'm a newbie trying to work out the following mail solution on a laptop where I'm the only user:

getmail - spamassassin - procmail - mu4e (an emacs mail program)

Right now I'm succeeding at

getmail                -            mu4e

With my former mail program (emacs gnus) I was successfully implementing spamassassin as spamd daemon.

I think I understand how to tell getmail to filter mail through spamassassin and send it on to procmail. How should I write my .procmailrc file to send spamassassin-processed mail on to its final "spam" or "not-spam" destination in my email program?

AnFi
  • 886
  • 4
  • 10

1 Answers1

2

I would suggest using fetchmail (with mda option) instead of getmail.

getmail configuration: ~/.getmail/getmailrc - deliver via procmail

To deliver with an external MDA:

[destination]
type = MultiDestination
destinations = ("[procmail-as-bob]", )

[procmail-as-bob]
type = MDA_external
path = /path/to/procmail
arguments = ('~bob/.procmailrc', '-f', '%(sender)')
user = bob

procmail configuration with spamassassin/spamc: ~/.procmailrc

# default/fallback delivery destination
DEFAULT=Maildir/

# rewrite message using spamassassin or spamc
# :spamassassin.lock lock is not necessary for spamc 
# (it makes some sense for spamassassin)
:0fw: spamassassin.lock
* < 256000
| spamc

# Mails with a score of 15 or higher are almost certainly spam (with 0.05%
# false positives according to rules/STATISTICS.txt). Let's put them in a
# different mailbox. (This one is optional.)
# locking (trailing : ) is not necessary for deliveries to maildir 
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Maildir/almost-certainly-spam/

# All mail tagged as spam (eg. with a score higher than the set threshold)
# is moved to "probably-spam".
# locking (trailing : ) is not necessary for deliveries to maildir
:0:
* ^X-Spam-Status: Yes
Maildir/probably-spam/
AnFi
  • 886
  • 4
  • 10
  • Note that `\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*` can be rewritten as `\*{15,}` to better emphasize the numerical score value. – user Aug 14 '15 at 08:30
  • @MichaelKjörling No, Procmail does not support the `{m,n}` repetition operator found in e.g. `egrep`. – tripleee Aug 14 '15 at 10:22
  • What's with the `spamassassin.lock` file? I know what it does, and I have frequently seen it copy/pasted in this particular recipe construct, but I have never seen a satisfying explanation of why you would want to prevent multiple simultaneous invocations of `spamc`. Indeed, the point of `spamc`/`spamd` is to allow for multiple parallel invocations. – tripleee Aug 14 '15 at 10:24
  • @tripleee `:spamassassin.lock` makes more sense with spamassassin used in original recipe. – AnFi Aug 14 '15 at 10:51
  • @tripleee Hm? I was sure I had used that one myself in a procmail recipe, but turns out not. Maybe you're right. Apologies then. – user Aug 14 '15 at 11:11
  • Not sure what you mean by "original" (using `spamassassin` instead of `spamc` I guess?) but my suggestion would be to edit the answer to remove the superfluous lock. – tripleee Aug 14 '15 at 11:29
  • 1
    @StevenArntson It may be extended to execute procmail with per external email account rc file **OR** pass external account name to `~/.procmailrc`. – AnFi Aug 14 '15 at 17:35
  • One followup question: I see that spams go to `/probably-spam` and `/almost-certainly-spam` but where do the rest of the mails (the "hams") go? Is it to `~/Maildir` by default? – Steven Arntson Aug 14 '15 at 18:40
  • First recipe rewrites "not too big" messages. Second and third recipe conduct "final delivery" for some messages. Messages not "finally delivered" by any rule end in `$DEFAULT` location - I have redefined it at the very begin of rc file. – AnFi Aug 14 '15 at 19:20