From 7266da779de14349a2edb0a60594115006f8fee9 Mon Sep 17 00:00:00 2001 From: VG Date: Wed, 11 May 2016 14:42:09 +0200 Subject: get unseen mails at start --- climl/imap.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/climl/imap.py b/climl/imap.py index 19354d3..3785427 100644 --- a/climl/imap.py +++ b/climl/imap.py @@ -124,12 +124,17 @@ def main(callback=None): connection.select_folder(conf.get('imap.mailbox')) # at start, select all mails idlist = connection.search(['SEEN']) + for oneid in idlist: + print('new mail:', oneid) + print('calling callback...') + callback('mail: ' + str(oneid)) while True: events = imap_waiter(connection) if events: print('events:', events) - print('calling callback...') - callback('mail') + for oneid, _ in events: + print('calling callback...') + callback('mail: ' + str(oneid)) except (socket.error, socket.timeout): pass except KeyboardInterrupt: -- cgit v1.2.3