ikvk / imap_tools

Work with email by IMAP
Apache License 2.0
717 stars 83 forks source link

Receiving and forwarding #17

Closed cboden closed 4 years ago

cboden commented 4 years ago

Thanks for this awesome library. I have a couple usage questions:

  1. Is there a way to enter IDLE mode? I'd like to have a script that is constantly running and act upon any incoming emails.

  2. What's the best way I can forward an email? I'm not too familiar with the various email protocols, I'm guessing this is outside the scope of IMAP, but I was wondering if you could point me in the right direction?

ikvk commented 4 years ago

Hi, Chris.

  1. There is point in todo project file - "try to imitate long poll by noop"

rfc3501 NOOP Command: ... Since any command can return a status update as untagged data, the NOOP command can be used as a periodic poll for new messages or message status updates during a period of inactivity (this is the preferred method to do this). The NOOP command can also be used to reset any inactivity autologout timer on the server.

IDLE command from rfc2177 maybe useful here too.

At this point, I haven't tried to implement any of the methods. It is necessary to carefully study the commands and come up with an implementation with a simple interface and clear code. I think its a really big work. I am ready to consider proposals, if there are any.

For a large number of tasks, it is usually enough to read the mailbox periodically. Plus, this approach is much easier to implement and maintain. Although I do not argue that longpoll feature is good.

  1. As you mentioned, Forward an email is outside the scope of IMAP.

Here is a case from my email forward practice: Create special "central" email mailbox on email server. Then specify rules for it on server - to forward to several email boxes.

Sirri69 commented 3 years ago

Hey @ikvk is there any update/way to issue NOOP command ?? I have to reconnect to my mailbox again and again to get new mails ☹.

ikvk commented 3 years ago

@Sirri69, BaseMailBox.box - imaplib.IMAP4/IMAP4_SSL client instance.

ikvk commented 2 years ago

IDLE implemented: https://github.com/ikvk/imap_tools/releases/tag/v0.51.0