Created
September 15, 2016 13:33
-
-
Save flevour/c145c99e5b049bf11877ea4985cbb0fa to your computer and use it in GitHub Desktop.
Small integration class for `python-emails`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SendmailViaSES(object): | |
def sendmail(self, from_addr, to_addrs, msg, **kwargs): | |
return ses.send_email( | |
Source=from_addr, | |
Destination={ | |
'ToAddresses': to_addrs, | |
}, | |
Message={ | |
'Subject': { | |
'Data': msg.get_subject(), | |
}, | |
'Body': { | |
'Text': { | |
'Data': msg.text_body, | |
}, | |
'Html': { | |
'Data': msg.html_body, | |
}, | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ses import SendmailViaSES | |
m = emails.Message(html=templates.get_template("template.html"), | |
text=templates.from_string("Sample text {{ data }}"), | |
subject=templates.from_string("Sample subject: {{ data }}"), | |
mail_from=("", "noreply@example.com")) | |
response = m.send(render={"data": data}, | |
to=self.recipient_email, | |
smtp=SendmailViaSES()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where is templates. coming from?