Slightly OT. Good IMAP search tool?

Howdy Folks,

What are people using these days to suck down an IMAP account, search it and
then export the search results? Any suggestions.

Cheers,
Mike

I don't know your specific need, but it is usually far more efficient (to
what degree depends on the IMAP server) to perform your searches via the
IMAP SEARCH command and let the server feed you the appropriate emails
containing the keyword(s) you're searching for.

* Am Sat, Feb 20, 2010 at 11:56:19AM -0800 , schrieb Mike Lyon:

Howdy Folks,

What are people using these days to suck down an IMAP account, search it and
then export the search results? Any suggestions.

If you really need to suck everything down, i'd suggest
offlineimap+maildir-utils

Cheers,
  Christoph

Well, I don't have to exactly suck everything down. if I I could use the
imap search function as one post previously mentioned, that would work to.

Just trying to find a good utility to do it...Win/Linux, doesn't matter...

Thanks,
Mike

IMAP Webmail clients (like squirrelmail) have build in server side
searching. Many IMAP clients do as well.

The Perl imap module should be verify flexible in performing the search and
letting you manipulate the results programmatically.

You could also do it via telnet/nc and script the search and fetch commands
via shell script. See RFC 3501.

I'd replied off-list, but then realized that perhaps this would be of
more general interest. My apologies to Mike for the redundancy.

I use fetchmail and grepmail. Grepmail emits as its output a Unix mbox
file, so it lends itself quite nicely to going through chunks of saved mail,
matching grep-ish criteria (including headers) and producing a file full
of the messages that match.

Let me also mention formail, which is part of the procmail distribution,
and is also quite useful -- in this particular case, for culling duplicates.
All three of these tools are part of my standard postmaster toolbox.

---Rsk

hm..If you really want to snarf the imap, think fetchmail for
downloading. hypermail/pipermail for parsing. Get it into a DBM
(such as PgSQL) and perform full-text indexing. Or coax Hypermail into
generating HTML flat files....

Then your full-text search problem is reduced to finding the right
.html files out of the massive number of files. If you want to
search binary attachment contents, that's harder.

Sounds like a job for a recursive 'grep' at that point. Or post
(non-sensitive) output to a web site, wait for Google to index. Or
(heck) use Google Desktop :slight_smile:
Else use a private web site ht://Dig. some other tools are
(supposedly): Apache Nutsch, Sphinx, mnoGoSearch, SWISH-E.

Well, I don't have to exactly suck everything down. if I I could use the
imap search function as one post previously mentioned, that would work to.
Just trying to find a good utility to do it...Win/Linux, doesn't matter...

How about telnet + openssl, and perhaps an expect script?

# openssl s_client -connect mail.example.com:143 -starttls imap
or

# openssl s_client -connect mail.example.com:993
a1 LOGIN myusername mypassword
a1 LIST "/" "*"

yawn SELECT INBOX
a2 SEARCH SUBJECT "hello"
a3 SEARCH SUBJECT "test" SEEN
a4 SEARCH ANSWERED
a5 SEARCH TEXT "xs-" BODY "cron" SINCE "20-Oct-2009 00:00:00 -0500"
FROM "root@" TO "root" UNDELETED

a FETCH 1012 FLAGS
b FETCH 1012 full
c FETCH 1012 BODY
c FETCH 1012 BODY[text]
blah LOGOUT

Have you figured out how to get grepmail to decode MIME? A mailing
list I'm on recently started emitting MIME/base64 encoded inline text.

Check out mairix: http://www.rpcurnow.force9.co.uk/mairix/

"""
mairix is a program for indexing and searching email messages stored in
maildir, MH or mbox folders.
"""