﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26344	EmailMultiAlternatives ignores alternatives when it has attachments and body is empty	Alvin Lindstam	nobody	"It seems like django.core.mail.EmailMultiAlternatives does not include the body or the alternative if the body is falsey and if it has attachments.
 
{{{
    >>> from django.core.mail import EmailMultiAlternatives
    >>> m = EmailMultiAlternatives(body="""")
    >>> m.attach_alternative(""<img src='https://example.com/example_image.png'>"", ""text/html"")
    >>> ""example_image.png"" in m.message().as_string()
    True
    >>> m.attach('example.txt', ""example attachment"", 'text/plain')
    >>> ""example_image.png"" in m.message().as_string()
    False
    >>> print(m.message().as_string())
    Content-Type: multipart/mixed; boundary=""===============2599669765216026223==""
    MIME-Version: 1.0
    Subject: 
    From: webmaster@localhost
    To: 
    Date: Thu, 10 Mar 2016 14:31:12 -0000
    Message-ID: <20160310143112.53907.61069@236.1.168.192.in-addr.arpa>

    --===============2599669765216026223==
    MIME-Version: 1.0
    Content-Type: text/plain; charset=""utf-8""
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment; filename=""example.txt""

    example attachment
    --===============2599669765216026223==--

}}}

It is probably because of [https://github.com/django/django/blob/53ccffdb8c8e47a4d4304df453d8c79a9be295ab/django/core/mail/message.py#L351 this] conditional. It checks if body is truthy, even though it is sometimes called from EmailMultiAlternatives with a msg that should be included."	Bug	closed	Core (Mail)	1.9	Normal	fixed			Ready for checkin	1	0	0	0	0	0
