'Encode the specified django.core.mail.message.EmailMessage, then decode
it using Python\'s email.parser module and, for each attachment of the
message, return a list of tuples with (filename, content, mimetype).'

def get_decoded_attachments(self, django_message):

    msg_bytes = django_message.message().as_bytes()
    email_message = message_from_bytes(msg_bytes)
    def iter_attachments():
        for i in email_message.walk():
            content_disposition = i.get('content-disposition', '').split(';')[0].lower()
            if (content_disposition == 'attachment'):
                filename = i.get_filename()
                content = i.get_payload(decode=True)
                mimetype = i.get_content_type()
                (yield (filename, content, mimetype))
    return list(iter_attachments())
