From 4f84e8a99f6a63ef45d77e6b3fa020cffa9527ed Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Mon, 1 May 2023 17:37:38 +1000 Subject: [PATCH] Update EMAIL_DEBUG to use/support evolution --- ssmain/email.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ssmain/email.py b/ssmain/email.py index 71b75fe..8b7049e 100644 --- a/ssmain/email.py +++ b/ssmain/email.py @@ -1,5 +1,6 @@ # Society Self-Service # Copyright © 2018-2023 Yingtong Li (RunasSudo) +# Copyright © 2023 MUMUS Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -56,9 +57,9 @@ class Emailer: def send_raw_mail(self, recipients, subject, content_txt, content_html): if settings.EMAIL_DEBUG: - with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', suffix='.eml') as f: - print('Subject:' + subject + '\nContent-Type: multipart/alternative; boundary=boundary\n\n--boundary\nContent-Type: text/html; charset=utf-8\n\n' + content_html + '\n--boundary\nContent-Type: text/plain; charset=utf-8\n\n' + content_txt + '\n--boundary', file=f) - subprocess.run(['thunderbird', f.name]) + with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', suffix='.mbox') as f: + print('From: sender@example.com\nTo: ' + ','.join(recipients) + '\nSubject: ' + subject + '\nContent-Type: multipart/alternative; boundary=boundary\nMessage-ID: <0@example.com>\n\n--boundary\nContent-Type: text/html; charset=utf-8\n\n' + content_html + '\n--boundary\nContent-Type: text/plain; charset=utf-8\n\n' + content_txt + '\n--boundary', file=f) + subprocess.run(['evolution', f.name]) time.sleep(5) else: self.boto3_send(