From 6da13d1120bec486a743b15fdd9c29ed8f68e29b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 4 Dec 2023 23:34:19 +0100 Subject: [PATCH] fix credentials --- prototyping/email_stuff.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/prototyping/email_stuff.py b/prototyping/email_stuff.py index a8896f8..ce0d850 100644 --- a/prototyping/email_stuff.py +++ b/prototyping/email_stuff.py @@ -1,6 +1,7 @@ # %% import email import json +import os from email.header import decode_header from imaplib import IMAP4, IMAP4_SSL from pathlib import Path @@ -11,19 +12,20 @@ cred_file = Path("../credentials.json") with open(cred_file, "r") as f: CREDENTIALS = json.load(f) -username = CREDENTIALS["imap_user"] -password = CREDENTIALS["imap_pass"] +for key, value in CREDENTIALS.items(): + os.environ[key] = value + +IMAP_HOST = os.environ["IMAP_HOST"] +IMAP_PORT = os.environ["IMAP_PORT"] +IMAP_USER = os.environ["IMAP_USER"] +IMAP_PASS = os.environ["IMAP_PASS"] # ----------------------------------- imap ----------------------------------- # -host = "mail.local-it.org" -imap_port = 143 -imap_ssl_port = 993 - -with IMAP4_SSL(host=host) as imap_server: - imap_server.login(username, password) +with IMAP4_SSL(host=IMAP_HOST) as imap_server: + imap_server.login(IMAP_USER, IMAP_PASS) imap_server.select("INBOX") # Search for all emails in the folder