发送html模板时未显示烧瓶邮件图像

时间:2020-06-20 17:23:21

标签: python html flask flask-mail

我对flask-email非常陌生,现在我尝试发送html电子邮件,该电子邮件的图像位于模板主体内,但是当在电子邮件上打开此html时,该图像未显示,所以我该如何解决它。

这是我的示例代码。

    msg = Message('Test', sender='sender_email',  recipients=['receiver_email'])

    msg.html=render_template('Email.html')
    mail.send(msg)
    return render_template('Email.html')

这是我在Email.html中的img标签

<img src="{{ url_for('static', filename='images/logo.png', _external=True) }}">
                

1 个答案:

答案 0 :(得分:2)

该网站上线了吗?如果不是,它将显示指向本地主机映像的链接,但是只有您可以在网络上打开它。这就是为什么您无法在电子邮件客户端中看到它的原因。将网站发布到服务器或域后,链接将公开,您将看到图像。