I sent an IMAP interface proposal to the issues list. As of now, there is a dal module modification available that allows connecting to an IMAP (i.e. Gmail) server, auto create tables and query for mailbox messages with the web2py query syntax.
It is possible to construct queries using ==, !=, >, <=, belongs,
contains, ...
This web2py command returns rows that contain a string within the
subject text
rows = imapdb(imapdb.INBOX.subject.contains("mytext")).select()
I will appreciate your comments.

