Django Amazon SES

raw JSON →
4.0.1 verified Fri May 01 auth: no python

A Django email backend that uses Boto3 to interact with Amazon Simple Email Service (SES). Version 4.0.1 drops Python 3.6 and Django 3.0/3.1 support, adds Python 3.9/3.10 and Django 3.2/4.0, and enables email tagging.

pip install django-amazon-ses
error ImportError: No module named 'django_amazon_ses'
cause Package not installed or used wrong package name in import.
fix
Run 'pip install django-amazon-ses' and use 'from django_amazon_ses.backends import SESBackend'.
error botocore.exceptions.NoCredentialsError: Unable to locate credentials
cause AWS credentials not provided to boto3.
fix
Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in Django settings or environment variables.
error django.core.mail.backends.base.InvalidEmailBackendError: 'django_ses.SESBackend' is not a valid email backend
cause Using the old backend path from earlier versions.
fix
Change EMAIL_BACKEND to 'django_amazon_ses.backends.SESBackend'.
error botocore.errorfactory.MessageRejected: An error occurred (MessageRejected) when calling the SendEmail operation: Email address is not verified.
cause Sending to unverified email in SES sandbox.
fix
Verify the recipient's email address in SES console or request production access.
breaking Version 4.0.1 drops Python 3.6 and Django 3.0/3.1 support. Upgrade Python to >=3.7 and Django to >=3.2.
fix Use Python 3.7+ and Django 3.2+.
gotcha The email backend requires Boto3 credentials (access key, secret key, region) to be configured. Missing them causes silent failures or boto3 exceptions.
fix Set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SES_REGION_NAME in Django settings or environment variables.
gotcha SES sandbox mode restricts sending to verified email addresses only unless you move out of sandbox. Emails to unverified recipients will fail with a 550 error.
fix Either verify all recipient addresses in SES console or request production access.
deprecated The older backend path 'django_ses.SESBackend' was used in previous versions. The correct import is now 'django_amazon_ses.backends.SESBackend'.
fix Use 'django_amazon_ses.backends.SESBackend' as EMAIL_BACKEND.

Minimal setup: configure Django settings with SES backend, then call send_mail.

import os
import django
from django.conf import settings
from django.core.mail import send_mail

# Configure Django settings
settings.configure(
    DEBUG=True,
    DATABASES={},
    EMAIL_BACKEND='django_amazon_ses.backends.SESBackend',
    AWS_ACCESS_KEY_ID=os.environ.get('AWS_ACCESS_KEY_ID', 'your-access-key'),
    AWS_SECRET_ACCESS_KEY=os.environ.get('AWS_SECRET_ACCESS_KEY', 'your-secret-key'),
    AWS_SES_REGION_NAME=os.environ.get('AWS_SES_REGION_NAME', 'us-east-1'),
    AWS_SES_REGION_ENDPOINT='email.us-east-1.amazonaws.com',
    DEFAULT_FROM_EMAIL='sender@example.com',
)
django.setup()

send_mail(
    'Subject here',
    'Here is the message.',
    'sender@example.com',
    ['recipient@example.com'],
    fail_silently=False,
)