Commit 99e326f9 authored by Benjamin Graillot's avatar Benjamin Graillot

Use IMAP STARTTLS

parent 5946d1b9
......@@ -35,14 +35,16 @@ class MailSources:
def loop(self):
while True:
try:
imap_client = imaplib.IMAP4_SSL(host=secrets.host)
imap_client = imaplib.IMAP4(host=secrets.host)
imap_client.starttls()
imap_client.login(secrets.user, secrets.password)
imap_client.select()
print('email: Running...')
while True:
for uid, msg in imap_client.idle():
if msg == b'EXISTS':
fetcher = imaplib.IMAP4_SSL(host=secrets.host)
fetcher = imaplib.IMAP4(host=secrets.host)
fetcher.starttls()
fetcher.login(secrets.user, secrets.password)
fetcher.select()
mail = fetcher.fetch(uid.decode('ascii'), '(RFC822)')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment