'Regression test for #9367'

def test_attachments(self):

    headers = {'Date': 'Fri,    09    Nov    2001    01:08:47    -0000', 'Message-ID': 'foo'}
    (subject, from_email, to) = ('hello', 'from@example.com', 'to@example.com')
    text_content = 'This    is    an    important    message.'
    html_content = '<p>This    is    an    <strong>important</strong>    message.</p>'
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to], headers=headers)
    msg.attach_alternative(html_content, 'text/html')
    msg.attach('an    attachment.pdf', '%PDF-1.4.%...', mimetype='application/pdf')
    msg_str = msg.message().as_string()
    message = email.message_from_string(msg_str)
    self.assertTrue(message.is_multipart())
    self.assertEqual(message.get_content_type(), 'multipart/mixed')
    self.assertEqual(message.get_default_type(), 'text/plain')
    payload = message.get_payload()
    self.assertEqual(payload[0].get_content_type(), 'multipart/alternative')
    self.assertEqual(payload[1].get_content_type(), 'application/pdf')
