mirror of https://github.com/django/django.git
Improved connection clean-up for SMTP backend.
This commit is contained in:
parent
de0c7744be
commit
8a844e761d
|
@ -130,12 +130,14 @@ class EmailBackend(BaseEmailBackend):
|
||||||
# Trying to send would be pointless.
|
# Trying to send would be pointless.
|
||||||
return 0
|
return 0
|
||||||
num_sent = 0
|
num_sent = 0
|
||||||
for message in email_messages:
|
try:
|
||||||
sent = self._send(message)
|
for message in email_messages:
|
||||||
if sent:
|
sent = self._send(message)
|
||||||
num_sent += 1
|
if sent:
|
||||||
if new_conn_created:
|
num_sent += 1
|
||||||
self.close()
|
finally:
|
||||||
|
if new_conn_created:
|
||||||
|
self.close()
|
||||||
return num_sent
|
return num_sent
|
||||||
|
|
||||||
def _send(self, email_message):
|
def _send(self, email_message):
|
||||||
|
|
Loading…
Reference in New Issue