本文整理汇总了Python中string.Template.sendmail方法的典型用法代码示例。如果您正苦于以下问题:Python Template.sendmail方法的具体用法?Python Template.sendmail怎么用?Python Template.sendmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string.Template
的用法示例。
在下文中一共展示了Template.sendmail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Template
# 需要导入模块: from string import Template [as 别名]
# 或者: from string.Template import sendmail [as 别名]
mailbody = s.substitute(userFirst=userdata['firstname'].capitalize(),
reservation_id=reservation['reservation_id'],
title=reservation['title'],
description=reservation['description'],
begin=reservation['begin'], end=reservation['end'],
image=reservation['image_type'],
numsites=len(reservation['sites']))
for site in reservation["sites"]:
notes = ""
if site['admin_description'] != 'None':
notes = "Admin notes: %s" % site['admin_description']
s = Template(SITE_TEMPLATE)
site_status = site_status_changes[site['site_id']]['was']
if site_status_changes[site['site_id']]['now']:
site_status = "%s (was %s)" % (
site_status_changes[site['site_id']]['now'],
site_status_changes[site['site_id']]['was'])
mailbody += s.substitute(siteName=site['site_name'], status=site_status,
cpus=site['CPU'], memory=site['memory'],
notes=notes)
msg = MIMEText(mailbody)
msg['Subject'] = 'Update: PRAGMA Cloud Scheduler reservation #%s' % \
reservation['reservation_id']
msg['From'] = '[email protected]%s' % config.get("Server", "hostname")
msg['To'] = userdata['email_address']
s = smtplib.SMTP('localhost')
s.sendmail(msg['From'], [msg['To']], msg.as_string())
s.quit()