Opened 13 years ago

Closed 13 years ago

#17445 closed Bug (wontfix)

sending mail fails when EMAIL_HOST is an empty string

Reported by: tinodb Owned by: nobody
Component: Core (Mail) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I changed EMAIL_HOST from a hostname to an empty string, expecting it to use localhost. A misleading error was thrown: SMTPServerDisconnected: please run connect() first. This is because the empty string is passed down to smtplib.SMTP, which doesn't connect on init when the given host evaluates to False.

I don't know what the best solution would be, maybe a note in the docs would be enough? Or should the django SMTP backend change an empty host to 'localhost'?

Change History (1)

comment:1 by Karen Tracey, 13 years ago

Resolution: wontfix
Status: newclosed

The way to have your project use a default value, for any setting, is to not set it at all in your own settings file. This is described here: https://docs.djangoproject.com/en/1.3/topics/settings/#default-settings

If you instead set it to an empty value, that's the value that will be used. Likely there are many settings that will give odd errors if this is done. I don't see that EMAIL_HOST is special in some way that Django's code should guard against an "improper" setting and fallback to the default in spite of what's been set in the local settings file. Which implies if we were to "fix" this case, we should "fix" all such settings where an empty value would likely never be correct, and make them fallback to their defaults. Which I don't think we want to do.

Note: See TracTickets for help on using tickets.
Back to Top