[英]Mandrill API to send email with recipients(cc), but It also send mail to recipients(cc) as 'TO' using Django==1.11.10
[英]send pygal line chart in mail using mandrill api
從上周開始,我試圖使用pygal python庫創建一個簡單的折線圖,並使用mandrill api發送結果郵件。
我將渲染結果放置在pygal文檔中指定的“ figure”標簽中。
我可以發送電子郵件,但完全空白。
以下是我的代碼。
line_chart = pygal.Line()
line_chart.title = 'Browser usage evolution (in %)'
line_chart.x_labels = map(str, range(2002, 2013))
line_chart.add('Firefox', [None, None, 0, 16.6, 25, 31, 36.4, 45.5, 46.3, 42.8, 37.1])
line_chart.add('Chrome', [None, None, None, None, None, None, 0, 3.9, 10.8, 23.8, 35.3])
line_chart.add('IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6, 54.7, 44.8, 36.2, 26.6, 20.1])
line_chart.add('Others', [14.2, 15.4, 15.3, 8.9, 9, 10.4, 8.9, 5.8, 6.7, 6.8, 7.5])
chart = line_chart.render()
html = """<html>
<head>
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/svg.jquery.js"></script>
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js"></script>
</head>
<body>
<figure>"""
html += chart
html += "</figure></body></html>"
try:
mandrill_client = mandrill.Mandrill(MANDRILL_API_KEY)
message = {}
message['from_email'] = constants.REPORTS
message['subject'] = 'Sending report of non reporting gps devices.'
for email_id in send_to:
to_dict = {}
to_dict['email'] = str(email_id)
to.append(to_dict)
message['to'] = to
message['preserve_recipients'] = True
message['html'] = str(html)
result = mandrill_client.messages.send(message=message, async=False, ip_pool=constants.MANDRILL_MAIN_POOL, send_at=constants.SEND_AT)
except mandrill.Error, e:
print 'A mandrill error occurred: %s - %s' % (e.__class__, e)
有人可以告訴我我在做什么錯嗎?
電子郵件客戶端無法呈現Javascript。 您要附加的圖表需要由pygal.js呈現,由於電子郵件無法呈現Javascript,該圖表將失敗。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.