Package: django-ses3
Info:A Django email backend for Amazon’s Simple Email ServiceAuthor:Harry Marr (http://github.com/hmarr,http://twitter.com/harrymarr)Collaborators:Paul Craciunoiu (http://github.com/pcraciunoiu,http://twitter.com/embrangler)Attention:This project is not actively maintained as of ~end 2012, but it is still fairly popular and in use.
If you are interested in helping out, please contactPaul Craciunoiu (pcraciunoiu).A bird’s eye viewDjango-SES is a drop-in mail backend forDjango. Instead of sending emails
through a traditional SMTP mail server, Django-SES routes email through
Amazon Web Services’ excellent Simple Email Service (SES).Using Django directlyAmazon SES allows you to also setup usernames and passwords. If you do configure
things that way, you do not need this package. The Django default email backend
is capable of authenticating with Amazon SES and correctly sending email.Using django-ses gives you additional features like deliverability reports that
can be hard and/or cumbersome to obtain when using the SMTP interface.Note:In order to use smtp with Amazon SES, you may have to install some
supporting packages for ssl. Check outthis SMTP SSL email backend for DjangoWhy SES instead of SMTP?Configuring, maintaining, and dealing with some complicated edge cases can be
time-consuming. Sending emails with Django-SES might be attractive to you if:You don’t want to maintain mail servers.You are already deployed on EC2 (In-bound traffic to SES is free from EC2
instances).You need to send a high volume of email.You don’t want to have to worry about PTR records, Reverse DNS, email
whitelist/blacklist services.Django-SES is a truely drop-in replacement for the default mail backend.
Your code should require no changes.Getting goingAssuming you’ve gotDjangoinstalled, you’ll needBoto2.1.0 or higher.Botois a Python library that wraps the AWS API.You can do the following to install boto 2.1.0 (we’re using –upgrade here to
make sure you get 2.1.0):pip install --upgrade botoInstall django-ses:pip install django-sesAdd the following to your settings.py:EMAIL_BACKEND = 'django_ses.SESBackend'

# These are optional -- if they're set as environment variables they won't
# need to be set here as well
AWS_ACCESS_KEY_ID = 'YOUR-ACCESS-KEY-ID'
AWS_SECRET_ACCESS_KEY = 'YOUR-SECRET-ACCESS-KEY'

# Additionally, you can specify an optional region, like so:
AWS_SES_REGION_NAME = 'us-east-1'
AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com'Alternatively, instead ofAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY, you
can include the following two settings values. This is useful in situations
where you would like to use a separate access key to send emails via SES than
you would to upload files via S3:AWS_SES_ACCESS_KEY_ID = 'YOUR-ACCESS-KEY-ID'
AWS_SES_SECRET_ACCESS_KEY = 'YOUR-SECRET-ACCESS-KEY'Now, when you usedjango.core.mail.send_mail, Simple Email Service will
send the messages by default.Since SES imposes a rate limit and will reject emails after the limit has been
reached, django-ses will attempt to conform to the rate limit by querying the
API for your current limit and then sending no more than that number of
messages in a two-second period (which is half of the rate limit, just to
be sure to stay clear of the limit). This is controlled by the following setting:AWS_SES_AUTO_THROTTLE = 0.5 # (default; safety factor applied to rate limit)To turn off automatic throttling, set this to None.Check out theexampledirectory for more information.DKIMUsingDomainKeysis entirely optional, however it is recommended by Amazon for
authenticating your email address and improving delivery success rate.  Seehttp://docs.amazonwebservices.com/ses/latest/DeveloperGuide/DKIM.html.
Besides authentication, you might also want to consider using DKIM in order to
remove thevia email-bounces.amazonses.commessage shown to gmail users -
seehttp://support.google.com/mail/bin/answer.py?hl=en&answer=1311182.To enable DKIM signing you should install thepydkimpackage and specify values
for theDKIM_PRIVATE_KEYandDKIM_DOMAINsettings.  You can generate a
private key with a command such asopenssl genrsa 512and get the public key
portion withopenssl rsa-pubout<private.key.  The public key should be
published toses._domainkey.example.comif your domain is example.com.  You
can use a different name instead ofsesby changing theDKIM_SELECTORsetting.The SES relay will modify email headers such asDateandMessage-Idso by
default only theFrom,To,Cc,Subjectheaders are signed, not the full
set of headers.  This is sufficient for most DKIM validators but can be overridden
with theDKIM_HEADERSsetting.Example settings.py:DKIM_DOMAIN = 'example.com'
DKIM_PRIVATE_KEY = '''
-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxxx
-----END RSA PRIVATE KEY-----
'''Example DNS record published to Route53 with boto:route53 add_record ZONEID ses._domainkey.example.com. TXT ‘“v=DKIM1; p=xxx”’ 86400SES Sending StatsDjango SES comes with two ways of viewing sending statistics.The first one is a simple read-only report on your 24 hour sending quota,
verified email addresses and bi-weekly sending statistics.To generate and view SES sending statistics reports, include, updateINSTALLED_APPS:INSTALLED_APPS = (
    # ...
    'django.contrib.admin',
    'django_ses',
    # ...
)… andurls.py:urlpatterns += (url(r'^admin/django-ses/', include('django_ses.urls')),)Optional enhancements to stats:Localized datetime in the stats dashboardYou can installpytzto localize the Amazon timestamp
(assumed UTC) to your locale. This will also make the date more readable,
using Django’s default formatting.Link the dashboard from the adminYou can use adminplus for this (https://github.com/jsocol/django-adminplus):from django_ses.views import dashboard
admin.site.register_view('django-ses', dashboard, 'Django SES Stats')Store daily statsIf you need to keep send statistics around for longer than two weeks,
django-ses also comes with a model that lets you store these. To use this
feature you’ll need to first runsyncdb:python manage.py syncdbTo collect the statistics, run theget_ses_statisticsmanagement command
(refer to next section for details). After running this command the statistics
will be viewable via/admin/django_ses/.Django SES Management CommandsTo use these you must includedjango_sesin your INSTALLED_APPS.Managing Verified Email AddressesManage verified email addresses through the management command.python manage.py ses_email_address -lCollecting Sending StatisticsTo collect and store SES sending statistics in the database, run:python manage.py get_ses_statisticsSending statistics are aggregated daily (UTC time). Stats for the latest day
(when you run the command) may be inaccurate if run before end of day (UTC).
If you want to keep your statistics up to date, setupcronto run this
command a short time after midnight (UTC) daily.Django Builtin-in Error EmailsIf you’d like Django’sBuiltin Email Error Reportingto function properly
(actually send working emails), you’ll have to explicitly set theSERVER_EMAILsetting to one of your SES-verified addresses. Otherwise, your
error emails will all fail and you’ll be blissfully unaware of a problem.Note:You will need to sign up forSESand verify any emails you’re going
to use in thefrom_emailargument todjango.core.mail.send_email().Botohas averify_email_address()method:https://github.com/boto/boto/blob/master/boto/ses/connection.pyRequirementsdjango-ses requires boto version 2.1.0 or later.Full List of SettingsAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYRequired.Your API keys for Amazon SES.AWS_SES_ACCESS_KEY_ID,AWS_SES_SECRET_ACCESS_KEYRequired.Alternative API keys for Amazon SES. This is useful in situations
where you would like to use separate access keys for different AWS services.AWS_SES_REGION_NAME,AWS_SES_REGION_ENDPOINTOptionally specify what region your SES service is using. Details:http://readthedocs.org/docs/boto/en/latest/ref/ses.html#boto.ses.regionsAWS_SES_RETURN_PATHInstruct Amazon SES to forward bounced emails and complaints to this email.
For more information please refer tohttp://aws.amazon.com/ses/faqs/#38TIME_ZONEDefault Django setting, optionally set this. Details:https://docs.djangoproject.com/en/dev/ref/settings/#time-zoneDKIM_DOMAIN,DKIM_PRIVATE_KEYOptional. If these settings are defined and thepydkimmodule is installed
then email messages will be signed with the specified key.   You will also
need to publish your public key on DNS; the selector is set tosesby
default.  Seehttp://dkim.org/for further detail.ContributingIf you’d like to fix a bug, add a feature, etcStart by opening an issue.Be explicit so that project collaborators can understand and reproduce the
issue, or decide whether the feature falls within the project’s goals.
Code examples can be useful, too.File a pull request.You may write a prototype or suggested fix.Check your code for errors, complaints.Usecheck.pyWrite and run tests.Write your own test showing the issue has been resolved, or the feature
works as intended.Running TestsTo run the tests:python manage.py test django_ses