Question

The common ethicete about mailing lists is to answer to a human, and CC the mailing list, like this:

To: help-volounter@dev.full
Cc: some-program@mailing-list.com
Subject: Re: Describtion of the problem

Problem is that I get two copies of such email(it's expected). I would like to procmail one copy to mailing list mbox, and another to inbox mbox. Is it simple way to do it?

Was it helpful?

Solution

It's not entirely trivial, but there are some building blocks you may find useful.

You can detect whether you have already received a message by keeping a cache of seen message-id:s. This is a standard technique described in the procmailex man page in more detail. I would propose to use the same technique to decide where to file an incoming message; if it has not been seen before, deliver to your inbox; otherwise, file to the list's folder.

The locking becomes somewhat more complex because you need to obtain the lock file before entering the formail -D recipe. This can be done by using the LOCKFILE special variable.

# Is this message addressed both to yourself and to the list?
:0
* ^TO_you@example\.net\>
* ^TO_mailing-list@elsewhere\.example\.org\>
{
    # Select regular inbox as default target for this message
    dest=$DEFAULT

    # Lock msgid.lock for exclusive access to msgid.cache
    LOCKFILE=msgid.lock

    # If message-id is already cached, override $dest
    :0
    * H ? formail -D 8192 msgid.cache
    { dest=listbox/ }

    # Release lock
    LOCKFILE=

    # Deliver to $dest
    :0
    $dest
}

This is not 100% foolproof. If you get a Bcc:, for example, your own address will not be in the headers, and so ^TO_ yourself will not match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top