Amazon SES with Python and Django

Send via SES from Python? Check.


It’s amazing to see that a product that Amazon announces has ready-to-use python code overnight. Getting setup to send email using Amazon’s Simple Email Service is a breeze using Harry Marr’s [1] boto and Django-SES packages available on github [2][3].

Using SES directly in python is a matter of instantiating an SESConnection and calling send_email:

from import SESConnection

source = ""
subject = "hello SES!"
body = "email message from python!"
to_addresses = [""]

connection = SESConnection(aws_access_key_id=<your id>, aws_secret_access_key=<your key>)
connection.send_email(source, subject, body, to_addresses)

Integrating it into django is pretty trivial, just add to

EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_ACCESS_KEY_ID = <your id>

Once that’s in your settings, your application doesn’t have to change at all to send via SES.

The downside: SES does not handle attachments, period. You can only send text or HTML-formatted emails. If you need to send files, you’re out of luck for now.


3 thoughts on “Amazon SES with Python and Django”

  1. The Python community is an exciting place to be at this time and boto is a very nice example of open source done right (and Pythonic). Thank you for the helpful article!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s