我使用this snippet將電子郵件圖像嵌入到django中。但我想用這個圖片作爲背景。 我使用這個線在我的模型:在django中使用電子郵件圖像作爲背景嵌入
img_content_id = 'standard.jpg'
img_data = open('mypath/static/images/standard.jpg', 'rb').read()
msg = MIMEMultipart(_subtype='related')
body = 'cid:%s' % img_content_id
html_content = render_to_string('email/mail.html',
{'email': self.invited, 'url': url, 'current_site':current_site, 'body':body})
msg = EmailMessage(subject, html_content, settings.DEFAULT_FROM_EMAIL, [self.invited])
msg.content_subtype = "html"
msg = email_embed_image(msg, img_content_id, img_data)
msg.send()
而且在模板使用這樣的:
<table border="0" cellpadding="0" cellspacing="0" background="{{ body }}">
但是我對郵件的兩個圖像。 (一位作爲公民)。在django中使用電子郵件圖像嵌入作爲背景的正確方法是什麼?
在此先感謝
感謝Guillaume –