Move mail settings to config file

This commit is contained in:
Edward Betts 2024-02-25 17:20:26 +00:00
parent d707eef267
commit 30a5847320

View file

@ -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()