procmail
[Top] [All Lists]

Re: bulk redelivery

1996-10-31 13:39:40
    > All of the non-delivered mail accumulated in one huge folder.
    > Can one of you help me set up a redelivery pipe?
    > 
    > My first guess:
    > 
    >   cat big-undelivered-mail | formail -ds procmail
    > 
    > Is this close?  Anyone have a better idea?

Here's a command which I've used to refile customer's email
based on the same prefiling recipes, but not delivering the
mail afterwards.

    % formail -ds procmail -m refile.rc <big-undelivered-mail

The recipe file "refile.rc" should have a duplicate check and the same
set of filing recipes as would be used in the ~/.procmailrc.

If you use a "duplicate check" recipe routinely, then use the same
"Message-Id:" cache file.  Otherwise, you will have to "prime" then
cache file with the "Message-Id:" headers from the existing, 
filed mail.

A /bin/csh ommand to "prime" the Message-Id: cache might be:

    lockfile .msgid.cache.lock
    foreach f ( folder1 folder2 folder3 ... folderN )
        formail -ds formail -D 16384 .msgid.cache
    end
    rm -f .msgid.cache.lock
    
This command will capture the Message-Id: headers from all the
mails stored in the named folders.  If the folders are MH-style,
then a different syntax would be required:

    lockfile .msgid.cache.lock
    foreach f ( folder1 folder2 folder ... folderN )
        mhpath +$folder | \
                xargs -i% ls -1 %/. | \
                xargs -i% sh -c 'formail -D 16384 .msgid.cache <%'
    end
    rm -f .msgid.cache.lock

Now that the cache is primed, here's a sample script of "refile.rc";
you may (will) have to edit to suit the conventions of your site and
particular usage.

    MAILDIR=$HOME/Mail          # or wherever your scripts live
    LOG=$MAILDIR/refile.log     # keep a log of these refiles
    COMSAT=off                  # keep comsat/biff away

    # Remove duplicate messages
    :0 Wh: .msgid.lock
    | formail -D 16384 .msgid.cache

    :0
    * ? test -r prefile.rc
    { INCLUDERC=prefile.rc }

The file "prefile.rc" is the set of recipes which do the normal
pre-filing of incoming email.  By placing them in a file, it can be
shared between .procmailrc and this recipe file "refile.rc".

The reason why you wouldn't want to just invoke "procmail" with the
default .procmailrc is that it may have rules based on the assumption
that the mail is to be delivered *after* any prefiling takes place.
The "refile.rc", on the other hand, will drop any mail which doesn't
get delivered -- which is okay since the mail is already sitting in a
folder.

Hope this helps.

___________________________________________________________
Alan Stebbens <aks(_at_)sgi(_dot_)com>      http://reality.sgi.com/aks

<Prev in Thread] Current Thread [Next in Thread>
  • bulk redelivery, Gary Casterline
    • Re: bulk redelivery, Alan K. Stebbens <=