diff --git a/jdav_web/mailer/mailutils.py b/jdav_web/mailer/mailutils.py index 3251316..0cfeb2f 100644 --- a/jdav_web/mailer/mailutils.py +++ b/jdav_web/mailer/mailutils.py @@ -13,14 +13,14 @@ def send(subject, content, sender, recipients, message_id, reply_to=None, if type(recipients) != list: recipients = [recipients] if reply_to is not None: - kwargs = {"reply_to": [reply_to]} + kwargs = {"reply_to": reply_to} else: kwargs = {} with mail.get_connection() as connection: for recipient in set(recipients): email = EmailMessage(subject, content, sender, [recipient], - connection=connection, **kwargs, - headers={'Message-ID': message_id}) + headers={'Message-ID': message_id}, + connection=connection, **kwargs) if attachments is not None: for attach in attachments: email.attach_file(attach) diff --git a/jdav_web/mailer/management/commands/reply_addrs.py b/jdav_web/mailer/management/commands/reply_addrs.py index f547b39..b0302a6 100644 --- a/jdav_web/mailer/management/commands/reply_addrs.py +++ b/jdav_web/mailer/management/commands/reply_addrs.py @@ -21,7 +21,7 @@ class Command(BaseCommand): if not replies: # send mail to all jugendleiters - replies = Member.objects.filter(group__name='Jugendleiter', + replies = Member.objects.filter(group__name='Jugendleiter0', gets_newsletter=True) forwards = [l.email for l in replies] subprocess.call(["forward"] + forwards) diff --git a/jdav_web/mailer/models.py b/jdav_web/mailer/models.py index 3b9e103..c91cfc1 100644 --- a/jdav_web/mailer/models.py +++ b/jdav_web/mailer/models.py @@ -72,10 +72,15 @@ class Message(models.Model): # remove any underscores from subject to prevent Arne from using # terrible looking underscores in subjects self.subject = self.subject.replace('_', ' ') + if len(self.reply_to.all()) > 0: + temporary_reply_to = [r.email for r in self.reply_to.all()] + else: + temporary_reply_to = None try: success = send(self.subject, get_content(self.content), SENDING_ADDRESS, emails, + reply_to=temporary_reply_to, message_id=self.pk, attachments=attach) if success == SENT or success == PARTLY_SENT: