Menu

dbacl with MAILDIR folders?

2006-11-15
2013-04-15
  • Michel Albert

    Michel Albert - 2006-11-15

    I am aware, that dbacl allows you to classify mails. It states in the docs that it works "best" with MBOX mail folders. What I wanted to know, is it also possible to do this when having the mails stored in MAILDIR folders?

    What I find kind of strange when inspecting my current mails, is that they all reside in one single folder, and that there is one file which only lists the folders. I know this has more to do with the way how courier-imap works but still... ;)

    Is there any way to get dbacl to work sensibly with such a configuration?

    Best Regards,

    Mich.

     
    • Laird Breyer

      Laird Breyer - 2006-11-15

      Hi Mich,

      A MAILDIR folder is just a plain directory containing three subdirectories
      called new, cur and tmp. Each of those directories contains lots of files
      with unique names, and each file is a single email message. The new directory
      contains new (unread) messages, then those messages are moved to cur after
      they have been read, and tmp can contain incomplete messages etc.

      When you run a command such as

      dbacl -T email ... -l catname file1 file2 file3 ...

      you can let fileX be either an MBOX file or a directory. In the second case,
      dbacl will read all the files which exist inside that directory (but not
      subdirectories, they must each be given separately). So you can
      let file1=/path/to/maildir/cur for example, etc.

      dbacl reads EVERYTHING in the directory, even non emails, but it only
      starts learning (with the -T email switch) if the file looks like an email
      (a header, a blank line, a body). Typically, there might be an index
      file in cur, which won't look like an email at all and will
      effectively be skipped.  You can see what is being learned by using
      the -D or -d switches.

      If you only want to learn a subset of all the files in a directory,
      you should copy those to another directory, or you can build a
      temporary MBOX archive etc. An MBOX archive is just a big file where
      all messages are separated by a blank line and the string "From ". It
      can be build using formail.

      For example, the following (bash) shell command creates a file called
      imp containing all the messages containing the word "important",
      without modifying the maildir.

      grep -i -l important /maildir/cur/* | while read f; do formail <$f; done > imp

      Best regards,
      Laird Breyer.

       

Log in to post a comment.