本文整理汇总了Python中turbomail.Message.rich方法的典型用法代码示例。如果您正苦于以下问题:Python Message.rich方法的具体用法?Python Message.rich怎么用?Python Message.rich使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turbomail.Message
的用法示例。
在下文中一共展示了Message.rich方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_mail
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def send_mail(subject='',
to=[],
cc=[],
bcc=[],
template='',
lang='zh',
values={},
ip=ip,
):
interface.start(email_config)
msg = Message(sender_address,
to,
subject,
cc=cc,
bcc=bcc,
plain=subject if template else 'Plain Text',
)
if template:
try:
url_root = request.url_root
except:
url_root = 'http://{}'.format(ip)
if 'http://localhost' in url_root:
url_root = 'http://{}'.format(ip)
msg.rich = render_template('notifications/{}'.format(template),
lang=lang,
url_root=url_root,
**values
)
msg.send()
interface.stop()
示例2: feedback
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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}
示例3: send_email
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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.")
示例4: send
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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()
示例5: __notify
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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()
示例6: forgotaction
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def forgotaction(self):
values = dict(request.params)
del values["action"]
msg = ""
settingsf = file(config["settings_file"], "rb")
session["site_settings"] = pickle.load(settingsf)
settingsf.close()
session.save()
captchres = h.captcha.submit(
values["recaptcha_challenge_field"],
values["recaptcha_response_field"],
"6LepGccSAAAAAMfzDtmvyRjJ7-A1FWuJa5qUTxX2",
session["site_settings"]["ip_address"],
)
if not captchres.is_valid:
c.menu_items = h.top_menu(self.menu_items, _("Customers"))
html = render("/derived/user/forgot.html")
return htmlfill.render(html, values, errors={"captcha": _("Invalid Captcha try again")})
user = Session.query(User).join(User.emails).filter(Email.email_address == values["email"]).one()
confcode = str(uuid.uuid1())
uconf = UserConfirm(user, confcode)
Session.add(uconf)
Session.commit()
message = Message(
session["site_settings"]["forgotpass"],
user.emails[0].email_address,
_("Kazhal trading Reset password"),
encoding="utf-8",
)
msg += _("If you requested a password reset click the below link\n")
##msg += "%s%s"%(request.application_url,h.url(controller='user',action='resetpassEmail',id=user.id,confcode=confcode))
msg += "%s%s" % (
request.application_url,
url(controller="user", action="resetpassEmail", id=user.id, confcode=confcode),
)
c.contents = msg
msgHtml = render(_("/derived/emails/forgotpass.html"))
message.rich = msgHtml
message.plain = msg
message.send()
h.flash(
_(
"An email has been sent to your address.To reset your password check your email and click on the confirm link."
)
)
return redirect(url(controller="user", action="forgot"))
示例7: send_mail
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def send_mail(sender, to, subject, body):
if sender and to and subject and body:
message = Message(author=sender, to=to, subject=subject)
message.rich = body
# TODO: convert mail body to plain
message.plain = 'This mail should be viewed in HTML.'
try:
message.send()
except Exception, msg:
if str(msg) == '[Errno 111] Connection refused':
# caused by connection problem to smtp server
pass
else:
# other error, raise
raise Exception
示例8: send_mail
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def send_mail(subject, body, author=None, **kwargs):
interface.start(email_config)
msg = Message(author or from_, parse_mail(kwargs.get('to', [])), subject)
msg.cc = parse_mail(kwargs.get('cc', []))
bcc = kwargs.get('bcc', [])
if not bcc:
if kwargs.get('debug', True):
bcc = debug_list
msg.bcc = parse_mail(bcc)
msg.plain = subject
msg.rich = body
[msg.attach(attachment) for attachment in kwargs.get('attachments', [])]
msg.send()
interface.stop()
示例9: send_email
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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()
示例10: _send_email_entry
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def _send_email_entry(self, entry):
sender = self.request.registry.settings.get('mail.message.author',
'[email protected]')
recipient = entry.form.user.email
subject = _("[MootiroForm] Entry #%(entry_number)d for the form %(form_title)s") \
% {"entry_number": entry.entry_number,
"form_title": entry.form.name}
labels = [f.label for f in entry.form.fields]
value = [f.value(entry) for f in entry.form.fields]
fields = [{'label': labels[i], 'value': value[i]}
for i in range(len(labels))]
try:
rendered = self.request.registry.settings['genshi_renderer'] \
.fragment('email_entry.genshi',
dict(entry=entry, fields=fields, url=self.url))
except KeyError as e:
raise KeyError("Simon says: cd mootiro_web; git pull; ./setup.py develop")
# TODO: Remove this except block after developers have updated.
# 2011-08-11
msg = Message(sender, recipient, self.tr(subject))
msg.rich = rendered
msg.plain = "We've collected an entry for you form. Visit us to see."
msg.send()
示例11: createcustomer
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def createcustomer(self):
readsettings()
values = dict(request.params)
# create the pending user
captchres = h.captcha.submit(
values["recaptcha_challenge_field"],
values["recaptcha_response_field"],
"6LepGccSAAAAAMfzDtmvyRjJ7-A1FWuJa5qUTxX2",
session["site_settings"]["ip_address"],
)
if not captchres.is_valid:
c.menu_items = h.top_menu(self.menu_items, _("Customers"))
c.came_from = values["came_from"]
if request.GET.get("came_from", None):
h.flash(_("After filling the from you will be sent back to your shopping cart"))
html = render("/derived/user/new.html")
return htmlfill.render(html, values, errors={"captcha": _("Invalid Captcha try again")})
email = Email(email_address=self.form_result["email"], user=None)
phone = Phone(None, str(self.form_result["phone"]), None)
newcustormer = User(
first_name=self.form_result["first_name"],
last_name=self.form_result["last_name"],
user_name=self.form_result["email"],
password=self.form_result["password"],
user_groups=[Session.query(Group).filter_by(group="customer").one()],
SSN=None,
birth_date=None,
balance=0,
photo=None,
addresses=[],
customer_invoices=[],
staff_invoices=[],
emails=[email],
phones=[phone],
deleted=False,
pending=True,
)
# create the confirm link
Session.add(newcustormer)
# confurlcode = randint(10e40,10e49)
confurlcode = str(uuid.uuid1())
confurlcode = "cu-" + confurlcode
conf = UserConfirm(newcustormer, confurlcode)
Session.add(conf)
newcustormer.confirmcode = [conf]
Session.add(newcustormer)
message = Message(
session["site_settings"]["userconf"], self.form_result["email"], _("User registration"), encoding="utf-8"
)
plain = (
"someone (hopefully you) registered an account with"
+ str(request.application_url)
+ "<br/>"
+ "for confirming your registration click the below link"
+ "<br/>"
+ unicode(request.application_url + url(controller="user", action="confirmuser", confirmcode=confurlcode))
+ "<br/>"
+ "After confirmation you can login with your Email address and password."
)
c.confurlcode = confurlcode
registerHtml = render(_("/derived/emails/register.html"))
message.plain = plain
message.rich = registerHtml
try:
message.send()
except:
Session.delete(conf)
Session.delete(phone)
Session.delete(email)
Session.delete(newcustormer)
Session.rollback()
h.flash(_("smtp error try again"))
redirect(values["came_from"])
Session.commit()
h.flash(
_(
"Check your email and click the activation link after logging in you can continue with the purchuse in Shop online page"
)
)
redirect(values["came_from"])
示例12: feedbackanf
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [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}
示例13: savebasket
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import rich [as 别名]
def savebasket(self):
wholesale = False
if "repoze.who.identity" in request.environ:
user = request.environ.get('repoze.who.identity')['user']
wholesale_tag = Session.query(UserTag).filter_by(tag='wholesale').one()
if wholesale_tag in user.tags:
wholesale = True
c.wholesale=True
values = dict(request.params)
action = request.params.getone('action')
del values['action']
if action == _('Remove all items from basket'):
session['basket'] = {}
h.flash(_('All items removed from basket'))
session.save()
redirect(url(controller='product', action='list'))
if action.startswith(_('Remove item')):
gid = int(action.split(' ')[-1])
for item in values:
if item.startswith('quantityid-%s'%gid):
id = int(values[item])
del session['basket'][id]
session.save()
newvalues = remove_item(values,action,'quantity')
newvalues = remove_item(newvalues,action,'quantityid')
return render_editbasket(self.menu_items,values=newvalues)
if action == _('Buy'):
identity = request.environ.get('repoze.who.identity')
if identity is None:
redirect(
url(controller='account',
action='login',
came_from=url(controller='product', action='editbasket')
)
)
schema = Editbasket()
try:
result = schema.to_python(dict(request.params), c)
except Invalid, e:
return render_editbasket(self.menu_items,values=values, errors=variabledecode.variable_encode(
e.unpack_errors() or {},
add_repetitions=False)
)
else:
for i in range(len(result['quantityid'])):
session['basket'][result['quantityid'][i]] = result['quantity'][i]
session.save()
# create pending invoices. email to customer and email to sales
user = Session.query(User).filter_by(id=session['user']).one()
items=[]
dt = datetime.now()
productsmsg= ""
total = 0
invoice = Invoice(dt,user,None,None,0,[],True)
for id in session['basket']:
product = Session.query(Product).filter_by(id=id).one()
quantity = session['basket'][id]
if wholesale:
price = product.wholesale_price
else:
price = product.sell_price
totprice = quantity * price
productsmsg +='<p>'+_('Code')+' :'+str(product.code)+'<br/>'+_('Name')+' :' + product.name+'<br/>'+_('Unit price')+' :'+str(price)+'<br/>'+_('Quantity')+' :'+str(quantity)+'<br/>'+_('Total price')+' :'+str(totprice)+'<br/>'+'</p>'+'<hr>'
total += totprice
item = Invoice_item(product,
invoice,
quantity,
totprice,
unitprice=price
)
items.append(item)
invoice.invoice_items = items
invoice.total_price = total
Session.add(invoice)
#Session.commit()
customer_message = Message(session['site_settings']['invoicealertfrom'],
#user.emails[0].email_address,
"[email protected]",
_("your order details from Kazhal"),
encoding='utf-8')
plain = _("You placed an order of the following items with Kazhal")+' :'+ productsmsg + "<br/>"+ _("Total price")+' :'+str(total) +"<br/>"+_("our staff will contact you to confirm the purchase.<br/>Thank you.<br/>Kazhal")
c.usermsg = _("You placed an order of the following items with Kazhal")+_("our staff will contact you to confirm the purchase.<br/>Thank you.<br/>Kazhal")
c.user = user
c.invoice = invoice
c.total = total
customerHtml = render(_('/derived/emails/customer_invoice.html'))
customer_message.rich = customerHtml
customer_message.plain = plain
splain = _("User")+u' :'+user.user_name +u'<br/>'+_("Phone")+u' :'+unicode([int(phone.phone_number) for phone in user.phones])[1:-1]+u'<br/>'+ _("Items")+u' :'+productsmsg+u'<br/>'+_("Total price")+u" :"+unicode(total)+u'<br/>'
splain += unicode(h.link_to(_("Click here to confirm the order."),((request.application_url)+url(controller='invoice',action='confirm',id=invoice.id))))
c.usermsg = unicode(h.link_to(_("Click here to confirm the order."),((request.application_url)+url(controller='invoice',action='confirm',id=invoice.id))))
salesHtml = render(_('/derived/emails/customer_invoice.html'))
sales_messages=[]
for email in session['site_settings']['invoicealertmail'].split(','):
#.........这里部分代码省略.........