When debugging, don't send emails
This commit is contained in:
parent
1afc3f3db7
commit
a0d6164d95
@ -23,6 +23,7 @@ SECRET_KEY = None # IMPORTANT: Set this to a secret string
|
||||
SECRET_KEY_MEMBERSIG = None # IMPORTANT: Set this to a secret string
|
||||
|
||||
DEBUG = True
|
||||
EMAIL_DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
@ -24,6 +24,11 @@ from jinja2 import Markup
|
||||
|
||||
import markdown
|
||||
|
||||
# Debugging
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
class Emailer:
|
||||
def __init__(self):
|
||||
self.client = boto3.client('ses', aws_access_key_id=settings.AWS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET, region_name=settings.AWS_REGION)
|
||||
@ -47,6 +52,12 @@ class Emailer:
|
||||
raise Exception('Reached maximum number of retries')
|
||||
|
||||
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])
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
self.boto3_send(
|
||||
Destination={
|
||||
'ToAddresses': recipients,
|
||||
|
Loading…
Reference in New Issue
Block a user