diff --git a/.gitignore b/.gitignore index 61a7006454a..b5e9cdb5e33 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ media/test_orgs media/tmp media/attachments media/blog +media/emails # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/temba/settings_common.py b/temba/settings_common.py index e2d6707cf87..d136730b1dd 100644 --- a/temba/settings_common.py +++ b/temba/settings_common.py @@ -38,23 +38,6 @@ _minio_host = "localhost" _dynamo_host = "localhost" -# ----------------------------------------------------------------------------------- -# Email -# ----------------------------------------------------------------------------------- - -SEND_EMAILS = TESTING # enable sending emails in tests - -EMAIL_HOST = "smtp.gmail.com" -EMAIL_HOST_USER = "server@temba.io" -DEFAULT_FROM_EMAIL = "server@temba.io" -EMAIL_HOST_PASSWORD = "mypassword" -EMAIL_USE_TLS = True -EMAIL_TIMEOUT = 10 - -# Used when sending email from within a flow and the user hasn't configured -# their own SMTP server. -FLOW_FROM_EMAIL = "no-reply@temba.io" - # ----------------------------------------------------------------------------------- # AWS # ----------------------------------------------------------------------------------- @@ -164,6 +147,20 @@ MEDIA_ROOT = os.path.join(PROJECT_DIR, "../media") MEDIA_URL = "/media/" +# ----------------------------------------------------------------------------------- +# Email +# ----------------------------------------------------------------------------------- +EMAIL_HOST = "smtp.gmail.com" +EMAIL_HOST_USER = "server@temba.io" +DEFAULT_FROM_EMAIL = "server@temba.io" +EMAIL_HOST_PASSWORD = "mypassword" +EMAIL_USE_TLS = True +EMAIL_TIMEOUT = 10 + +# Used when sending email from within a flow and the user hasn't configured +# their own SMTP server. +FLOW_FROM_EMAIL = "no-reply@temba.io" + # ----------------------------------------------------------------------------------- # Templates # ----------------------------------------------------------------------------------- diff --git a/temba/utils/email/send.py b/temba/utils/email/send.py index d61904d107a..bc27056cc76 100644 --- a/temba/utils/email/send.py +++ b/temba/utils/email/send.py @@ -68,16 +68,6 @@ def send_email(recipients: list, subject: str, text: str, html: str, from_email: """ Actually sends the email. Having this as separate function makes testing multi-part emails easier """ - if settings.SEND_EMAILS: - message = EmailMultiAlternatives(subject, text, from_email, recipients, connection=connection) - message.attach_alternative(html, "text/html") - message.send() - else: # pragma: no cover - # just print to console if we aren't meant to send emails - print("------------- Skipping sending email, SEND_EMAILS is False -------------") - print(f"To: {', '.join(recipients)}") - print(f"From: {from_email}") - print(f"Subject: {subject}") - print() - print(text) - print("------------------------------------------------------------------------") + message = EmailMultiAlternatives(subject, text, from_email, recipients, connection=connection) + message.attach_alternative(html, "text/html") + message.send()