0

I have Postfix installed and configured to pass mail to Procmail. I have Procmail configured to pass the email to a Python script. I also notice that Procmail is placing a copy of the same email into a file at /var/spool/mail/<username>. I don't want a copy of the message to be retained there or anywhere on the server. Is there a way to configure Procmail to drop the message after it is sent to the Python script?

In my .procmailrc configured like so:

:0Wc:
| env python3 /home/user/python/script.py
:0
* ^From:.*@.*
/dev/null

This however does not work. The message still ends up /var/spool/mail/<username>.

1
  • Your second recipe should certainly have delivered to /dev/null regardless of the outcome of the first. If it didn't, there is an error somewhere, but without seeing Procmail's log file, it's impossible to say more. Perhaps see also iki.fi/era/mail/procmail-debug.html – tripleee Feb 10 at 7:23
2

This is exactly how Procmail operates out of the box. Recipes are executed sequentially until a delivering action is taken, or until we run out of recipes, and deliver to $DEFAULT. Writing to a mailbox, piping to a command, or forwarding to a different recipient are all delivering actions.

However, your first recipe has a c flag, which explicitly disables this behavior, and causes another delivery to be attempted even after this action completes.

In so many words, take out the c flag (and probably the second colon, too; or name an explicit lock file after it).

The old (not so) mini-FAQ has a section about locking which coincidentally also has a passage about your main question, and a discussion of "deliveredness".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.