"""Simple email service by AWS."""
import boto3
def get_ses_client():
"""Get ses client."""
return boto3.client('ses')
def send_email(params):
"""Send an email with ses.
Args:
params (dict): the params of the email to send.
e.g.
params = {
subject: 'Analytics Digest Notification',
to: ['test_recepient@theorchard.com'],
sender: 'test_sender@theorchard.com',
text_body: '
Text body would be used if recepient
client
is not configured to accept html
',
html_body: '
'
}
Returns:
None
"""
client = get_ses_client()
client.send_email(
Destination={
'ToAddresses': params['to'],
},
Message={
'Body': {
'Html': {
'Charset': 'UTF-8',
'Data': params['html_body'],
},
'Text': {
'Charset': 'UTF-8',
'Data': params['text_body'],
}
},
'Subject': {
'Charset': 'UTF-8',
'Data': params['subject'],
},
},
Source=params['sender']
)