本文整理汇总了Python中mailer.Message.Body方法的典型用法代码示例。如果您正苦于以下问题:Python Message.Body方法的具体用法?Python Message.Body怎么用?Python Message.Body使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mailer.Message
的用法示例。
在下文中一共展示了Message.Body方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: alert_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def alert_email(feed, cfg, entry):
"""Sends alert via email.
Args:
feed (:py:class:`Feed`): the feed
cfg (dict): output config
entry (dict): the feed entry
"""
logger = logging.LoggerAdapter(log, extra = {
'feed': feed.name,
'group': feed.group['name'],
})
logger.debug(f"[{feed.name}] Alerting email: {entry.title}")
description = strip_html(entry.description)
try:
smtp = Mailer(host=cfg['server'])
message = Message(charset="utf-8", From=cfg['from'], To=cfg['to'],
Subject = f"{feed.group['name']} Alert: ({feed.name}) {entry.title}")
message.Body = f"Feed: {feed.name}\nDate: {entry.datestring}\n\n{description}"
message.header('X-Mailer', 'rssalertbot')
smtp.send(message)
except Exception:
logger.exception(f"[{feed.name}] Error sending mail")
示例2: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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
示例3: sendmail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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)
示例4: send_reset_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def send_reset_email(self):
self.token = os.urandom(32).encode('hex')
sender = Mailer('localhost', port=25)
msg = Message(From="[email protected]", To=[self.email],
charset="utf-8")
msg.Subject = u'Accès trombinoscope ACR'
msg.Body = _BODY % (unicode(self.token), unicode(self.login))
sender.send([msg])
示例5: _send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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)
示例6: _send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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)
示例7: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def send(self):
"""Send the email described by this object."""
message = Message(From=self.sender,
To=self.to,
charset="utf-8")
message.Subject = self.subject
message.Body = self.body
mailer = Mailer(self.smtp_server)
mailer.send(message)
示例8: send
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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)
示例9: handle_notification
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def handle_notification(self, users, subject, body):
"Send a notification email."
recipients = [u.email for u in users if u.email is not None]
if len(recipients) > 0:
msg = Message(From=config.get('mailer.from',
'[email protected]'),
To=recipients)
msg.Subject = "BlueChips: %s" % subject
msg.Body = body
self.send_message(msg)
示例10: send_mail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def send_mail(self):
message = Message(From=self.fr,
To=self.to,
Subject=self.sub,
Charset='utf8')
message.Body = self.body
sender = Mailer(host=self.server,usr=self.usr,pwd=self.pwd)
sender.send(message)
示例11: verify_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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)
示例12: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def send_email(from_email, to_email_list, subject, html, smtp_host, smtp_port=587, username=None, password=None):
message = Message(From=from_email, To=to_email_list, charset='utf-8')
# Keep from creating threads in gmail...
message.Subject = "{} -- {}".format(subject, datetime.now().strftime('%Y-%m-%dT%H:%M:%S'))
message.Html = html.encode('utf-8')
message.Body = 'See the HTML!'
sender = Mailer(host=smtp_host, port=smtp_port, use_tls=True, usr=username, pwd=password)
if username is not None:
sender.login(username, password)
sender.send(message)
示例13: send_email
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [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: send_feedback_mail
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def send_feedback_mail(version, username, feedback, logcat):
# noinspection PyBroadException
try:
msg = Message(From=args.user, To=args.receiver, charset="utf8")
msg.Subject = u"Feedback {} ({})".format(version, username)
msg.Body = u"User: {0} http://pr0gramm.com/user/{0}\nFeedback: {1}\n\nLogcat: {2}\n".format(username, feedback, logcat)
mailer = Mailer(args.host, port=587, use_tls=True, usr=args.user, pwd=args.password)
mailer.send(msg)
except:
traceback.print_exc()
示例15: __init__
# 需要导入模块: from mailer import Message [as 别名]
# 或者: from mailer.Message import Body [as 别名]
def __init__(self, from_email, to_emails, subject, html, mailer=None):
if mailer is None:
mailer = Mailer(host='localhost', port=1025)
for to_email in to_emails:
message = Message(From=from_email,
To=to_email,
charset="utf-8")
message.Subject = subject
message.Html = html
message.Body = """Digestive doesn't support non-html emails. Sorry!"""
sender = mailer
sender.send(message)