Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (19.9k points)

I am using django-anymail(sendgrid) to send emails in my web app. I would like to let the emails send in asynchronous manner without letting the users wait for some time.So, how can I configure django-celery-email with django-anymail.

Now, my email config. is:

ANYMAIL = {

"SENDGRID_API_KEY": os.environ.get('SENDGRID_API_KEY')

}

EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend"

1 Answer

0 votes
by (25.1k points)

In your settings.py:

EMAIL_BACKEND = "djcelery_email.backends.CeleryEmailBackend"

CELERY_EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend"  # your setting from before

Also, note that django-celery-email doesn't know about Anymail's extra sending options, like metadata, tags, template_id, envelope_sender, etc. If you use any of those, you'll need to let django-celery-email know about them in your settings:

CELERY_EMAIL_MESSAGE_EXTRA_ATTRIBUTES = ['metadata', 'tags']  # or whatever you use

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...