The crux is that Procmail doesn't fail if you don't explicitly make it fail. Its default behavior, like you noted, is to fail the current recipe, and then eventually deliver to $DEFAULT
as a fallback if no delivering recipe was successfully executed.
I don't think this is obviously fixable, but I can come up with a hacky workaround; configure it so that $DEFAULT
points to a location where mail cannot be delivered; then you should get an error when it falls off the end of the user's .procmailrc
Actually, if you override $DEFAULT
with an unwritable location, Procmail will repeatedly try to deliver, fail, and retry. Eventually it seems to fall back to $ORGMAIL
(the "default $DEFAULT
") in my quick and dirty experiment.
I suppose you could also think about wrapping it somehow, maybe explicitly includerc=$HOME/.procmailrc
in /etc/procmailrc
and then fail if it returns without having delivered.
The following /etc/procmailrc
is really hacky.
It actually ends up running the user's .procmailrc
twice; it assumes that if the first one didn't deliver anything, the second invocation won't, either. I could not find a way to prevent it from executing the user's .procmailrc
again; but maybe there is a way.
# ... your regular /etc/procmailrc contents here
# Drop root privileges
DROPPRIVS=yes
# Run user's recipes
INCLUDERC=$HOME/.procmailrc
# Don't deliver to DEFAULT any longer
DEFAULT=/dev/null
# Set exit code to an error code (check your local manual for what makes sense for your MTA)
EXITCODE=77
# Force quit
HOST=
Sendmail (and I think Postfix) use exit codes from sysexits.h; Qmail (if somebody is still using that) allegedly has its own conventions.
By the by, the c
flag on your testing recipe seems misdirected (:0wc
); the c
flag says to clone the message, and effectively generate two of them. Since your recipe will always fail, I guess you are then immediately discarding the one you just created; but anyway, the w
flag should be sufficient here.