Commit e01bc6da authored by kaiyou's avatar kaiyou
Browse files

Change the format of generated emails

parent 33365810
Pipeline #263 passed with stage
in 1 minute and 15 seconds
......@@ -49,11 +49,18 @@ def send_mail(context, account, to, message):
smtp.login(account["username"], account["password"])
mail = multipart.MIMEMultipart("alternative")
sentence = fake.sentence(nb_words=6, variable_nb_words=True)[:-1]
mail["Subject"] = f"[{message}] {sentence}]
title = "This message is for delivery monitoring"
content = f"Hello,\n\nThis is an automatically built email, sent by the\
Amonit monitoring system. Its title contains a random generated string so\
that Amnoit can later check that it has indeed been received.\n\n\
You may contact the sending address if this is in any way disturbing your\
email system. Or you can click on the following link to get more\
information about Amonit and what it is about.\n\n\{message}"
mail["Subject"] = f"[{message}] {title}]
mail["From"] = account["username"]
mail["To"] = to
mail.attach(text.MIMEText("\n".join(fake.paragraphs(nb=5)), "text"))
mail.attach(text.MIMEText(content, "text"))
smtp.sendmail(account["username"], to, mail.as_string())
Supports Markdown
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