我正在尝试将渲染的图像发送到电子邮件正文中,而不是从.jpg文件,而是从url链接。
下面的代码发送的是url,而不是渲染的图像。
@celery.task(queue='email')
def send_async_email(to, subject, sender, image, **kwargs):
msg = Message(subject=subject,
sender=sender,
recipients=to)
image = "https://i.scdn.co/image/26816116d2e836116ccf596a855160be5657d936"
msg.body = "testing"
msg.html = "<img src={}</img>".format(image)
mail.send(msg)
return {'Status': 'mail sent!'}如何从链接发送渲染图像?
发布于 2019-12-02 10:19:40
将任务指向具有以下条件的html模板:
<img src="{{image}}" height="42" width="42" class="bobby img-circle">然后以kwargs的形式传递image ( url)
msg.html = render_template('new_consumer.html',**kwargs)
mail.send(msg)上面的方法应该是可行的。
https://stackoverflow.com/questions/59131123
复制相似问题