In settings.py
CELERY_SEND_TASK_ERROR_EMAILS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
ADMINS = (
('test', '...@....com'),
)
EMAIL_HOST='smtp.gmail.com'
EMAIL_HOST_USER='...@gmail.com'
EMAIL_HOST_PASSWORD='...'
EMAIL_PORT=587
EMAIL_USE_TLS = True
Then in the celery.py file, if you create the configuration, use this:
app.conf.update(
ADMINS = ('test', '...@....com'),
CELERY_SEND_TASK_ERROR_EMAILS= True,
....
....
)
To test this code, check the use of these lines in the shell:
from app_name.celery import app
app.mail_admins('Subject', 'body', fail_silently=False)
This is necessary to send email to your admins. If this work, then it will certainly send a letter on the failed task.
source
share