pmclanahan / django-celery-email

A Django email backend that uses a celery task for sending the email.
BSD 3-Clause "New" or "Revised" License
477 stars 110 forks source link

How to integrate it with Amazon SES #74

Open prafulbagai708 opened 4 years ago

prafulbagai708 commented 4 years ago

The question is self-explanatory! I've integrated django-celery-email. Now I want to send an email using Amazon SES, to be specific using https://github.com/django-ses/django-ses/ . How can I do that?

sandhuharjodh commented 4 years ago

Any updates on it?

jd-solanki commented 4 years ago

+1

arnav13081994 commented 4 years ago

You need to add the following to settings.py


# https://anymail.readthedocs.io/en/stable/installation/#installing-anymail
INSTALLED_APPS += ["anymail"]  # noqa F405
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
# EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend"
# Use Celery for sending emails
EMAIL_BACKEND = "djcelery_email.backends.CeleryEmailBackend"
# https://github.com/pmclanahan/django-celery-email
INSTALLED_APPS += ["djcelery_email"]  # noqa F405
# Make celery delegate the actual email sending to AWS SES
CELERY_EMAIL_BACKEND = "anymail.backends.amazon_ses.EmailBackend"

Please note that EMAIL_BACKEND was changed from anymail.backends.amazon_ses.EmailBackend to djcelery_email.backends.CeleryEmailBackend. This makes Django use celery workers for all email tasks. To make sure the actual email sending task is handled by anymail.backends.amazon_ses.EmailBackend (SES) change the CELERY_EMAIL_BACKEND to anymail.backends.amazon_ses.EmailBackend

prafulbagai commented 3 years ago

You don't need to use anymail for this. Just set the following:-

EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' CELERY_EMAIL_BACKEND = 'django_ses.SESBackend'