本文整理匯總了Python中turbomail.Message.sender方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.sender方法的具體用法?Python Message.sender怎麽用?Python Message.sender使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類turbomail.Message
的用法示例。
在下文中一共展示了Message.sender方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: send_email
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import sender [as 別名]
def send_email(sender, truename, emails, title, plain, rich):
"""
notify using email
sending alert email to followers
"""
"""
rand send email
"""
day_str = datetime.datetime.strftime(datetime.datetime.today(), "%d%H")
sender = "Knowing <Knowing-noreply-%[email protected]>" % day_str
logging.debug("Send email %s" % ", ".join((truename, str(emails), title, plain, rich)))
try:
mail = Message()
mail.subject = title
mail.sender = sender
mail.to = u"%s <%s>" % (truename, emails[0])
if len(emails) > 1:
mail.cc = u",".join(emails[1:])
mail.encoding = "utf-8"
mail.plain = plain
mail.rich = rich
mail.send()
except Exception, e:
logging.exception("Fail to send email.")
示例2: send_email
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import sender [as 別名]
def send_email(self, imgs1, imgs2):
day_str = datetime.datetime.strftime(datetime.datetime.today(),"%Y-%m-%d")
mail = Message()
mail.subject = u'#%s#SOS日報' % day_str
mail.sender = '[email protected]'
#mail.to = self.config['sos_receiver']
self.owner.append('[email protected]')
self.owner.append('[email protected]')
self.owner.append('[email protected]')
self.owner.append('[email protected]')
self.owner.append('[email protected]')
self.owner.append('[email protected]')
mailto = list(set(self.owner))
mail.to = ','.join(mailto)
mail.encoding = 'utf-8'
mail.plain = u'本郵件由Knowing係統自動發送,如有疑問請聯係運維團隊,謝謝。'
title_style = 'font-size: 15px; font-weight: bold; padding-top: 10px;'
items = [u'<p>Hi All,</p><p>本郵件由Knowing係統自動發送,實時數據可<a href="http://knowing.corp.126.com/monitor/341">點此查看</a>,如有疑問請聯係運維團隊,謝謝。</p>']
for img in imgs1:
items.append(u'<div style="%s">%s</div><p><img src="cid:%d.png"></p>' % (title_style, img[1], img[0]))
mail.embed(img[2], u'%d.png' % img[0])
items.append('<table border="0" cellspacing="0" cellpadding="0" width="1024">')
for i in xrange(0, len(imgs2), 2):
items.append(u'<tr><td><div style="%s">%s</div><img src="cid:%d.png"></td>' % (title_style, imgs2[i][1], imgs2[i][0]))
mail.embed(imgs2[i][2], u'%d.png' % imgs2[i][0])
if i + 1 < len(imgs2):
items.append(u'<td valign="bottom"><div style="%s">%s</div><img src="cid:%d.png"></td></tr>' % (title_style, imgs2[i+1][1], imgs2[i+1][0]))
mail.embed(imgs2[i+1][2], u'%d.png' % imgs2[i+1][0])
else:
items.append(u'<td> </td></tr>')
items.append('</table>')
mail.rich = u''.join(items)
print 'Sending email...'
mail.send()