#23063: send email 1.6.5 OK, 1.7c1 malformed packet in wireshark
-------------------------------------+-------------------------------------
     Reporter:  contact@…            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Core (Mail)          |                  Version:  1.7
     Severity:  Normal               |               Resolution:
     Keywords:  send_mail, smtp,     |             Triage Stage:  Accepted
  malformed, packet                  |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by apollo13):

 New patch:
 {{{
 diff --git a/django/core/mail/backends/smtp.py
 b/django/core/mail/backends/smtp.py
 index 4c41eb8..620168e 100644
 --- a/django/core/mail/backends/smtp.py
 +++ b/django/core/mail/backends/smtp.py
 @@ -120,7 +120,7 @@ class EmailBackend(BaseEmailBackend):
                        for addr in email_message.recipients()]
          message = email_message.message()
          try:
 -            self.connection.sendmail(from_email, recipients,
 message.as_bytes())
 +            self.connection.sendmail(from_email, recipients,
 message.as_bytes(linesep='\r\n'))
          except smtplib.SMTPException:
              if not self.fail_silently:
                  raise
 diff --git a/django/core/mail/message.py b/django/core/mail/message.py
 index da9891f..f339102 100644
 --- a/django/core/mail/message.py
 +++ b/django/core/mail/message.py
 @@ -139,7 +139,7 @@ class MIMEMixin():
      if six.PY2:
          as_bytes = as_string
      else:
 -        def as_bytes(self, unixfrom=False):
 +        def as_bytes(self, unixfrom=False, linesep='\n'):
              """Return the entire formatted message as bytes.
              Optional `unixfrom' when True, means include the Unix From_
 envelope
              header.
 @@ -149,7 +149,7 @@ class MIMEMixin():
              """
              fp = six.BytesIO()
              g = generator.BytesGenerator(fp, mangle_from_=False)
 -            g.flatten(self, unixfrom=unixfrom)
 +            g.flatten(self, unixfrom=unixfrom, linesep=linesep)
              return fp.getvalue()
 }}}

 This is the most backwardscompatible approach I could come up with.

--
Ticket URL: <https://code.djangoproject.com/ticket/23063#comment:33>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/077.a201aebf81d068cee8e85fd795e74583%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to