Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #991 from stockr-labs/feature/email-backends-gener…

…ators

Fixed #20194 -- Adds generators support for email backends that do not support it.
  • Loading branch information...
commit 5ac7f777cde6cdabee8c804fd8c71c4fd5f71d3c 2 parents 626fa28 + cd1ca26
@alex alex authored
View
4 django/core/mail/backends/console.py
@@ -16,6 +16,7 @@ def send_messages(self, email_messages):
"""Write all messages to the stream in a thread-safe way."""
if not email_messages:
return
+ msg_count = 0
with self._lock:
try:
stream_created = self.open()
@@ -24,9 +25,10 @@ def send_messages(self, email_messages):
self.stream.write('-' * 79)
self.stream.write('\n')
self.stream.flush() # flush after each message
+ msg_count += 1
if stream_created:
self.close()
except:
if not self.fail_silently:
raise
- return len(email_messages)
+ return msg_count
View
2  django/core/mail/backends/dummy.py
@@ -6,4 +6,4 @@
class EmailBackend(BaseEmailBackend):
def send_messages(self, email_messages):
- return len(email_messages)
+ return len(list(email_messages))
View
4 django/core/mail/backends/locmem.py
@@ -20,7 +20,9 @@ def __init__(self, *args, **kwargs):
def send_messages(self, messages):
"""Redirect messages to the dummy outbox"""
+ msg_count = 0
for message in messages: # .message() triggers header validation
message.message()
+ msg_count += 1
mail.outbox.extend(messages)
- return len(messages)
+ return msg_count

0 comments on commit 5ac7f77

Please sign in to comment.
Something went wrong with that request. Please try again.