procmail
[Top] [All Lists]

Re: store mail in separate messages

2009-08-08 00:16:59
On 7-Aug-2009, at 00:08, Rossen Karpuzov wrote:
I have big mail in my mail box and I want to receive every new e- mail in maildir with separated messages for fast listing. Now every time the process reading for new messages cost 10-15 minutes.

Assuming you want to CONVERT an existing mbox file to maildir it is very simple to do

First, make the new maildir folder

Just throw the existing mail at procmail

$ formail -s procmail -m DEFAULT=$HOME/Maildir/.myoldmail/ /dev/null < oldmboxfile

All the mail in oldmailbox file will now be in the maildir 'myoldmail'

Make sure that all your procmailrc recipes now declare the delivery to be a maildir (end in a /) and you're set to go.

You can also do it via mutt very easily, if you already have mutt and are familiar with it.


[ YOU CAN IGNORE THE REST OF THIS EMAIL ]
[ YOU CAN IGNORE THE REST OF THIS EMAIL ]
[ YOU CAN IGNORE THE REST OF THIS EMAIL ]


This is simple, and it works... but. The mail received time-stamp [But not the mail-sent timestamp] will be wrong for courier (and others?) since it gets its time stamp from the timestamp on the file created. Normally this makes a great deal of sense, but in this case it's not so good.There are two ways to go, the better way is to extract the date from the From_ header, what I would do (trusting my system more than the sender's) was extract from the received header for my mailserver.


WEEKDAYS = '(S(un|at)|Mon|T(ue|hu)|Wed|Fri)'
MONTHS = '(J(an|u[ln])|Feb|Ma[ry]|A(pr|ug)|Sep|Oct|Nov|Dec)'
WHICHRECVD = 'by [^     ]*(mail.)?covisp.net'
YEARS = '(199[0-9]|20[0-9][0-9])'
TIMESTAMP = '([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]'
#RCVD_STAMP = "$WEEKDAYS, [0-9]+ $MONTHS $YEARS $TIMESTAMP"
RCVD_STAMP = "[0-9]+ $MONTHS $YEARS $TIMESTAMP"

:0
* $ ^Received:.*$WHICHRECVD.*\/$RCVD_STAMP
{ xDATE = "$MATCH" }

UTIME=`date --date="${xDATE}" +%s`

This gives you the unix epoch time, which is the filename of the stored mail. in my case the complete filename is

{epoch seconds}.{random 4 chars}_0(_at_)${hostname}

If you care about the mail-received timestamp, this is a laborious process. if you can live with having correct date-sent timestamp in all your own mail, it's that aforementioned one line formail command.

I had to go through rather more hoops as my date command does not support --date and it's -f is... archaic. It is probably worth installing GNU date if you want to do this. In fact, it's probably worth installing GNU date anyway.


--
A ship should not ride on a single anchor,
nor life on a single hope

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>