1👍
✅
connection = mail.get_connection()
After this line, connection
represents an settings.EmailBackend
object
Check this
And now your connection
object has an attribute connection
which represents connection is already open or not
So In general terms, logic will be
if connection.connection :
# already open
else:
# not open
Also I will add one point,
When you do connection.open()
, django itself checks whether the connection is already open or not, and do things accordingly.
See this from django’s repo
Source:stackexchange.com