1

I am working at a place where e-mails are sent to multiple groups very often, which means that e-mails will be filtered into random directories, even in mid-thread if a new group is added to the thread. I would like to see every e-mail in every group folder where it was sent, which means more disk space used, but disk space is cheap. For this there is the "c" flag, but the problem is that if put a "c" to every rule, i will have every e-mail in the appropriate folder, and in the inbox at the end. So i would like to have a last rule which could recognize if this e-mail was already recognized/filtered into some folder, and if not, let it through to the inbox. I tried to use "test -z $LASTFOLDER, which seemed to work except that with this procmail returned a failure to fetchmail, which in turn was not deleting my e-mails from the imap server and mess happened. Whats the proper way of doing this? Should i use something else for mailfiltering? Was i able to write down clearly enough what i want?

2

You can do something like this for all rules that sort messages to list folders:

:0
* ^List-Id:...
{
    :0 c:
    somefolder

    :0 fw
    | formail -a X-Chad-Loop: Chad was here
}

Then just before the end:

:0
* ^X-Chad-Loop:\ Chad\ was\ here
{
    :0
    /dev/null

    HOST
}

I think this will also log the delivery to /dev/null. If you don't like that you'll have to play with LOGABSTRACT.

On a side note: beware that procmail has been unmaintained for a long time, and it has well-known security issues. Even some of its old time developers recommend switching to something else nowadays. For what its worth, my personal preference is fdm, which has a much better security record.

1

The LASTFOLDER idea is completely fine; you just need to make sure you don't end up signaling failure to the invoking process. You are not showing your code, but something like the following should work fine.

:0
* LASTFOLDER ?? .
/dev/null

The variable ?? regex syntax is Procmail's built-in facility for examining a variable. The single dot will match any value at all except the empty string (or, technically, a string containing only newlines).

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.