當前位置: 首頁>>代碼示例>>Python>>正文


Python mailer.Message類代碼示例

本文整理匯總了Python中mailer.Message的典型用法代碼示例。如果您正苦於以下問題:Python Message類的具體用法?Python Message怎麽用?Python Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Message類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: notify

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)
開發者ID:dawid1stanek,項目名稱:guardian,代碼行數:25,代碼來源:__main__.py

示例2: mail_manifest

 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)
開發者ID:OdinsHat,項目名稱:citylink-utils,代碼行數:7,代碼來源:citylink.py

示例3: message

    def message(self, name, log_file=None, error=None, **kwargs):
        """Create an email for the given stage based upon the log file.

        If no log file is provided or it is False then the email's body will
        not include the log lines to examine, and it will not be attached. If
        an error object is given this will be used to indicate the stage
        failed.

        :stage: Name of the stage that was run.
        :log_file: Filename for the log file
        :error: Exception object that occurred.
        :returns: A Mailer message to send.
        """

        status = 'Succeeded'
        if error:
            status = 'Failed'

        kwargs = {'stage': name, 'status': status}
        subject = self.config['email']['subject'].format(**kwargs)
        to_address = kwargs.get('send_to', None) or self.config['email']['to']
        msg = Message(
            From=self.config['email']['from'],
            To=to_address,
            Subject=subject,
            Body=self.body(name, log_file, **kwargs)
        )

        compressed_log = self.compressed_log(log_file)
        if compressed_log:
            msg.attach(compressed_log)

        return msg
開發者ID:BGSU-RNA,項目名稱:RNA-3D-Hub-core,代碼行數:33,代碼來源:email.py

示例4: send_email

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)
開發者ID:Syanna,項目名稱:UTNC_email,代碼行數:27,代碼來源:Email.py

示例5: alert_email

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")
開發者ID:jwplayer,項目名稱:rssalertbot,代碼行數:27,代碼來源:alerts.py

示例6: send

    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
開發者ID:maidstone-hackspace,項目名稱:maidstone-hackspace,代碼行數:32,代碼來源:mail.py

示例7: send_reset_email

 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])
開發者ID:AcrDijon,項目名稱:trombi,代碼行數:8,代碼來源:mappings.py

示例8: sendEmail

def sendEmail(toaddr, ccs, bccs, body, subject):
	""" 'sendEmail()' is called by 'feedConsumer()' when it is ready to
	send the e-mail to the specified recipient using SMTP; in case of
	failure to send, fallback gracefully to using the existing
	[email protected] account."""
	mailer = Mailer('smtp.gmail.com', port=587, use_tls=True, usr="[email protected]", pwd="mailerbot")
	msg = Message(From="[email protected]", To=toaddr, CC=ccs, BCC=bccs, Body=body)
	msg.Subject = subject
	mailer.send(msg)
開發者ID:acommitteeoflunatics,項目名稱:artifacts,代碼行數:9,代碼來源:couch-express.py

示例9: _send

 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)
開發者ID:WeszNL,項目名稱:autorsyncbackup,代碼行數:9,代碼來源:statusemail.py

示例10: _send

 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)
開發者ID:Nextpertise,項目名稱:autorsyncbackup,代碼行數:9,代碼來源:statusemail.py

示例11: send_email

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)
開發者ID:kuanghy,項目名稱:pps,代碼行數:9,代碼來源:watchpmc.py

示例12: send

 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)
開發者ID:JoseEspinosa,項目名稱:bbcflib,代碼行數:9,代碼來源:email.py

示例13: verify_email

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)
開發者ID:CarbonComputed,項目名稱:flotag,代碼行數:10,代碼來源:emailer.py

示例14: sendMail

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)
開發者ID:geekslife,項目名稱:soongduk,代碼行數:10,代碼來源:soongduk.py

示例15: handle_notification

 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)
開發者ID:andersk,項目名稱:bluechips,代碼行數:10,代碼來源:app_globals.py


注:本文中的mailer.Message類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。