[Twisted-Python] IMAP4 Proxy to add headers and modify body of an incoming message
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
Hello, 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?
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
Maybe I asked the wrong question? Is it possible to use the imap4 library from twisted to write an imap4 proxy? ________________________________ From: Krzysztof Oblucki <koblucki@yahoo.com> To: "twisted-python@twistedmatrix.com" <twisted-python@twistedmatrix.com> Sent: Monday, November 25, 2013 11:27 AM Subject: IMAP4 Proxy to add headers and modify body of an incoming message Hello, 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?
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
Awesome, that's what I've been trying to do for the past couple of days. Definitely learning a lot of new things :) ________________________________ From: "exarkun@twistedmatrix.com" <exarkun@twistedmatrix.com> To: Twisted general discussion <twisted-python@twistedmatrix.com> Sent: Wednesday, November 27, 2013 5:18 PM Subject: Re: [Twisted-Python] IMAP4 Proxy to add headers and modify body of an incoming message
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Nov 27, 2013, at 6:39 PM, Krzysztof Oblucki <koblucki@yahoo.com> wrote:
Perhaps you should file a ticket for this? (Searching for one first, of course, to see if it already exists). Thanks, -glyph
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Nov 28, 2013, at 12:10 PM, Krzysztof Oblucki <koblucki@yahoo.com> wrote:
I will do that. I'm struggling with doing this myself so far because of my noobness but making small progress every day.
Feel free to ask here for any help you might need :). -glyph
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
Maybe I asked the wrong question? Is it possible to use the imap4 library from twisted to write an imap4 proxy? ________________________________ From: Krzysztof Oblucki <koblucki@yahoo.com> To: "twisted-python@twistedmatrix.com" <twisted-python@twistedmatrix.com> Sent: Monday, November 25, 2013 11:27 AM Subject: IMAP4 Proxy to add headers and modify body of an incoming message Hello, 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?
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
Awesome, that's what I've been trying to do for the past couple of days. Definitely learning a lot of new things :) ________________________________ From: "exarkun@twistedmatrix.com" <exarkun@twistedmatrix.com> To: Twisted general discussion <twisted-python@twistedmatrix.com> Sent: Wednesday, November 27, 2013 5:18 PM Subject: Re: [Twisted-Python] IMAP4 Proxy to add headers and modify body of an incoming message
Sounds like you diagnosed the problem correctly. IMAP4Server needs to handle Deferreds here and doesn't currently. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Nov 27, 2013, at 6:39 PM, Krzysztof Oblucki <koblucki@yahoo.com> wrote:
Perhaps you should file a ticket for this? (Searching for one first, of course, to see if it already exists). Thanks, -glyph
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Nov 28, 2013, at 12:10 PM, Krzysztof Oblucki <koblucki@yahoo.com> wrote:
I will do that. I'm struggling with doing this myself so far because of my noobness but making small progress every day.
Feel free to ask here for any help you might need :). -glyph
![](https://secure.gravatar.com/avatar/7303898a54770bd70c4258fbd10608c7.jpg?s=120&d=mm&r=g)
It would be great if I could get some pointers as to the correct way of doing it. If I were to start with search_DELETED what would be your recommendation? Sent from my BatPhone
participants (3)
-
exarkun@twistedmatrix.com
-
Glyph
-
Krzysztof Oblucki