[Dovecot] dovecot mailbox to csv

Logan Shaw lshaw at emitinc.com
Thu Oct 5 02:18:33 UTC 2006


On Wed, 4 Oct 2006, John Heim wrote:
> We (the Math department at the U of Wisconsin) recently switched over from 
> another server to dovecot
>
> One thing that a lot of people here do is set up an on-line form that sends 
> them email. They use formmail for this. I have them edit their procmail 
> config so that all the messages go into a particular mail folder.... So far 
> so good.
>
> With our old system, all messages in a folder were kept in a single file. 
> With dovecot, they go into a couple of different directories.  This is 
> problematic because we often need to convert the form field data to csv 
> values so it can be imported into a spreadsheet. So a professor can create an 
> on-line form and end up with the data from it in an Excell spreadsheet. Slick 
> (when it works).
>
> I understand that I can make dovecot store messages in a file by leaving the 
> trailing slash off when specifying the folder name. Sample procmail segment:
>
> :0:
> * Subject:.*\[feedback\]
> .feedback
>
> But I can't get the feedback folder to show up in the list of IMAP folders in 
> my mail client. I've tried Outlook Express and Thunderbird. If I put the 
> slash at the end, it creates a .feedback folder and then I can see it in my 
> mail client. But then I can't export it to cvs.

Is it possible it would be better to just process one message at
a time as they arrive and append whatever info to the CSV file
at that time?  The procmail rule would look something like this:

 	:0 c:
 	* Subject:.*\[feedback\]
 	| /path/to/script/which/analyzes/message

That copies the message to the pipe command, so that the
rest of the procmail file continues to apply to the message.
(You might still file them in a folder.)

If you do this, you don't have to worry about the format of the
mailboxes that messages are delivered to, and your processing
can be completely independent of it.

Alternatively, if you'd like to do it all in a batch, the
format you are now using (with each message in a separate
folder) is called "maildir", rather than "mbox".  There are
tools to convert from one to the other.  Or, you can use a
Perl script and use the tools from the Mail-Box distribution of
Perl modules.  These modules can read LOTS of different formats.
See http://search.cpan.org/~markov/Mail-Box-2.068/ .

   - Logan


More information about the dovecot mailing list