allow multiple reply_tos in the ugly way, temporary workaround

v1-0-stable
Christian Merten 7 years ago
parent 5cf9afa3cc
commit 83b4bd09a4

@ -13,14 +13,14 @@ def send(subject, content, sender, recipients, message_id, reply_to=None,
if type(recipients) != list: if type(recipients) != list:
recipients = [recipients] recipients = [recipients]
if reply_to is not None: if reply_to is not None:
kwargs = {"reply_to": [reply_to]} kwargs = {"reply_to": reply_to}
else: else:
kwargs = {} kwargs = {}
with mail.get_connection() as connection: with mail.get_connection() as connection:
for recipient in set(recipients): for recipient in set(recipients):
email = EmailMessage(subject, content, sender, [recipient], 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: if attachments is not None:
for attach in attachments: for attach in attachments:
email.attach_file(attach) email.attach_file(attach)

@ -21,7 +21,7 @@ class Command(BaseCommand):
if not replies: if not replies:
# send mail to all jugendleiters # send mail to all jugendleiters
replies = Member.objects.filter(group__name='Jugendleiter', replies = Member.objects.filter(group__name='Jugendleiter0',
gets_newsletter=True) gets_newsletter=True)
forwards = [l.email for l in replies] forwards = [l.email for l in replies]
subprocess.call(["forward"] + forwards) subprocess.call(["forward"] + forwards)

@ -72,10 +72,15 @@ class Message(models.Model):
# remove any underscores from subject to prevent Arne from using # remove any underscores from subject to prevent Arne from using
# terrible looking underscores in subjects # terrible looking underscores in subjects
self.subject = self.subject.replace('_', ' ') 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: try:
success = send(self.subject, get_content(self.content), success = send(self.subject, get_content(self.content),
SENDING_ADDRESS, SENDING_ADDRESS,
emails, emails,
reply_to=temporary_reply_to,
message_id=self.pk, message_id=self.pk,
attachments=attach) attachments=attach)
if success == SENT or success == PARTLY_SENT: if success == SENT or success == PARTLY_SENT:

Loading…
Cancel
Save