#29140: Exception sending EmailMessage with body=None
------------------------------------------+------------------------
               Reporter:  Alex Schokking  |          Owner:  nobody
                   Type:  Uncategorized   |         Status:  new
              Component:  Core (Mail)     |        Version:  1.11
               Severity:  Normal          |       Keywords:
           Triage Stage:  Unreviewed      |      Has patch:  0
    Needs documentation:  0               |    Needs tests:  0
Patch needs improvement:  0               |  Easy pickings:  1
                  UI/UX:  0               |
------------------------------------------+------------------------
 This had been working fine on 1.9 but when we upgraded to 1.11 instantly
 started hitting an exception when django tries to call splitlines on the
 None body without checking if there's a value there to split on.

 {{{
  File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/message.py", line 348, in send
     return self.get_connection(fail_silently).send_messages([self])
   File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/backends/smtp.py", line 111, in send_messages
     sent = self._send(message)
   File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/backends/smtp.py", line 125, in _send
     message = email_message.message()
   File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/message.py", line 307, in message
     msg = SafeMIMEText(self.body, self.content_subtype, encoding)
   File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/message.py", line 214, in __init__
     MIMEText.__init__(self, _text, _subtype=_subtype, _charset=_charset)
   File "/usr/lib/python2.7/email/mime/text.py", line 30, in __init__
     self.set_payload(_text, _charset)
   File "/usr/local/lib/python2.7/dist-
 packages/django/core/mail/message.py", line 224, in set_payload
     for l in payload.splitlines()
 AttributeError: 'NoneType' object has no attribute 'splitlines'
 }}}


 We've hacked around it by passing in an empty string instead but would
 probably be more elegant for this `has_long_lines` logic to check if
 there's a value instead.

 For context we're not passing in a body because we're attaching the
 plaintext and html versions of the email as a SafeMIMEMultipart
 attachment.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29140>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.f9cbb016ae1242894b9dfe489ed529d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to