Django + Heroku + Mandrill mail_admins () does not work, either manually, or as caused by a 500 error

I have a Django website (v1.4) on Heroku using Mandrill for SMTP. I have all the necessary values ​​in the settings file:

  • EMAIL_HOST_PASSWORD
  • EMAIL_HOST_USER
  • EMAIL_HOST
  • EMAIL_PORT
  • SERVER_EMAIL (set to the real address, not root @localhost)

I can send regular emails using send_messages() manually from the client. But no emails are sent when no errors are mail_admins in the client for 500 errors and calling mail_admins , but an email is also not sent.

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', ' myaddress@gmail.com '), ) 

I checked the spam folder and there is nothing there. Am I missing something in the settings? Or something else?

+6
source share
1 answer

Have you checked the Mandrill API logs?

I have the same problem and I noticed that emails are being sent to the Mandrill API (since I set my smtp settings for Mandrill in settings.py), but that from_email and from_name are empty in the API calls.

So, I found https://github.com/brack3t/Djrill and am going to install it. I will let you know if this "just works."

EDIT: Therefore, after installing djrill and the subsequent documentation, I get unsuccessful API calls for error messages. For some reason, from_email appears as "root @localhost".

When I test the shell shown on the github page (with the email address from the 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 < djrill@example.com >", [" to@example.com "]) 

Turns out I had a default configured name of "From". It is called SERVER_EMAIL. See https://docs.djangoproject.com/en/1.3/ref/settings/#std:setting-SERVER_EMAIL .

So in settings.py the following is indicated ::

 SERVER_EMAIL = myname@myMandrillApprovedDomain.com 
+13
source

Source: https://habr.com/ru/post/947169/


All Articles