A simple Django email backend which uses Huey.
Add the app to your settings:
# settings.py
INSTALLED_APPS = [
...
"huey.contrib.djhuey",
"hueymail",
...
]
and use it as your email backend:
# settings.py
EMAIL_BACKEND = 'hueymail.backends.EmailBackend'
Last, choose which email backend Huey should dispatch to via the HUEY_EMAIL_BACKEND
setting:
# settings.py
HUEY_EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
What happens when you send an email? Basically this:
- Django creates a new instance of
hueymail.backends.EmailBackend
, and calls itssend_messages()
method with the email messages it wants to send. - The
send_messages()
method of thehueymail.backends.EmailBackend
instance dispatches a Huey task calleddispatch_messages()
, which is responsible for sending those messages. - The
dispatch_messages()
task creates an instance ofHUEY_EMAIL_BACKEND
and calls itssend_messages()
method with the original email messages.
Copyright (c) 2022 Christopher McDonald
Distributed under the terms of the MIT license.