Skip to content

Instantly share code, notes, and snippets.

@thomaswieland
thomaswieland / keybase.md
Created August 4, 2017 11:59
keybase.md

Keybase proof

I hereby claim:

  • I am thomaswieland on github.
  • I am thomaswieland (https://keybase.io/thomaswieland) on keybase.
  • I have a public key ASBN2-lKR3NGl40mlhCOKaMeTuXaufva4fKcfEU6amZjXQo

To claim this, I am signing this object:

@thomaswieland
thomaswieland / gist:3cac92843896040b11c4635f7bf61cfb
Created February 17, 2018 13:56
Python: IMAP IDLE with imaplib2
import imaplib2, time
from threading import *
# This is the threading object that does all the waiting on
# the event
class Idler(object):
def __init__(self, conn):
self.thread = Thread(target=self.idle)
self.M = conn
self.event = Event()
@thomaswieland
thomaswieland / imap_monitor
Created February 17, 2018 14:11 — forked from shimofuri/imap_monitor
Python script for monitoring an IMAP folder
Each existing unread and subsequent new emails after the script is started are
passed as Mail objects to "process_email" function.Function header is provided
but processing implementation is left to the user. Error logs are currently sent
to a rotating log file (in the same directory as the script) and to STDOUT.
Instead of polling or checking the server for new emails every now and then,
IMAP IDLE check is utilized. Ensure that the IMAP server supports IDLE command
and allows at least 5 minutes of idling*** and uses the default ports for this
script to work. Tested to work with Gmail and default installations of MS
Exchange Server.