本文整理汇总了Python中turbomail.Message类的典型用法代码示例。如果您正苦于以下问题:Python Message类的具体用法?Python Message怎么用?Python Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_mail
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: test_mail_encoding_is_used_as_fallback
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'])
示例3: request_enable
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: submit
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'))
示例5: test_use_deprecated_smtp_from
def test_use_deprecated_smtp_from(self):
message = Message(smtpfrom='[email protected]')
self.assertEqual('[email protected]', str(message.smtp_from))
self.assertEqual(message.smtpfrom, message.smtp_from)
message.smtpfrom = '[email protected]'
self.assertEqual('[email protected]', str(message.smtp_from))
self.assertEqual(message.smtpfrom, message.smtp_from)
示例6: test_message_instantiation_with_positional_parameters
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)
示例7: test_use_deprecated_reply_to
def test_use_deprecated_reply_to(self):
message = Message(replyto='[email protected]')
self.assertEqual('[email protected]', str(message.reply_to))
self.assertEqual(message.replyto, message.reply_to)
message.replyto = '[email protected]'
self.assertEqual('[email protected]', str(message.reply_to))
self.assertEqual(message.replyto, message.reply_to)
示例8: _reset
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'))
示例9: send_email
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.")
示例10: test_use_deprecated_recipient
def test_use_deprecated_recipient(self):
message = Message(recipient='[email protected]')
self.assertEqual('[email protected]', str(message.to))
self.assertEqual(message.recipient, message.to)
message.recipient = '[email protected]'
self.assertEqual('[email protected]', str(message.to))
self.assertEqual(message.recipient, message.to)
示例11: email_test
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
示例12: test_message_instantiation_with_tuples
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)
示例13: test_message_instantiation_with_keyword_parameters
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)
示例14: on_success
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')}
示例15: test_message_enqueue
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)