I have a Django (v1.4) site on Heroku using Mandrill for SMTP. I have all the required values in my settings file:
I can send regular emails just fine using send_messages()
manually from the client. But no emails are sent when for 500 errors and calling mail_admins
in the client doesn't produce any errors but also doesn't send an email.
Here is my logging setup:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
And my ADMINS:
ADMINS = (
('My Name', '[email protected]'),
)
I've checked my Spam folder and there is nothing there. Am I missing something in settings? Or something else?
Have you checked your Mandrill API logs?
I am having the same issue and noticed that the emails are being sent to the Mandrill API (since I set my smtp settings for Mandrill in settings.py), but that the from_email and from_name are empty in the API calls.
So, I found https://github.com/brack3t/Djrill and am about to install it. I'll let you know if it "just works".
EDIT: So after installing djrill and following the documentation I'm getting failed API calls for error messages - the from_email is showing as "root@localhost" for some reason.
When I do the shell test shown on the github page (with an email from an accepted domain for my Mandrill account replacing Djrill Sender), it works:
from django.core.mail import send_mail
send_mail("It works!", "This will get sent through Mandrill",
"Djrill Sender <[email protected]>", ["[email protected]"])
It turns out that I had my default "From" email setting name confused. Its called SERVER_EMAIL. See https://docs.djangoproject.com/en/1.3/ref/settings/#std:setting-SERVER_EMAIL.
So the following in settings.py fixed my issue:
SERVER_EMAIL = [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With