Maybe I asked the wrong question?  Is it possible to use the imap4 library from twisted to write an imap4 proxy?

From: Krzysztof Oblucki <>
To: "" <>
Sent: Monday, November 25, 2013 11:27 AM
Subject: IMAP4 Proxy to add headers and modify body of an incoming message

I am trying to write an IMAP proxy to modify headers and the body of an incoming message using twisted.  I am new to python and twisted so maybe this is why I either picked the wrong route or don't have the skills to get through some issues and I'm hoping that some you fine list members can point me in the right direction.

I started by using the IMAP4Client and IMAP4Server to do the proxying.  However, I realized that in certain cases, the IMAP4Server requires synchronous results but since I need to do an async call using the client the handling is not working properly.  I ran into this when implementing getFlags() in the IMessage and I am not sure how I can get out of this short of changing the IMAP4Server code to handle Deferreds.

Am I on the right track?  Is imap4 lib the right tool for this job?  If so, is modifying IMAP4Server to handle Deferreds the right thing to do?  If not, what would you recommend?