From 3ad25201848222ce428b0c30a37c73ca5c2935e8 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 7 Mar 2017 22:24:43 +0100 Subject: [PATCH] send individual mails --- jdav_web/mailer/mailutils.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/jdav_web/mailer/mailutils.py b/jdav_web/mailer/mailutils.py index 16c3ddb..8878b81 100644 --- a/jdav_web/mailer/mailutils.py +++ b/jdav_web/mailer/mailutils.py @@ -9,17 +9,18 @@ def send(subject, content, sender, recipients, reply_to=None, kwargs = {"reply_to": [reply_to]} else: kwargs = {} - email = EmailMessage(subject, content, sender, recipients, **kwargs) - if attachments is not None: - for attach in attachments: - email.attach_file(attach) - try: - email.send() - except Exception as e: - print("Error when sending mail:", e) - return False - else: - return True + for recipient in recipients: + email = EmailMessage(subject, content, sender, [recipient], **kwargs) + if attachments is not None: + for attach in attachments: + email.attach_file(attach) + try: + email.send() + except Exception as e: + print("Error when sending mail:", e) + return False + else: + return True def get_content(content):