本文整理汇总了Python中envelopes.Envelope.send方法的典型用法代码示例。如果您正苦于以下问题:Python Envelope.send方法的具体用法?Python Envelope.send怎么用?Python Envelope.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类envelopes.Envelope
的用法示例。
在下文中一共展示了Envelope.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mail_results
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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
示例2: mail_results
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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,
)
示例3: send_mail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
def send_mail(self, text):
self.logger.debug("Building mail")
envelope = Envelope(
from_addr=('[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)
示例4: send
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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)
示例5: mail_new_entries
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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')
示例6: main
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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()
示例7: save_tfidf_results
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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)
示例8: send_report
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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)
示例9: mail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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')
示例10: send_envelope
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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)
示例11: ReplyMail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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__
示例12: send_email
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
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"])
示例13: send_mail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
def send_mail(html_file, attach_file):
envelope = Envelope(
from_addr=mail_from,
to_addr=mail_to,
cc_addr=mail_cc,
subject='Test Report - ' + month_last,
html_body=open(html_file).read(),
)
# envelope.add_attachment(attach_file)
print("begin to send: {}".format(html_file))
envelope.send(smtp_server, login=user, password=passwd, tls=True)
示例14: send_mail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
def send_mail(self, message, subject):
mail = Envelope(
from_addr=self.mail_class.get("author", self.email_author),
to_addr=self.mail_class["to"].split(";"),
subject=subject.format(version=self.candidate, target=env.name.upper()),
text_body=message % env.name.upper(),
)
if self.mail_class.get("cc"):
for cc in self.mail_class["cc"].split(";"):
mail.add_cc_addr(cc)
mail.send(self.mail_class["server"])
示例15: send_mail
# 需要导入模块: from envelopes import Envelope [as 别名]
# 或者: from envelopes.Envelope import send [as 别名]
def send_mail(self, message, subject):
mail = Envelope(
from_addr=self.mail_load.get('author', self.email_author),
to_addr=self.mail_load['to'].split(';'),
subject=subject.format(version=self.candidate, target=env.name.upper()),
text_body=message % env.name.upper()
)
if self.mail_load.get('cc'):
for cc in self.mail_load['cc'].split(';'):
mail.add_cc_addr(cc)
mail.send(self.mail_load['server'])