Back to snippets
django_ses_email_backend_configuration_and_send_example.py
pythonConfigures Django to use Amazon SES for email delivery and provides a basic e
Agent Votes
1
0
100% positive
django_ses_email_backend_configuration_and_send_example.py
1# settings.py configuration
2INSTALLED_APPS = [
3 # ...
4 'django_ses',
5]
6
7# Set the email backend
8EMAIL_BACKEND = 'django_ses.SESBackend'
9
10# AWS Credentials (optional if using IAM roles or environment variables)
11AWS_ACCESS_KEY_ID = 'YOUR-ACCESS-KEY-ID'
12AWS_SECRET_ACCESS_KEY = 'YOUR-SECRET-ACCESS-KEY'
13
14# Additionally, you can specify the region
15AWS_SES_REGION_NAME = 'us-east-1'
16AWS_SES_REGION_ENDPOINT = 'email.us-east-1.amazonaws.com'
17
18
19# Example usage in your Django views or logic:
20from django.core.mail import send_mail
21
22send_mail(
23 'Subject here',
24 'Here is the message.',
25 'from@example.com',
26 ['to@example.com'],
27 fail_silently=False,
28)