亚马逊ses附件对@yahoo接收器不可见,但为@gmail

时间:2015-11-26 09:49:12

标签: amazon-web-services amazon-ses

我试图在python中调用Amazon Ses发送带附件的电子邮件。如果接收者是@gmail帐户,它可以正常工作。但是,如果接收方是@yahoo或其他一些电子邮件服务,则不会发送附件。我做错了什么?

def build_msg_html(cls, sender, receiver, subject, txt, html, attachment):
    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = sender
    msg['To'] = receiver
    msg.attach(MIMEText(txt, 'plain', 'utf-8'))
    if html is not None:
        msg.attach(MIMEText(html, 'html', 'utf-8'))
    if attachment is not None:
        msg.attach(MIMEApplication(
            attachment.file.read(),
            Content_Disposition='attachment; filename="%s"' % attachment.filename,
            Name=attachment.filename
        ))
    return msg

1 个答案:

答案 0 :(得分:0)

我设法通过遵循此问题Java Mail attachment not shown in outlook的答案解决了这个问题: 我将MIMEMultipart('alternative')替换为MIMEMultipart()