mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Add HTML email
Make the SES client optionally pass through HTML and text body, as per: http://docs.aws.amazon.com/ses/latest/APIReference/API_Body.html Gets the message as HTML from: https://github.com/alphagov/notifications-utils/pull/12
This commit is contained in:
@@ -267,7 +267,8 @@ def send_email(service_id, notification_id, subject, from_address, encrypted_not
|
||||
from_address,
|
||||
notification['to'],
|
||||
subject,
|
||||
template.replaced
|
||||
body=template.replaced,
|
||||
html_body=template.as_HTML_email,
|
||||
)
|
||||
update_notification_reference_by_id(notification_id, reference)
|
||||
except AwsSesClientException as e:
|
||||
|
||||
@@ -41,6 +41,7 @@ class AwsSesClient(EmailClient):
|
||||
to_addresses,
|
||||
subject,
|
||||
body,
|
||||
html_body='',
|
||||
reply_to_addresses=None):
|
||||
try:
|
||||
if isinstance(to_addresses, str):
|
||||
@@ -50,6 +51,15 @@ class AwsSesClient(EmailClient):
|
||||
elif reply_to_addresses is None:
|
||||
reply_to_addresses = []
|
||||
|
||||
body = {
|
||||
'Text': {'Data': body}
|
||||
}
|
||||
|
||||
if html_body:
|
||||
body.update({
|
||||
'Html': {'Data': html_body}
|
||||
})
|
||||
|
||||
start_time = monotonic()
|
||||
response = self._client.send_email(
|
||||
Source=source,
|
||||
@@ -62,9 +72,7 @@ class AwsSesClient(EmailClient):
|
||||
'Subject': {
|
||||
'Data': subject,
|
||||
},
|
||||
'Body': {
|
||||
'Text': {
|
||||
'Data': body}}
|
||||
'Body': body
|
||||
},
|
||||
ReplyToAddresses=reply_to_addresses)
|
||||
elapsed_time = monotonic() - start_time
|
||||
|
||||
Reference in New Issue
Block a user