当前位置: 首页>>代码示例>>Python>>正文


Python turbomail.Message类代码示例

本文整理汇总了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()
开发者ID:hlzz23,项目名称:AssetSystem,代码行数:34,代码来源:sendmail.py

示例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'])
开发者ID:mbbui,项目名称:Jminee,代码行数:7,代码来源:test_tm2_compatibility.py

示例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)
开发者ID:cemeyer2,项目名称:comoto,代码行数:32,代码来源:users.py

示例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'))
开发者ID:camerontt2000,项目名称:inphosite,代码行数:28,代码来源:account.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:7,代码来源:test_tm2_compatibility.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:7,代码来源:test_tm2_compatibility.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:7,代码来源:test_tm2_compatibility.py

示例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'))
开发者ID:colinallen,项目名称:inphosite,代码行数:30,代码来源:account.py

示例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.")
开发者ID:emilymwang8,项目名称:knowing,代码行数:27,代码来源:alert.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:7,代码来源:test_tm2_compatibility.py

示例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
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:8,代码来源:account.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:8,代码来源:test_tm2_compatibility.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:8,代码来源:test_tm2_compatibility.py

示例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')}
开发者ID:SinisaG,项目名称:klinikWeb,代码行数:9,代码来源:forms.py

示例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)
开发者ID:mbbui,项目名称:Jminee,代码行数:9,代码来源:test_tm2_compatibility.py


注:本文中的turbomail.Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。