Code

#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

Description


Attachments (0)

Change History (5)

comment:1 Changed 15 months 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 15 months 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:

https://github.com/django/django/pull/991

Test:

from django.core.management.base import BaseCommand
from django.core import mail


class Command(BaseCommand):
    help = 'Test for https://code.djangoproject.com/ticket/20194'

    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()
        conn.open()
        sent_count = conn.send_messages(email_messages)
        conn.close()
        print("Sent: %d" % sent_count)
        return ''

comment:3 Changed 15 months 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 15 months ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 12 months 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.