Skip to content

Commit

Permalink
Ensure that SMTP message body is not empty
Browse files Browse the repository at this point in the history
Email notifications of both the start of a deploy, and of a failed
deploy, have empty message bodies. Azure Communication Services rejects
emails with empty message bodies with:

> smtplib.SMTPDataError: (501, b'5.6.0 Request body validation error. Need either non-empty Html or PlainText body to be present.')
  • Loading branch information
kaapstorm committed Jun 7, 2024
1 parent 229cb70 commit 9694dfd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/commcare_cloud/commands/deploy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ def send_email(environment, subject, message='', to_admins=True, recipients=None
"""
Call a Django management command to send an email.
:param environment: The Environement object
:param environment: The Environment object
:param subject: Email subject
:param message: Email message
:param to_admins: True if mail should be sent to Django admins
:param recipients: List of additional addresses to send mail to
"""
if environment.fab_settings_config.email_enabled:
print(color_summary(f">> Sending email: {subject}"))

if not message:
# Azure Communication Services require a message body
message = subject

args = [
message,
'--subject', subject,
Expand Down

0 comments on commit 9694dfd

Please sign in to comment.