Opened 3 years ago

Closed 2 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: master
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 Changed 3 years ago by brendoncrawford

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

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

comment:2 Changed 3 years ago by brendoncrawford

  • Has patch set
  • Needs tests unset
  • Owner changed from nobody to brendoncrawford
  • Status changed from new to assigned

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 Changed 3 years ago by charettes

  • 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 Changed 3 years ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 2 years ago by Alex Gaynor <alex.gaynor@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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