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


Python envelopes.Envelope类代码示例

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


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

示例1: mail_results

def mail_results(al, results):
    subject = 'Aleph: %s new documents matching %s' % (results.result['hits']['total'], al.label)
    templatedir = dirname(dirname(dirname(abspath(__file__)))) + '/templates/'
    env = Environment(loader=FileSystemLoader(templatedir))

    # every other search from the same user, for display in the mail
    other_searches = db.session.query(
        Alert).filter(Alert.user_id == al.user_id)
    
    html_body = env.get_template('alert.html').render(**{
        'hits': results.result['hits']['hits'],
        'user': al.user,
        'alert': al,
        'other_searches': other_searches})
    text_body = html2text.html2text(html_body)
    
    msg = Envelope(
        from_addr = (u'[email protected]', u"Dan O'Huiginn"),
        to_addr = (al.user.email),
        subject = subject,
        text_body = text_body,
        html_body = html_body)
    msg.send(app.config.get('MAIL_HOST'),
             login=app.config.get('MAIL_FROM'),
             password=app.config.get('MAIL_PASSWORD'),
             tls=True)    
    # simple python templating of results
    pass
开发者ID:vied12,项目名称:aleph,代码行数:28,代码来源:alerts.py

示例2: sendmail

def sendmail(to_address, subject, 
        message_text=None, message_html=None, 
        reply_to=None, headers=None, 
        **kwargs):
    if not web.config.get('smtp_server'):
        logger.warn("smtp_server not configured, mail won't be sent.")
        return

    headers = dict(headers or {})
    if reply_to:
        headers['Reply-To'] = reply_to

    envelope = Envelope(
        from_addr=web.config.from_address,
        to_addr=to_address,
        subject=subject,
        html_body=message_html,
        text_body=message_text,
        headers=headers
    )
    server = web.config.smtp_server
    port = int(web.config.get('smtp_port', 25))
    username = web.config.smtp_username
    password = web.config.get('smtp_password')
    tls = web.config.get('smtp_starttls', False)

    return envelope.send(
            host=server,
            port=port,
            login=username,
            password=password,
            tls=tls)
    
开发者ID:RahulRavindren,项目名称:broadgauge,代码行数:32,代码来源:sendmail.py

示例3: main

def main():
    browser = webdriver.Firefox()
    browser.implicitly_wait(10)
    try:
        text_body = ''
        for user, pwd in settings.users:
            user = JDUser(browser, user, pwd)
            if user.login():
                total_bean = user.sign_and_get_beans()
                text_body += '\n{}领取成功!当前京豆:{}'.format(user, total_bean)
                user.logout()
            else:
                text_body += '\n{}登录失败!'.format(user)

    except Exception:
        text_body = traceback.format_exc()
        logger.info(text_body)
    finally:
        envelope = Envelope(
            from_addr=(settings.email_user, u''),
            to_addr=(settings.email_user, u''),
            subject=u'京东领取京豆记录-{:%Y-%m-%d %H:%M:%S}'.format(
                datetime.datetime.now()),
            text_body=text_body
        )
        envelope.send(settings.email_host,
                      login=settings.email_user,
                      password=settings.email_pwd,
                      tls=True)
        logger.info("发送邮件成功!")
        browser.quit()
开发者ID:shyrock,项目名称:jd_bean_auto_get,代码行数:31,代码来源:get_jd_bean.py

示例4: sendmail

def sendmail(template, to, subject, headers=None, **kwargs):
    """
    Sends an email with the selected html template.
    html templates can be found inside the broadguage/templates
    directory. 

    Params:
    =======
    template: str
    Link to the html file to be used as template. The html
    file is parsed by Jinja Templating before sending to the
    recipient. 

    Keyword Args:
    =============
    to: str
    Recipient's email
    
    sub: str
    Subject of the mail

    P.S: Other keywords are sent to Jinja Templating Language for 
    direct parsing, as it is.
    
    Example:
    >>> from sendmail import sendmail
    >>> sendmail("emails/trainers/welcome.html",to=..."some_email.com", 
                               sub="Hey Friend!", variable1=var, variable2=var2)
    Email sent to some_email.com
    """
    if not web.config.get('smtp_server'):
        # TODO: log warn message
        return

    html = render_template(template, **kwargs)

    # inline CSS to make mail clients happy
    html = pynliner.fromString(html)

    envelope = Envelope(
        from_addr=web.config.from_address,
        to_addr=to,
        subject=subject,
        html_body=html,
        headers=headers
    )

    server = web.config.smtp_server
    port = int(web.config.get('smtp_port', 25))
    username = web.config.smtp_username
    password = web.config.get('smtp_password')
    tls = web.config.get('smtp_starttls', False)

    result = envelope.send(
                host=server,
                port=port,
                login=username,
                password=password,
                tls=tls)
    return result
