﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15750	smtp.EmailBackend won't use empty username/password	thialfihar	bedmondmark	"Assuming settings.EMAIL_HOST_USER and/or settings.EMAIL_HOST_PASSWORD is non-empty, then something like this won't work:
{{{
connection = get_connection(host='mail.host.com', port=1234, username='', password='')
send_mail(..., connection=connection)
}}}
Because !EmailBackend.!__init!__ does this:
{{{
    self.username = username or settings.EMAIL_HOST_USER
    self.password = password or settings.EMAIL_HOST_PASSWORD
}}}
and therefore will default to settings.EMAIL_HOST_USER and settings.EMAIL_HOST_PASSWORD.

And then !EmailBackend.open() will attempt SMTP authentication:
{{{
    if self.username and self.password:
        self.connection.login(self.username, self.password)
}}}

A workaround to prevent the login then would be:
{{{
connection = get_connection(host='mail.host.com', port=1234)
connection.username = '' # or None
connection.password = '' # or None
send_mail(..., connection=connection)
}}}

A possible fix might be in !EmailBackend.!__init!__:
{{{
    if username is None:
        self.username = settings.EMAIL_HOST_USER
    else:
        self.username = username
    if password is None:
        self.password = settings.EMAIL_HOST_PASSWORD
    else:
        self.password = password
}}}

I'm not sure whether an empty string as username and password in order to prevent SMTP authentication is frowned upon and only None should be used. If that's the case, then perhaps !EmailBackend shouldn't use '''any''' defaults if, for instance, a different host is passed.
"	Bug	closed	Core (Mail)	1.3-beta	Normal	fixed		thialfihar mbertheau@… alexandrul	Ready for checkin	1	0	0	0	1	0
