本文整理匯總了Python中turbomail.Message.encoding方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.encoding方法的具體用法?Python Message.encoding怎麽用?Python Message.encoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類turbomail.Message
的用法示例。
在下文中一共展示了Message.encoding方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: feedback
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [as 別名]
def feedback(self):
try:
vars = self.request.json_body
sanitized_description = bleach.clean(vars['description'])
html_body = u"<h3>L\'utilisateur <a href=\"mailto:{0}\">{0}</a> " \
u"a remarqué le problème suivant:</h3><p>{1}</p>" \
u"<p><a href=\"{3}\">Ouvrir le lien vers la carte</a></p>" \
u"<h3>La couche suivante est concernée:</h3>" \
u"<p>{2}</p>" \
.format(vars['email'],
sanitized_description,
vars['layer'],
vars['url']
)
support_email = self.config.get('feedback.support_email',
'[email protected]')
message = Message(
author=vars['email'],
to=support_email,
subject=u'Un utilisateur a signalé un problème')
message.plain = html_body
message.rich = html_body
message.encoding = 'utf-8'
message.send()
except Exception as e:
log.exception(e)
return HTTPNotFound()
return {'success': True}
示例2: send_email
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [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.")
示例3: send
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [as 別名]
def send(self, mfrom, mto, subject, html_part):
interface.start(self.turbomail_config)
message = Message(mfrom, mto, subject=subject)
#message.cc =('idea','[email protected]')
message.encoding = 'gb2312'
message.plain = "Mabotech"
message.rich = html_part
message.send()
interface.stop()
示例4: __notify
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [as 別名]
def __notify(chart, message):
"""
notify using email
chart: Charts data row
message: message body
sending alert email to owner and followers
"""
config = __get_config('webapp')
mail_config = {}
mail_config['mail.on'] = config['turbomail']['enable']
mail_config['mail.manager'] = config['turbomail']['manager']
mail_config['mail.transport'] = config['turbomail']['transport']
mail_config['mail.smtp.server'] = config['turbomail']['server']
sender = config['turbomail']['sender']
"""
rand send email
"""
day_str = datetime.datetime.strftime(datetime.datetime.today(),"%d%H")
sender = 'Knowing <Knowing-noreply-%[email protected]>' % day_str
subject = message
u = session.query(Users).filter(Users.username == chart.owner)
addressee = ''
if u:
for i in u:
if i.mobile:
addressee = i.mobile + '@139.com'
else:
logger.warning("no mobile set for user \"%s\"" % i.username)
return
interface.start(mail_config)
now = str(datetime.datetime.now())[0:19]
chart_url = 'http://knowing.corp.anjuke.com/chart/%d' % chart.id
html_part = u"<html><body><h1>Look, %s</h1><p>時間: %s</p><p>詳細信息: %s</p><p><a href='%s'>%s</a></p><p>This mail is sent by Knowing</p></body></html>"
html_part %= (chart.name, now, message, chart_url, chart_url)
text_part = u"[critical] 時間: %s 詳細信息: %s"
text_part %= (now, message)
mail = Message(sender, addressee, subject)
mail.encoding = 'utf-8'
mail.plain = message
mail.rich = html_part
flag = mail.send()
示例5: send_email
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [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()
示例6: comment
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [as 別名]
def comment(self):
id = self.request.matchdict.get("map_id")
map = Map.get(id)
if map is None:
return HTTPNotFound()
# read the map author's email address from LDAP
author = self.get_user_info(map.user_login)
comment = self.request.params.get('comment')
if self.request.params.get('name') and self.request.params.get('mail'):
# feedback anonymous user
feedback_name = self.request.params.get('name')
feedback_mail = self.request.params.get('mail')
else:
# feedback loggedin user
user = self.get_user_info(self.request.user.username)
feedback_name = user[0]
feedback_mail = user[1]
try:
message = Message(
author='[email protected]',
to=author[1],
bcc='[email protected]',
subject=(u'comment_email_subject')
% {'title': map.title +
" ( http://map.geoportail.lu/?map_id="+map.uuid+" ) ",
'feedback_name': feedback_name,
'feedback_mail': feedback_mail},
plain=comment)
except:
traceback.print_exc(file=sys.stdout)
return HTTPNotFound()
message.encoding = 'utf-8'
message.send()
return {'success': True}
示例7: feedbackanf
# 需要導入模塊: from turbomail import Message [as 別名]
# 或者: from turbomail.Message import encoding [as 別名]
def feedbackanf(self):
try:
vars = self.request.json_body
map_id = self.config['anf']['map_id']
map = self.request.db_mymaps.query(Map).get(map_id)
if map is None:
return HTTPNotFound()
sanitized_description = bleach.clean(vars['description'])
sanitized_lot = bleach.clean(vars['lot'])
message = u"L\'utilisateur <a href=\"mailto:{0}\">{0}</a> " \
u"a remarqué le problème suivant:<p>{1}</p> sur le lot" \
u" {6}" \
.format(vars['email'],
sanitized_description,
vars['layer'],
vars['url'],
vars['name'],
"http://map.geoportail.lu?map_id=" + map_id,
sanitized_lot,
)
features = vars['features'].\
replace(u'\ufffd', '?')
feature_collection = geojson.\
loads(features, object_hook=geojson.GeoJSON.to_instance)
for feature in feature_collection['features']:
obj = None
try:
obj = Feature(feature)
obj.name = vars['name'] + " : " + sanitized_lot
obj.description = message
except Exception as e:
log.exception(e)
if obj is not None:
map.features.append(obj)
self.request.db_mymaps.commit()
html_body = u"<h3>L\'utilisateur <a href=\"mailto:{0}\">{4}</a> " \
u"a remarqué le problème suivant:</h3><p>{1}</p>" \
u" sur le lot {6}" \
u"<p><a href=\"{3}\">Ouvrir le lien vers la carte</a></p>" \
u"<p>L'incident a été enregistré dans cette <a href=\"{5}\">" \
u"mymaps</a>:</p>" \
.format(vars['email'],
sanitized_description,
vars['layer'],
vars['url'],
vars['name'],
"http://map.geoportail.lu?map_id=" + map_id,
sanitized_lot,
)
support_email = self.config['anf']['email']
message = Message(
author=vars['email'],
to=support_email,
subject=u'Un utilisateur a signalé un problème')
message.plain = html_body
message.rich = html_body
message.encoding = 'utf-8'
message.send()
except Exception as e:
log.exception(e)
return HTTPNotFound()
return {'success': True}