簡體   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