开发者ID:iambibhas,项目名称:broadgauge,代码行数:60,代码来源:sendmail.py

示例5: send_mail

    def send_mail(self, text):
        self.logger.debug("Building mail")

        envelope = Envelope(
            from_addr=('au[email protected]'),
            to_addr=self.config.get('emailRecipient', None),
            subject='The Augure has spoken',
            text_body=text
        )

        try:
            self.logger.debug("Sending mail")

            if self.external_mail_server:
                envelope.send(
                    self.config.get("emailServer"),
                    login=self.config["emailLogin"],
                    password=self.config["emailPassword"], tls=True
                )
            else:
                #if no mail in config we use local mail server
                envelope.send('localhost', port=25)

            self.logger.debug("Mail sent")
        except Exception as e:
            self.logger.error(e)
开发者ID:tristan-c,项目名称:augure,代码行数:26,代码来源:Augure.py

示例6: mail_results

def mail_results(al, results):
    subject = "Aleph: %s new documents matching %s" % (results.result["hits"]["total"], al.query)
    templatedir = dirname(dirname(dirname(abspath(__file__)))) + "/templates/"
    env = Environment(loader=FileSystemLoader(templatedir))

    # every other search from the same user, for display in the mail
    other_searches = db.session.query(Alert).filter(Alert.user_id == al.user_id).filter(Alert.id != al.id)

    html_body = env.get_template("alert.html").render(
        **{"hits": results.result["hits"]["hits"], "user": al.user, "alert": al, "other_searches": other_searches}
    )
    text_body = html2text.html2text(html_body)

    msg = Envelope(
        from_addr=(u"[email protected]", u"Dan O'Huiginn"),
        to_addr=(al.user.email),
        subject=subject,
        text_body=text_body,
        html_body=html_body,
    )
    msg.send(
        app.config.get("MAIL_HOST"),
        login=app.config.get("MAIL_FROM"),
        password=app.config.get("MAIL_PASSWORD"),
        tls=True,
    )
开发者ID:OpenOil-UG,项目名称:aleph,代码行数:26,代码来源:alerts.py

示例7: send

 def send(self):
     """
     Init envelope by passing message details and send
     using credentials define during self init
     """
     envelope = Envelope(**self.msg)
     envelope.send(**self.creds)
开发者ID:firstopinion,项目名称:courier,代码行数:7,代码来源:__init__.py

示例8: mail_new_entries

def mail_new_entries(links):
    """
    given a list of new entries, mail out to subscriber list
    :return:
    """

    recipients = ['[email protected]']

    html_start = ''

    for each_link in links:
        html_start += '<p>'
        html_start += str(each_link)
        html_start += '<br>'
        html_start += '<hr>'

        html_start += pull_html_from_post(each_link)

        html_start += '</p>'

    html_start += '</body></html>'

    print html_start

    envp = Envelope(from_addr='[email protected]', to_addr=recipients,
                    subject='New CL posting!', html_body=html_start)

    envp.send('localhost')
开发者ID:jakemadison,项目名称:quick_craig_mails,代码行数:28,代码来源:main.py

示例9: save_tfidf_results

def save_tfidf_results(self,job_id):
    db_collection = _get_db_collection()
    job_info = db_collection.find_one({'_id': ObjectId(job_id)})
    logger.info("Job %s: TF-IDF" % (job_id))
    # tfidf them
    filepaths = job_info['filepaths']
    tfidf = samediff.analysis.tf_idf(filepaths)
    cosine_similarity = samediff.analysis.cosine_similarity(filepaths)
    # save the results back to the db (based on the job_number)
    job_info['tfidf'] = tfidf
    job_info['cosineSimilarity'] = cosine_similarity
    # delete the raw input files
    for path in job_info['filepaths']:
        os.remove(path)
    del job_info['filepaths']
    job_info['status'] = 'complete'
    db_collection.save(job_info)
    # TODO: catch any exceptions and queue them up for retry attempts
    
    # notify them with email
    # TODO: Internationalize and put the text stuff into some kind of templating structure
    name = job_info['email'].split('@')[0]
    body = u'Dear %s, \n\nYour SameDiff job is ready at this URL: %s! \n\nSincerely, \n %s ' % ( name , job_info["results_url"], settings.get('mail','from_name'))
    envelope = Envelope(
        from_addr=(settings.get('mail','from_email'), settings.get('mail','from_name')),
        to_addr=(job_info['email'], name),
        subject=u'Your SameDiff job is ready!',
        text_body=body)
    envelope.send('mail.gandi.net', login=settings.get('mail','login'),
              password=settings.get('mail','password'), tls=True)
