in reply to Looking for a perl webmail

You might have a look at Mail::Box and the Mail::Box-Overview. Apparently this collection of modules can deal with both local mail as well as mail over a network, although I have no idea if IMAP support is included in this. You might have a look at the Mail::Box website.

This is a level or three below a turnkey webmail solution, but does seem to provide an extensive object interface to folders, individual messages and attachments. See Simon Cozen's article The Evolution of Perl Email Handling for more on Mail::Box.