Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SEND_EMAILS in favor of file backend #5906

Merged
merged 3 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ media/test_orgs
media/tmp
media/attachments
media/blog
media/emails

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
31 changes: 14 additions & 17 deletions temba/settings_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"
DEFAULT_FROM_EMAIL = "[email protected]"
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 = "[email protected]"

# -----------------------------------------------------------------------------------
# AWS
# -----------------------------------------------------------------------------------
Expand Down Expand Up @@ -164,6 +147,20 @@
MEDIA_ROOT = os.path.join(PROJECT_DIR, "../media")
MEDIA_URL = "/media/"

# -----------------------------------------------------------------------------------
# Email
# -----------------------------------------------------------------------------------
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "[email protected]"
DEFAULT_FROM_EMAIL = "[email protected]"
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 = "[email protected]"

# -----------------------------------------------------------------------------------
# Templates
# -----------------------------------------------------------------------------------
Expand Down
16 changes: 3 additions & 13 deletions temba/utils/email/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()