Opened 11 years ago

Closed 11 years ago

#20194 closed Cleanup/optimization (fixed)

"console", "dummy", and "locmem" email backends should accept generators to send_messages() just as "smtp" backend does

Reported by: brendoncrawford Owned by: brendoncrawford
Component: Core (Mail) Version: dev
Severity: Normal Keywords: email, email backends, emailbackend
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


Change History (5)

comment:1 by brendoncrawford, 11 years ago

Needs tests: set

I am working on a patch, which I will submit via Github pull request soon.

comment:2 by brendoncrawford, 11 years ago

Has patch: set
Needs tests: unset
Owner: changed from nobody to brendoncrawford
Status: newassigned

Github Pull Request is Here:


from import BaseCommand
from django.core import mail

class Command(BaseCommand):
    help = 'Test for'

    def handle(self, *args, **options):
        mail_from = "root+foo@localhost"
        msgs = [
            ("root+baz@localhost", "Test 1", "Test 1 Body"),
            ("root+baz@localhost", "Test 2", "Test 2 Body")
        cb = lambda m: mail.EmailMessage(m[1], m[2], mail_from, [m[0]])
        email_messages = (cb(m) for m in msgs)
        conn = mail.get_connection()
        sent_count = conn.send_messages(email_messages)
        print("Sent: %d" % sent_count)
        return ''

comment:3 by Simon Charette, 11 years ago

Patch needs improvement: set

Your test must be integrated into the test suite.

An additional test_send_messages_generator method on the mail.tests.BaseEmailBackendTests class should do.

comment:4 by Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Alex Gaynor <alex.gaynor@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 5ac7f777cde6cdabee8c804fd8c71c4fd5f71d3c:

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

Fixed #20194 -- Adds generators support for email backends that do not support it.

Note: See TracTickets for help on using tickets.
Back to Top