OT: procmail/formail magic (was: Re: [Evolution] Outlook PST Equivalent)




'formail' is one of the great tools that can ease automatic archiving.

I'm a fan of "formail" for munging local mboxes (it should be more
widely known) but it's not a lot of use for moving stuff around on an
IMAP server.

Granted, true. But using formail to split mbox files you can use any
script to move mails one by one, for example based on the received date
for archiving purposes.

procmail is the tool, that can do about anything regarding moving stuff
around on your IMAP server. :)

Actually, to correct myself: This is in no way limited to an IMAP
server.


How so?  I thought it only acted as an MTA filter.

Well, please see 'man procmail' for details, but in short, procmail can
take an rc file as argument and can be called as a filter manually.

With a "specially crafted" [1] rc file you can process any "single mail"
input just as it actually was called by your MTA as delivery agent. I
used this in the past some time, to re-process SPAM and Virus archives
to re-classify the mails. That way you can store the mails in different
mbox files in the current directory, for example, based on the procmail
receipts.

A simple ;) command like this will feed the contents of large.mbox to
formail, which splits it up into single mails and calls procmail to
actually sort (well, process) the mails according to the
local-procmail.rc receipts:

$ cat large.mbox | formail -s procmail ./local-procmail.rc

As action lines (in the procmail receipts) just use simple files and be
sure to have any kind of default receipt at the end, to not (re-)feed it
to your systems Inbox. [2]

Hope this is helpful...

...guenther


[1] Actually it's the same as usual, it just needs to fit the purpose.

[2] You likely want to test this first in aclean environment which can
    not clutter your systems Inbox. Really, believe me... ;-)


-- 
char *t="\10pse\0r\0dtu\0  ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]