本文整理汇总了Python中mailer.Message.Html方法的典型用法代码示例。如果您正苦于以下问题:Python Message.Html方法的具体用法?Python Message.Html怎么用?Python Message.Html使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer.Message
的用法示例。
在下文中一共展示了Message.Html方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send(self, from_address, to_address, subject, body=None, html=True):
try:
message = Message(
From=from_address,
To=to_address,
charset=self.charset
)
if body is None:
body = ''
self.body = body
message.Subject = "%s - %s" % (self.subject_prefix, subject)
message.Html = self.body
message.Body = self.body
except Exception as e:
log.exception('[scaffold_mailer] - Failed to create message object for mailer')
return False
try:
sender = Mailer(
host=self.config.get('host'),
port=self.config.get('port'),
use_tls=self.config.get('use_tls', False),
use_ssl=True,
usr=self.config.get('username'),
pwd=self.config.get('password'))
sender.send(message)
except Exception as e:
log.exception('[scaffold_mailer] - Failed to connect to smtp sever and send message with subject: %s' % message.Subject)
return False
return True
示例2: mail_manifest
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def mail_manifest(self, emailfrom, emailto):
message = Message(From=emailfrom, To=emailto)
message.Subject = "Manifest"
message.Html = self.fetch_manifest()
sender = Mailer('localhost')
sender.send(message)
示例3: notify
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def notify(args):
config = parse_config(args.config)
db = database.WatchDb(db_path=DB_PATH)
LOGGER.info("Notify if something is not working...")
if db.get_status(config['notify']['track_last']):
LOGGER.info("Everything seems to be ok.")
else:
LOGGER.warning("One of tests failed, generate report.")
env = Environment(loader=FileSystemLoader(DIRECTORY))
template = env.get_template('template.html')
body = template.render(table=db.get_latest(config['notify']['track_last']))
LOGGER.info("Sending email...")
sender = Mailer(
config['smtp']['host'],
port=config['smtp']['port'],
usr=config['smtp']['user'],
pwd=config['smtp']['password'],
)
message = Message(
From=config['smtp']['user'],
To=config['notify']['email'],
)
message.Subject = config['notify']['subject']
message.Html = body
sender.send(message)
示例4: sendmail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def sendmail(mailto, subject, html='', text='', textfile='', htmlfile='', attachments=''):
'''send mail'''
if not mailto:
print 'Error: Empty mailto address.\n'
return
mailto = [sb.strip() for sb in mailto.split(',')]
if attachments:
attachments = [att.strip() for att in attachments.split(',')]
else:
attachments = []
#USERNAME = hostname()
subject = "%s-[%s]" % ( subject, hostname())
message = Message(From=USERNAME, To=mailto, Subject=subject, attachments=attachments)
message.Body = text
message.Html = html
message.charset = 'utf8'
try:
if htmlfile:
message.Html += open(htmlfile, 'r').read()
if textfile:
message.Body += open(textfile, 'r').read()
except IOError:
pass
for att in attachments:
message.attach(att)
sender = Mailer(SERVER,port=465, use_tls=True, usr=USERNAME, pwd=PASSWD)
#sender = Mailer(SERVER)
#sender.login(USERNAME, PASSWD)
sender.send(message)
示例5: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send_email(user, pwd, recipient, subject, body):
gmail_user = user
gmail_pwd = pwd
FROM = user
TO = recipient if type(recipient) is list else [recipient]
SUBJECT = subject
TEXT = body
message = Message(From=FROM,
To=TO)
message.Subject = SUBJECT
message.Html = """
<html>
<head></head>
<body>
<p>Hi! You've requested the UTNC practice schedule<br>
How are you?<br>
Here is the <a href="http://www.python.org">link</a> you wanted.
</p>
</body>
</html>
"""
sender = Mailer('smtp.gmail.com',port=587, use_tls=True, usr=gmail_user, pwd=gmail_pwd)
sender.send(message)
示例6: _send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def _send(self, subject, htmlbody):
for to in config().backupmailrecipients:
logger().info("INFO: Sent backup report to [%s] via SMTP:%s" % (to, config().smtphost))
message = Message(From=config().backupmailfrom, To=to, charset="utf-8")
message.Subject = subject
message.Html = htmlbody
message.Body = """This is an HTML e-mail with the backup overview, please use a HTML enabled e-mail client."""
sender = Mailer(config().smtphost)
sender.send(message)
示例7: _send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def _send(self, subject, htmlbody, textbody):
for to in config().backupmailrecipients:
logger().info("Sent backup report to [%s] via SMTP:%s" % (to, config().smtphost))
message = Message(From=config().backupmailfrom, To=to, charset="utf-8")
message.Subject = subject
message.Html = htmlbody
message.Body = textbody
sender = Mailer(config().smtphost)
sender.send(message)
示例8: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send_email(msg):
from mailer import Mailer, Message
mail_msg = Message(From="监听者<%s>"%(os.environ["MAIL_ADDR"]),
To=["[email protected]"],
charset="utf-8")
mail_msg.Subject = "Watchpmc Report"
mail_msg.Html = msg
sender = Mailer(host="smtp.yeah.net", usr=os.environ["MAIL_ADDR"], pwd=os.environ["MAIL_PASS"])
sender.send(mail_msg)
示例9: verify_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def verify_email(user):
# logger.debug("Generated email verification link: " + user.reg_id)
# if not user.active:
message = Message(From="[email protected]",To="[email protected]",charset="utf-8")
message.Subject = "Flotag Email Verification"
message.Html = """This email uses <strong>Complete Flotag Registration</strong>!"""
message.Body = """Flotag Registration"""
sender = Mailer('127.0.0.1')
sender.send(message)
示例10: sendMail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def sendMail(item, hwp):
sender = Mailer('smtp.gmail.com',use_tls=True)
for to in MAILER_TO :
sender.login(MAILER_USERNAME,MAILER_PASSWORD)
message = Message(From='[email protected]', To=to)
message.Subject = "가정통신문 :%s"%item['title'].encode('utf-8')
message.Html = ""
if hwp:
message.attach(hwp)
sender.send(message)
示例11: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send(self, from_address, to_address, subject, body='', html=True):
message = Message(From="[email protected]",
To=to_address,
charset=self.charset)
message.Subject = "%sAn HTML Email" % self.subject_prefix
message.Html = body
message.Body = body
sender = Mailer(self.host)
sender.send(message)
示例12: send_mail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send_mail(self, html):
"""
Send a mail via smtps
"""
message = Message(
From=self._config['mail']['address'], To=self._config['mail']['to'],
Subject=self._config['mail']['subject']
)
message.Html = html
return self.sender.send(message)
示例13: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send_email(image):
# Format email message
message = Message(From=MAIL_FROM,To=MAIL_TO)
message.Subject = MAIL_SUBJECT
message.Html = MAIL_HTML
message.Body = MAIL_BODY
message.attach(image)
# Send message to SMTP server
sender = Mailer(SMTP_HOST)
sender.send(message)
示例14: sendEmailTest
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def sendEmailTest():
from mailer import Mailer
from mailer import Message
message = Message(From="[email protected]", To="[email protected]")
message.Subject = "An HTML Email"
message.Html = """<p>Hi!<br>
How are you?<br>
Here is the <a href="http://172.16.2.249/kpi-android-cn.html">link</a>you wanted.</p>"""
sender = Mailer("mail.bainainfo.com")
sender.send(message)
示例15: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Html [as 别名]
def send(url, email):
"""Sends a html page to an email. Requires a local smtp server and the mailer module"""
html = urllib2.urlopen(url).read()
mail = Message(From = "test", To = email, charset='UTF-8')
mail.Subject = "Test email"
mail.Html = html
sender = Mailer()
sender.send(mail)