How do I enable push-notification for IMAP (Gmail) using Python imaplib?

后端 未结 4 1529
甜味超标
甜味超标 2021-01-30 11:35

Is there a way to monitor a gmail account using imaplib without polling gmail each time I want to see if there is new mail. Or in other words, I just want the script to be notif

4条回答
  •  难免孤独
    2021-01-30 11:55

    There is simple patch proposed at bugs.python.org implementing RFC 2177 IMAP IDLE command in a synchronous way ( to wait for more than 1 IMAP server you have to use threads or other means of parallel execution ). It uses stdlib select to wait on socket including timeout. This patch will eventually be added to stdlib, but tests have to be written first. The IDLE command is what you need for gmail IMAP push-notification. Hope, this will help :)

提交回复
热议问题