Dustin Oprea
Dustin Oprea

Reputation: 10256

Attachments in emails sent from Python are not being seen

I can see them in Gmail and it sounds like there's no problem in Outlook, but my Mailspring client can't see them nor can Thunderbird. Not sure why. The attachments are in the message content and their headers seem fine.

mail headers

This is the code that assembles the message:

for filename, data in attached_data.items():

    mime_type = magic.from_buffer(data, mime=True)
    major_type, minor_type = mime_type.split('/', 1)

    if major_type == 'application':
        attachment = \
            email.mime.application.MIMEApplication(
                data,
                minor_type)

    elif major_type == 'image':
        attachment = \
            email.mime.image.MIMEImage(
                data,
                minor_type)

    else:
        attachment = \
            email.mime.application.MIMEApplication(
                data)

    attachment.add_header(
        "Content-Disposition",
        "attachment",
        filename=filename)

    msg.attach(attachment)


raw_message = msg.as_string()

This happens with every message. There appears to be no option to block images for unknown senders, nor would I expect it to be done without displaying some visible warning about it. What am I missing?

Upvotes: 1

Views: 306

Answers (1)

david
david

Reputation: 2638

Try showing the hidden attachments:

"Because this view mode is not needed by most users and could be confusing to some, it is disabled by default. To enable it, use the Config Editor to change the preference mailnews.display.show_all_body_parts_menu to true."

https://support.mozilla.org/en-US/kb/configuration-options-attachments

Mostly images aren't shown as attachments: they are displayed. It's easy for programs to get confused about this: mime isn't even as standard as the HTTP/HTML from which it is derived.

Upvotes: 1

Related Questions