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


Python Message.send方法代码示例

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


在下文中一共展示了Message.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_email_students

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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')
开发者ID:cemeyer2,项目名称:comoto,代码行数:29,代码来源:view_analysis.py

示例2: send_mail

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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()
开发者ID:hlzz23,项目名称:AssetSystem,代码行数:36,代码来源:sendmail.py

示例3: _reset

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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'))
开发者ID:colinallen,项目名称:inphosite,代码行数:32,代码来源:account.py

示例4: new

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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'))
             
         
     
开发者ID:vickyi,项目名称:PylonsSimpleCMS,代码行数:25,代码来源:contactus.py

示例5: request_enable

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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)
开发者ID:cemeyer2,项目名称:comoto,代码行数:34,代码来源:users.py

示例6: send_email

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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.")
开发者ID:emilymwang8,项目名称:knowing,代码行数:29,代码来源:alert.py

示例7: submit

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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'))
开发者ID:camerontt2000,项目名称:inphosite,代码行数:30,代码来源:account.py

示例8: feedback

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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}
开发者ID:Geoportail-Luxembourg,项目名称:geoportailv3,代码行数:30,代码来源:feedback.py

示例9: email_test

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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
开发者ID:shihikoo,项目名称:abstrackr-web,代码行数:10,代码来源:account.py

示例10: on_success

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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')}
开发者ID:SinisaG,项目名称:klinikWeb,代码行数:11,代码来源:forms.py

示例11: send

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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()
开发者ID:mabotech,项目名称:mabo-radar,代码行数:14,代码来源:procmon.py

示例12: mail_user_error

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [as 别名]
 def mail_user_error(self, user):
     app_name = config['application_name']
     from_addr = config['error_email_from']
     suffix = config['email_suffix']
     to_addr = user.name + "@" + suffix
     subject = app_name+" static moss analysis graph generation failed"         
     body = "Dear "+user.name+",\n\nThe static moss analysis graph that you requested is failed to generate.\n\n"
     body += "The "+app_name+" developers have been informed of this error and will correct it as soon as possible.\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()
开发者ID:cemeyer2,项目名称:comoto,代码行数:16,代码来源:static_graph_generator.py

示例13: save_entryid_wordlist

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [as 别名]
 def save_entryid_wordlist(self, bibtexkey, language_bookname, concept, format):
     if c.book:
         c.entry = model.meta.Session.query(model.WordlistEntry).join(
                 (model.WordlistConcept, model.WordlistConcept.id==model.WordlistEntry.concept_id),
                 (model.Wordlistdata, model.Wordlistdata.id==model.WordlistEntry.wordlistdata_id),
                 (model.LanguageBookname, model.LanguageBookname.id==model.Wordlistdata.language_bookname_id)
             ).filter(model.Wordlistdata.book_id==c.book.id).filter(model.LanguageBookname.name==language_bookname).filter(model.WordlistConcept.concept==concept).first()
         param_annotations = request.params.get("annotations", None)
         param_fullentry = request.params.get("fullentry", None)
         #print param_fullentry
         if c.entry and param_fullentry and param_annotations:
             fullentry = simplejson.loads(param_fullentry);
             annotations = simplejson.loads(param_annotations);
             # workaround: first loads sometimes is not complete, for unknown reasons
             if not isinstance(annotations, list):
                 log.error("workaround applied in save_entryid")
                 annotations = simplejson.loads(annotations)
             c.entry.fullentry = fullentry
             # delete all annotations in db
             for a in c.entry.annotations:
                 if a.annotationtype.type == "dictinterpretation" or a.annotationtype.type == "orthographicinterpretation" or a.annotationtype.type == "errata":
                     model.meta.Session.delete(a)
             # insert new annotations
             for a in annotations:
                 print a["string"].encode("utf-8")
                 c.entry.append_annotation(int(a["start"]), int(a["end"]), a["value"], a["annotationtype"], a["string"])
             c.entry.has_manual_annotations = True
             model.meta.Session.commit()
             
             # send mail
             message = Message("[email protected]", "[email protected]", "[quanthistling] Manual wordlist entry %s %s %s" % (bibtexkey, language_bookname, concept), encoding="utf-8")
             python_code = render('/derived/book/entryid_wordlist.py.txt')
             message.plain = "File attached."
             #print python_code.encode("utf-8")
             
             # create temporary file
             filename = ""
             if c.entry.volume:
                 filename = u"%s_%s_%s_%s.py.txt" % (bibtexkey, c.entry.volume, c.entry.startpage, c.entry.pos_on_page)
             else:
                 filename = u"%s_%s_%s.py.txt" % (bibtexkey, c.entry.startpage, c.entry.pos_on_page)
             tmpfile = tempfile.TemporaryFile()
             tmpfile.write(python_code.encode("utf-8"))
             tmpfile.flush()
             tmpfile.seek(0)
             message.attach(tmpfile, filename)
             message.send()
             tmpfile.close()
             return "success"
     abort(404)
开发者ID:FrankNagel,项目名称:qlc,代码行数:52,代码来源:book.py

示例14: forgotaction

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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"))
开发者ID:vickyi,项目名称:PylonsSimpleCMS,代码行数:51,代码来源:user.py

示例15: send_mail

# 需要导入模块: from turbomail import Message [as 别名]
# 或者: from turbomail.Message import send [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()
开发者ID:hlzz23,项目名称:AssetSystem,代码行数:17,代码来源:sendmail.py


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