mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 12:39:43 +02:00
more cleanup
This commit is contained in:
parent
2f270cded8
commit
e0025dfa4a
1 changed files with 14 additions and 7 deletions
|
@ -34,16 +34,18 @@ def send_templated_email(
|
||||||
):
|
):
|
||||||
"""Send an email built from a template.
|
"""Send an email built from a template.
|
||||||
|
|
||||||
to can be either a string representing a single address or a
|
to_address and bcc_address currently only supports a single address.
|
||||||
list of strings for multi-recipient emails.
|
|
||||||
|
|
||||||
bcc currently only supports a single address.
|
cc_address is a list and can contain many addresses. Emails not in the
|
||||||
|
whitelist (if applicable) will be filtered out before sending.
|
||||||
|
|
||||||
template_name and subject_template_name are relative to the same template
|
template_name and subject_template_name are relative to the same template
|
||||||
context as Django's HTML templates. context gives additional information
|
context as Django's HTML templates. context gives additional information
|
||||||
that the template may use.
|
that the template may use.
|
||||||
|
|
||||||
Raises EmailSendingError if SES client could not be accessed
|
Raises EmailSendingError if:
|
||||||
|
SES client could not be accessed
|
||||||
|
No valid recipient addresses are provided
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not settings.IS_PRODUCTION: # type: ignore
|
if not settings.IS_PRODUCTION: # type: ignore
|
||||||
|
@ -160,8 +162,13 @@ def get_sendable_addresses(addresses: list[str]) -> tuple[list[str], list[str]]:
|
||||||
raise EmailSendingError(message)
|
raise EmailSendingError(message)
|
||||||
else:
|
else:
|
||||||
AllowedEmail = apps.get_model("registrar", "AllowedEmail")
|
AllowedEmail = apps.get_model("registrar", "AllowedEmail")
|
||||||
allowed_emails = [address for address in addresses if (address and AllowedEmail.is_allowed_email(address))]
|
allowed_emails = []
|
||||||
blocked_emails = [address for address in addresses if (address and not AllowedEmail.is_allowed_email(address))]
|
blocked_emails = []
|
||||||
|
for address in addresses:
|
||||||
|
if AllowedEmail.is_allowed_email(address):
|
||||||
|
allowed_emails.append(address)
|
||||||
|
else:
|
||||||
|
blocked_emails.append(address)
|
||||||
|
|
||||||
return allowed_emails, blocked_emails
|
return allowed_emails, blocked_emails
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue