﻿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
19382	Closing SMTP backend raises AttributeError when already closed	Sebastian Noack	nobody	"{{{
>>> from django.core.mail import get_connection
>>> smtp = get_connection('django.core.mail.backends.smtp.EmailBackend')
>>> smtp.close()
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/home/sebastian/p24/src/placement24/placement24/django/core/mail/backends/smtp.py"", line 66, in close
    self.connection.quit()
AttributeError: 'NoneType' object has no attribute 'quit'
}}}

The SMTP backend is the only mail backend that can't be closed without opening it. In fact the filebased backend contains code to explicitly handle that case. So the smtp backend should handle it as well.

If that is not reason enough, note that it is not always possible to know whether the connection is open and must be closed or not. For example, when open() was called and an SMTP connection was established, but the login failed, close() must be called even though open() raised an exception. However when the exception was raised while establishing the connection, close() would raise the AttributeError, shown above.

Therefore the close() method must just return in case the connection isn't open."	Bug	closed	Core (Mail)	1.4	Normal	fixed			Accepted	1	0	1	0	1	0
