From 30a5847320a467a49fb5cac25d9382f69b5dcb72 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 25 Feb 2024 17:20:26 +0000 Subject: [PATCH] Move mail settings to config file --- check.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/check.py b/check.py index fd3ae0e..53615c5 100755 --- a/check.py +++ b/check.py @@ -67,11 +67,6 @@ s.mount("http://", adapter) s.mount("https://", adapter) -MAIL_FROM = "edward@4angle.com" -MAIL_TO_NAME = "Edward Betts" -MAIL_TO_ADDRESS = "edward@4angle.com" -SMTP_HOST = "4angle.com" - not_here_list = [ "The specified URL was not found.", "There is currently no text in this page.", @@ -137,12 +132,15 @@ def check_conference(name: str, url: str) -> tuple[bool, str]: def send_mail(subject: str, body: str) -> None: """Send an e-mail.""" - mail_from = MAIL_FROM + mail_from_address = config["mail"]["from_address"] + mail_from_name = config["mail"]["from_name"] + mail_to_address = config["mail"]["to_address"] + mail_to_name = config["mail"]["to_name"] msg = MIMEText(body, "plain", "UTF-8") msg["Subject"] = subject - msg["To"] = f"{MAIL_TO_NAME} <{MAIL_TO_ADDRESS}>" - msg["From"] = f"Edward Betts <{mail_from}>" + msg["To"] = f"{mail_to_name} <{mail_to_address}>" + msg["From"] = f"{mail_from_name} <{mail_from_address}>" msg["Date"] = formatdate() msg["Message-ID"] = make_msgid()