【问题标题】:Mail sent using send_mail() [Python - Django] does not send embedded images使用 send_mail() [Python - Django] 发送的邮件不发送嵌入的图像
【发布时间】:2015-12-17 13:32:42
【问题描述】:

好的,下面是我的电子邮件模板:

<html>

<head>
{% load staticfiles %}

</head>

<body>

<h2>Welcome!</h2>
<img src = "{% static 'app/images/logo1.png' %}" style = "position: absolute; left: 5%; height: 100%; width:50%;" />


<div style = "position: absolute; top: 100%; left: 0%; height: 10%; width: 100%: color: #006699;"></div>

<img src = "{% static 'app/images/content.png' %}" style = "position: absolute; left:0%; top: 110%; height: 100%; width: 60%">
</img>
</body>

</html>

以下是我的电子邮件功能:

        html_template = render_to_string('email_template.html', {})

        try:
            send_mail(
                'Title',
                'Plaintext Version Goes Here',
                'sender',
                [email],
                html_message=html_template,
            )
        except:
            return HttpResponse("No!")

当我只发送邮件时欢迎!打印在邮件中。图像不显示。知道为什么吗?

提前致谢!

【问题讨论】:

    标签: python html django email


    【解决方案1】:

    我解决了这个问题,指定了完整的 STATIC_URL,例如 http://localhost:8000/static/ 部署后,我更改为域。 尝试将其更改为

    <img src = "http://localhost:8000/static/app/images/logo1.png" style = "position: absolute; left: 5%; height: 100%; width:50%;" />
    

    我找到了这个possible other solution,但我没有尝试过。

    【讨论】:

    • 如果他正在开发并正在测试电子邮件,为什么不呢?
    • 对不起。从来都不是一个强烈的词。不过不推荐。
    猜你喜欢
    • 2017-03-30
    • 2020-08-09
    • 2019-12-12
    • 1970-01-01
    • 2013-09-24
    • 2010-11-09
    • 2010-11-01
    • 1970-01-01
    相关资源
    最近更新 更多