Reputation: 1764
I have managed to link a gmail account up with offlineimap and mutt. I have a script that runs and I want to read and check my new emails. Is there a way for me to do something like cat /path/to/mutt/emails | grep "text search"?
Upvotes: 0
Views: 794
Reputation: 19119
Provided you are using the Maildir format to store the mail locally, your email will be stored one email per file. You cannot do a simple cat in this case. You would need to find the email files first, using for example find
. The Maildir format also defines to folders cur and new, so you could do something like this:
find <path-to-your-maildir>/new -type f | xargs grep "text search"
That might be helpful, when doing some low level scripts or when debugging the mail setup. However, I am also wondering why you would do it this way. Mutt has a very powerful search and tag syntax (much better than anything provided by a GUI mail client) - http://www.mutt.org/doc/devel/manual.html#patterns. Searches in email bodies can slow things down of course, depending of the size of your mailbox. For these cases there are external tools which can be integrated into mutt and fulltext index your emails, so that searches within the email bodies are much faster. Personally I am using mu, but there are alternatives - http://dev.mutt.org/trac/wiki/UseCases/SearchingMail
Upvotes: 1