brack3t / Djrill

[INACTIVE/UNMAINTAINED] Djrill is an email backend and new message class for Django users that want to take advantage of the Mandrill transactional email service from MailChimp.
BSD 3-Clause "New" or "Revised" License
319 stars 64 forks source link

Emails with errors logs not sending #106

Closed diegomatar closed 8 years ago

diegomatar commented 8 years ago

All the messages triggered by user actions are being send to their respective destination email address. But, the messages with error logs, are not being delivered to my email, as they were supposed to be.

I already checked the server configurations with the hosting company, but it seems that some configuration is missing (or being overwritten) in my settings.py.

I have the following settings.py configurations:

    #SETUP EMAIL ACOUNT

    # Production
    EMAIL_USE_TLS = True
    EMAIL_HOST = 'smtp.mandrillapp.com'
    EMAIL_HOST_USER = 'qandaperguntas@gmail.com'
    EMAIL_HOST_PASSWORD = 'my_correct_password'
    EMAIL_PORT = 587

    # Djrill (Transactional Emails) settings
    MANDRILL_API_KEY = "my_mandrill_api_key"
    EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend"
    DEFAULT_FROM_EMAIL = "contato@qanda.com.br" 
    SERVER_EMAIL = "contato@qanda.com.br"

And the API logs shows a error with the "from_email":

    "from_email": "root@localhost",
            "subject": "[Django] ERROR (EXTERNAL IP): Internal Server Error: /notificacoes/news/",
            "to": [
                {
                    "type": "to",
                    "email": "diegomatar@gmail.com",
                    "name": ""
                }
            ]

    Full Response
    {
        "code": -2,
        "name": "ValidationError",
        "message": "Validation error: {\"message\":{\"from_email\":\"The domain portion of the email address is invalid (the portion after the @: localhost)\"}}"
    }
medmunds commented 8 years ago

Thanks for including the API logs. It looks like Django's error handler is asking Djrill to send an email from "root@localhost", and Mandrill doesn't allow that as a valid from address.

"root@localhost" is the default value for Django's SERVER_EMAIL setting. So the question is why Django isn't seeing your SERVER_EMAIL = "contato@qanda.com.br" setting. (We know that the EMAIL_BACKEND and MANDRILL_API_KEY settings are being executed: your Djrill API logs confirm that Django is using the Djrill backend and Djrill is managing to call the Mandrill API. So why is only the SERVER_EMAIL line not working?)

Some things you might check: Are there maybe some parts of your settings.py that would prevent that statement from executing (e.g., an if DEBUG: test)? Do you maybe have multiple settings.py files (e.g., one for production, one for debug) and SERVER_EMAIL is missing from one of them? You mention your hosting company -- do they do something that overrides some Django settings, and if so, can you get ahold of the Django settings values after their changes to see what they've done?

(BTW, when you're using Djrill, the Django SMTP email settings like EMAIL_HOSTdon't apply. It shouldn't hurt to have them in your settings.py, but Djrill ignores them because it calls the Mandrill http API directly.)

diegomatar commented 8 years ago

Thanks a lot, I will check these issues you mention.

medmunds commented 8 years ago

@diegomatar assuming you managed to solve this. If not, please reopen with additional details of your settings.py.