开发者ID:c4fcm,项目名称:SameDiff,代码行数:30,代码来源:tasks.py

示例10: mail

def mail(subject,msg,sender='[email protected]',receiver='[email protected]'):
  envelope = Envelope(
    from_addr = sender, 
    to_addr = receiver,
    subject = subject,
    html_body = msg)
  #envelope.send('smtp.office365.com', login=sender,password='asdlfkj', tls=True)
  envelope.send('smtp.annik.com')
开发者ID:pandey957,项目名称:officework,代码行数:8,代码来源:testmail_arqiva.py

示例11: send_envelope

def send_envelope():
    envelope = Envelope(
        from_addr='%[email protected]' % os.getlogin(),
        to_addr='%[email protected]' % os.getlogin(),
        subject='Envelopes in Celery demo',
        text_body="I'm a helicopter!"
    )
    envelope.send('localhost', port=1025)
开发者ID:AdamCanady,项目名称:envelopes,代码行数:8,代码来源:example_celery.py

示例12: send_report

def send_report(report, subj, recips):
    envelope = Envelope(
        from_addr=(u"[email protected]", u"JoyRide Robot"), to_addr=recips, subject=subj, html_body=report
    )

    log.info("sending email '%s' to %s" % (subj, repr(recips)))
    # Send the envelope using an ad-hoc connection...
    envelope.send("smtp.googlemail.com", login=secrets[0], password=secrets[1], tls=True, port=587)
开发者ID:kmanley,项目名称:JoyrideRidgefield,代码行数:8,代码来源:fashionshowsales.py

示例13: ReplyMail

class ReplyMail(object):
    """An Envelope Object wrapper used to reply a mail easily. 
    """
    def __init__(self,orimail,from_name=None,charset='utf-8'):
        self.charset=charset

        from_addr = orimail.get_addr('to')[0]
        to_addr = orimail.get_addr('from')
        cc_addr = orimail.get_addr('cc')

        if not from_name:
            from_name = from_addr

        self.envelope = Envelope(
            from_addr = (from_addr,from_name),
            to_addr  = to_addr,
            subject = "RE:" + orimail.subject,
            )

        self.add_addr(cc_addr=cc_addr)

    def add_attachment(self,attfile):
        self.envelope.add_attachment(attfile)

    def set_subject(self,subject):
        self.envelope._subject = subject

    def set_body(self, text_body=None, html_body=None,charset='utf-8'):
        if text_body:
            self.envelope._parts.append(('text/plain', text_body, charset))

        if html_body:
            self.envelope._parts.append(('text/html', html_body, charset))

    def add_addr(self,to_addr=None,cc_addr=None,bcc_addr=None):
        if to_addr:
            for addr in to_addr:
                self.envelope.add_to_addr(addr)
        if cc_addr:
            for addr in cc_addr:
                self.envelope.add_cc_addr(addr)
        if bcc_addr:
            for addr in bcc_addr:
                self.envelope.add_bcc_addr(addr)

    def send(self,smtpserver=None,account=None):
        if smtpserver:
            smtpserver.send(self.msg)
        elif account:
            self.envelope.send(account.smtp,login=account.username,password=account.decrypt_password())
        else:
            logger.error("A SMTP server or mail account must be provided!.")
            return False

        return True

    def __repr__(self):
        return self.envelope.__repr__
开发者ID:Fatalerr,项目名称:mailbeeper,代码行数:58,代码来源:ezmail.py

示例14: send_email

def send_email(from_name, to_email, to_name, subject, content):
    envelope = Envelope(from_addr=(settings.SMTP_CONFIG["email"], from_name),
                        to_addr=(to_email, to_name),
                        subject=subject,
                        html_body=content)
    envelope.send(settings.SMTP_CONFIG["smtp_server"],
                  login=settings.SMTP_CONFIG["email"],
                  password=settings.SMTP_CONFIG["password"],
                  tls=settings.SMTP_CONFIG["tls"])
开发者ID:mcmdhr,项目名称:CSOJ,代码行数:9,代码来源:mail.py

示例15: send_email

def send_email(smtp_config, from_name, to_email, to_name, subject, content):
    envelope = Envelope(from_addr=(smtp_config["email"], from_name),
                        to_addr=(to_email, to_name),
                        subject=subject,
                        html_body=content)
    return envelope.send(smtp_config["server"],
                         login=smtp_config["email"],
                         password=smtp_config["password"],
                         port=smtp_config["port"],
                         tls=smtp_config["tls"])
开发者ID:joeyac,项目名称:OnlineJudge,代码行数:10,代码来源:shortcuts.py


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