[Django] #34126: Exception sending EmailMessage with html_message=True

5 views
Skip to first unread message

Django

unread,
Oct 28, 2022, 8:43:03 AM10/28/22
to django-...@googlegroups.com
#34126: Exception sending EmailMessage with html_message=True
----------------------------------------+---------------------------
Reporter: openHBP | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 4.1
Severity: Normal | Keywords: send_mail
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+---------------------------
{{{
from django.core.mail import send_mail

send_mail(
'Subject here',
'<p>Here is the message.</p>',
'fr...@example.com',
['t...@example.com'],
fail_silently=False,
html_message=True
)
}}}
{{{
Traceback (most recent call last):
File "zcheck/send_mail.py", line 9, in <module>
send_mail(
File ".venv/lib/python3.9/site-packages/django/core/mail/__init__.py",
line 61, in send_mail
return mail.send()
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 284, in send
return self.get_connection(fail_silently).send_messages([self])
File ".venv/lib/python3.9/site-
packages/django/core/mail/backends/smtp.py", line 109, in send_messages
sent = self._send(message)
File ".venv/lib/python3.9/site-
packages/django/core/mail/backends/smtp.py", line 123, in _send
message = email_message.message()
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 247, in message
msg = self._create_message(msg)
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 440, in _create_message
return self._create_attachments(self._create_alternatives(msg))
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 450, in _create_alternatives
msg.attach(self._create_mime_attachment(*alternative))
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 365, in _create_mime_attachment
attachment = SafeMIMEText(content, subtype, encoding)
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 159, in __init__
MIMEText.__init__(self, _text, _subtype=_subtype, _charset=_charset)
File "/home/pat/.pyenv/versions/3.9.7/lib/python3.9/email/mime/text.py",
line 42, in __init__
self.set_payload(_text, _charset)
File ".venv/lib/python3.9/site-packages/django/core/mail/message.py",
line 169, in set_payload
for line in payload.splitlines()
AttributeError: 'bool' object has no attribute 'splitlines'
}}}

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

Django

unread,
Oct 28, 2022, 8:58:38 AM10/28/22
to django-...@googlegroups.com
#34126: Exception sending EmailMessage with html_message=True
------------------------------+--------------------------------------
Reporter: openHBP | Owner: nobody
Type: Bug | Status: closed

Component: Core (Other) | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: send_mail | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Alex Morega):

* status: new => closed
* resolution: => invalid


Comment:

The `html_message` argument is meant to contain the HTML version of the
email, it's not a boolean flag. The `message` argument should be the
plaintext version.

https://docs.djangoproject.com/en/stable/topics/email/#send-mail

{{{
send_mail(
'Subject here',
'Here is the message.',


'fr...@example.com',
['t...@example.com'],
fail_silently=False,

html_message='<p>Here is the message.</p>'
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34126#comment:1>

Reply all
Reply to author
Forward
0 new messages