• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python turbomail.Message类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turbomail.Message的典型用法代码示例。如果您正苦于以下问题:Python Message类的具体用法?Python Message怎么用?Python Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: do_email_students

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


示例17: test_use_sender_for_author_if_no_author_given

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


示例18: __notify

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()
开发者ID:archlevel,项目名称:knowing,代码行数:52,代码来源:debug_alert.py


示例19: test_message_properties

 def test_message_properties(self):
     message = Message('[email protected]', '[email protected]', 'Test')
     message.plain = 'Hello world!'
     
     property_names = ['bcc', 'cc', 'date', 'disposition', 'encoding',
                       'headers', 'organization', 'plain', 'priority',
                       'recipient', 'replyto', 'rich', 'sender', 'smtpfrom',
                       'subject']
     for name in property_names:
         getattr(message, name)
     
     args = dict(zip(property_names, ['[email protected]'] * len(property_names)))
     Message(**args)
开发者ID:mbbui,项目名称:Jminee,代码行数:13,代码来源:test_tm2_compatibility.py


示例20: new

 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'))
             
         
     
开发者ID:vickyi,项目名称:PylonsSimpleCMS,代码行数:23,代码来源:contactus.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tools.get_absolute_path函数代码示例发布时间:2022-05-27
下一篇:
Python report_utils.reporter函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap