繁体   English   中英

看不到从 Python 发送的电子邮件中的附件

[英]Attachments in emails sent from Python are not being seen

我可以在 Gmail 中看到它们,听起来 Outlook 中没有问题,但我的 Mailspring 客户端看不到它们,Thunderbird 也看不到。 不知道为什么。 附件在邮件内容中,它们的标题看起来很好。

邮件标题

这是组装消息的代码:

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()

每条消息都会发生这种情况。 似乎没有选项可以阻止未知发件人的图像,我也不希望它在不显示一些可见警告的情况下完成。 我错过了什么?

尝试显示隐藏的附件:

“因为大多数用户不需要这种查看模式,并且可能会让某些人感到困惑,所以默认情况下它是禁用的。要启用它,请使用配置编辑器将首选项 mailnews.display.show_all_body_parts_menu 更改为 true。”

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

大多数图像不显示为附件:它们被显示。 程序很容易对此感到困惑:mime 甚至不像衍生它的 HTTP/HTML 那样标准。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM