ui / django-post_office

A Django app that allows you to send email asynchronously in Django. Supports HTML email, database backed templates and logging.
MIT License
1.01k stars 271 forks source link

Opening an email in the admin site connects to the mail server #374

Open pdewacht opened 3 years ago

pdewacht commented 3 years ago

If you open an email in the Django admin site, django-post-office attempts to create a connection to the mail server, and crashes if that doesn't work. I see no reason why this should be needed, and it's inconvenient in a dev setup where no mail server might be available.

To reproduce:

e-Dan-K commented 2 years ago

To potentially help with debugging/fixing, I believe this only happens if the email contains an html_message.

presidento commented 1 year ago

By the way, for the dev environment I suggest using the console backend if the mail server is not available. In settings.py:

EMAIL_HOST = load_from_a_noncommitted_config_file()

POST_OFFICE = {
    "BACKENDS": {
        "default": (
            "django.core.mail.backends.smtp.EmailBackend"
            if EMAIL_HOST
            else "django.core.mail.backends.console.EmailBackend"
        )
    }
}