So after 15 minutes trying to understand how Mail.app stores the IMAP messages locally (it stores them in a mh folder, at least similar enough for mairix), I did a small
.mairixc, set the output as mbox into a newly created folder, and pointed mairix to a incoming IMAP folder.
Run it once without parameters to index all the stuff, and run it again with a string to query the database.
Matched 82 messages
Whoa! Already? :) Jump back into Mail.app, look at the folder created and lo and behold, they where there.
So, the steps you need to take (this is a beta how-to, ok? the steps will get better):
- Download and install mairix: it compiles cleanly in my Mac, but the install failed for some reason, just copy the binary to someplace in your $PATH;
- Create a
Resultsfolder on you Local Mac. It must be created in the Local Mac.
- Use my modified
.mairixrcand adjust the following variables:
base: the base where all your Mail.app info is stored, usually
- Comment all the lines starting with
mhshould be the path of one of your folders in a IMAP account, something like
IMAP-**name_of_account**/INBOX/Sent.imapmbox/CachedMessages. One way to find this out is to run this command (
find ~/Library/Mail -type d -name CachedMessages) from the terminal. You can put as many lines as you want;
mfoldershould be changed to point to your results folder that you created above. If the name is
mfoldershould point to
- Remove the comment in the
mformat=mboxline: this specifies the result folder as a mbox-style folder;
databaseto a place in your home directory: mine is
mairixonce. It indexes all the folders you specified in step 3;
- now query the created database:
mairix some_string- it should display the number of messages found. Jump back into Mail.app, check the Results folder and they should be in there.
Don’t forget to run
mairix from time to time to update the database. Use Cronix or edit a crontab maybe.
Next steps: I only indexed one folder as you can see from the example
.mairixrc. I need to write a small perl script to generate my
.mairixrc file with all my mailboxes, and do a AppleScript to call the mairix command with the query.