本文整理汇总了Python中turbomail.Message.plain方法的典型用法代码示例。如果您正苦于以下问题:Python Message.plain方法的具体用法?Python Message.plain怎么用?Python Message.plain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turbomail.Message
的用法示例。
在下文中一共展示了Message.plain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def new(self):
user = None
if "repoze.who.identity" in request.environ:
user = request.environ.get('repoze.who.identity')['user']
values= dict(request.params)
for email in session['site_settings']['contactusmail'].split(','):
if user:
message = Message(user.emails[0].email_address,
email,
"contactus from %s"%values['email'],
encoding='utf-8')
message.plain = "%s"%values['message']
message.send()
else:
message = Message(values['email'],
email,
"contactus asked to reply to %s"%values['email'],
encoding='utf-8')
message.plain = "%s"%values['message']
message.send()
h.flash(_("Your message was sent successfully."))
return redirect(h.url(controller='contactus',action='index'))
示例2: feedback
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [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: request_enable
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def request_enable(self, id=None):
if id is None:
abort(404)
user = h.get_object_or_404(User, id=id)
admins = User.query.filter_by(superuser=True).all()
app_name = config['application_name']
from_addr = config['error_email_from']
suffix = config['email_suffix']
subject = "New user request for "+app_name
requested_courses = request.params["requested_course_name"]
user.requested_courses = requested_courses
if not request.environ.has_key('REMOTE_ADDR'):
request.environ['REMOTE_ADDR'] = "127.0.0.1" #must be debugging locally on paste
ip = request.environ['REMOTE_ADDR']
for admin in admins:
to_addr = admin.name + "@" + suffix
body = "Dear "+admin.name+",\n\nA new user has requested an account on "+app_name+".\n\nDetails:\n\n"
body += "username: "+user.name+"\n"
body += "requested course(s): "+requested_courses+"\n"
body += "timestamp: "+str(datetime.datetime.today())+"\n"
body += "remote ip: "+ip+"\n\n\n"
body += "Please login to https://comoto.cs.illinois.edu to approve or deny this request\n\n"
body += "Thanks\n\n"
body += "The "+app_name+" Team\n\n\n\n"
body += "Please do not reply to this message, as this account is not monitored"
message = Message(from_addr, to_addr, subject)
message.plain = body
message.send()
session['flash'] = "Request Acknowledged"
session.save()
Session.commit()
redirect_to(controller="login", action="index", id=None)
示例4: test_message_instantiation_with_positional_parameters
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_message_instantiation_with_positional_parameters(self):
message = Message('[email protected]', '[email protected]', 'Test')
message.plain = 'Hello world!'
msg_string = str(message)
self.failUnless('From: [email protected]' in msg_string)
self.failUnless('To: [email protected]' in msg_string)
self.failUnless('Subject: Test' in msg_string)
示例5: test_mail_encoding_is_used_as_fallback
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_mail_encoding_is_used_as_fallback(self):
interface.config['mail.encoding'] = 'ISO-8859-1'
message = Message('[email protected]', '[email protected]', 'Test')
message.plain = 'Hello world!'
msg = email.message_from_string(str(message))
self.assertEqual('text/plain; charset="iso-8859-1"', msg['Content-Type'])
self.assertEqual('quoted-printable', msg['Content-Transfer-Encoding'])
示例6: _reset
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def _reset(self, username=None):
username = username or request.environ.get('REMOTE_USER', False)
if not username:
abort(401)
try:
user = h.get_user(username)
except:
abort(400)
new_password = user.reset_password()
msg = Message("[email protected]", user.email,
"InPhO password reset")
msg.plain = """
%(name)s, your password at the Indiana Philosophy Ontology (InPhO) has been changed to:
Username: %(uname)s
Password: %(passwd)s
The Indiana Philosophy Ontology (InPhO) Team
[email protected]
""" % {'passwd' : new_password,
'uname' : user.username,
'name' : user.fullname or user.username or ''}
msg.send()
Session.commit()
h.redirect(h.url(controller='account', action='reset_result'))
示例7: submit
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def submit(self):
'''
This function validates the submitted registration form and creates a
new user. Restricted to ``POST`` requests. If successful, redirects to
the result action to prevent resubmission.
'''
user = User(
self.form_result['username'],
self.form_result['password'],
email=self.form_result['email'],
first_area_id=self.form_result['first_area'],
first_area_level=self.form_result['first_area_level'],
second_area_id=self.form_result['second_area'],
second_area_level=self.form_result['second_area_level']
)
Session.add(user)
Session.commit()
msg = Message("[email protected]", self.form_result['email'],
"InPhO registration")
msg.plain = """%s, thank you for registering with the Indiana Philosophy
Ontology Project (InPhO). You can access your """ % self.form_result['username']
msg.send()
h.redirect(h.url(controller='account', action='result'))
示例8: send_email
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [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.")
示例9: do_email_students
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def do_email_students(self):
log.debug(str(request.params))
user = h.get_user(request.environ)
student_ids_str = request.params['student_ids']
student_ids = ah.fileset_id_string_to_id_list(student_ids_str)
students = Student.query.filter(Student.id.in_(student_ids)).all()
students = filter(lambda student: request.params.has_key(str(student.id)), students)
for student in students:
check_student_access(student)
subject = request.params['subject']
body = request.params['body']
from_addr = (user.givenName+" "+user.surName,user.name + '@illinois.edu')
reply_to = user.name + '@illinois.edu'
to_addrs = map(lambda student: (student.displayName, student.netid + "@illinois.edu"), students)
from turbomail import Message
message = Message()
message.subject = subject
message.plain = body
message.author = from_addr
message.reply_to = reply_to
message.to = to_addrs
message.cc = from_addr
message.send()
if request.params.has_key('assignment_id'):
return redirect_to(controller='view_analysis', action='view', id=request.params['assignment_id'])
else:
return redirect_to(controller='view_analysis', action='list')
示例10: test_message_instantiation_with_keyword_parameters
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_message_instantiation_with_keyword_parameters(self):
message = Message(sender='[email protected]', recipient='[email protected]',
subject='Test')
message.plain = 'Hello world!'
msg_string = str(message)
self.failUnless('From: [email protected]' in msg_string)
self.failUnless('To: [email protected]' in msg_string)
self.failUnless('Subject: Test' in msg_string)
示例11: test_message_instantiation_with_tuples
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_message_instantiation_with_tuples(self):
message = Message(('Foo Bar', '[email protected]'),
('To', '[email protected]'), 'Test')
message.plain = 'Hello world!'
msg_string = str(message)
self.failUnless('From: Foo Bar <[email protected]>' in msg_string)
self.failUnless('To: To <[email protected]>' in msg_string)
self.failUnless('Subject: Test' in msg_string)
示例12: email_test
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def email_test(self):
from turbomail import Message
msg = Message('[email protected]', '[email protected]', 'Subject')
msg.plain = "Foo Bar"
try:
msg.send() # Message will be sent through the configured manager/transport.
except Exception, err:
print err
示例13: on_success
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def on_success(cls, request, values):
g = request.globals
config = g.getMailConfig()
interface.start(config)
msg = Message(config['mail.smtp.username'], g.mailRecipient, "Contact", encoding ='utf-8')
msg.plain = u'\n\n'.join( map(lambda s: s.format(**values), [u'First Name: {name}', u'Email: {email}', u'Message: {message}']) )
msg.send()
interface.stop(force=True)
return {'success':True, 'redirect':request.fwd_url('website_home')}
示例14: test_message_enqueue
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_message_enqueue(self):
config = {'mail.on': True}
fake_setuptools = {'immediate': ImmediateManager,
'debug': DebugTransportFactory}
interface.start(config, extra_classes=fake_setuptools)
message = Message('[email protected]', '[email protected]', 'Test')
message.plain = 'Hello world!'
turbomail.enqueue(message)
示例15: test_use_sender_for_author_if_no_author_given
# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import plain [as 别名]
def test_use_sender_for_author_if_no_author_given(self):
message = Message(sender='[email protected]', to='[email protected]',
subject='Test')
self.assertEqual('[email protected]', str(message.sender))
message.plain = 'Hello world!'
msg_string = str(message)
self.failUnless('From: [email protected]' in msg_string)
self.failUnless('To: [email protected]' in msg_string)
self.failUnless('Subject: Test' in msg_string)
self.failIf('Sender: ' in msg_string)
self.assertEqual('[email protected]', str(message.sender))