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


Python Mail.sendMail方法代码示例

本文整理汇总了Python中mail.Mail.sendMail方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.sendMail方法的具体用法?Python Mail.sendMail怎么用?Python Mail.sendMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mail.Mail的用法示例。


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

示例1: sendMail

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import sendMail [as 别名]
 def sendMail(self):
     link = self.webRTCaddress()
     topic = "nao_robot/camera/top/camera/image_raw"
     text = "please see the video from this address " + link
     text = text + " with topic name " + topic
     mail = Mail(text)
     mail.sendMail()
开发者ID:yiqiaoc,项目名称:ROS_Package,代码行数:9,代码来源:controller.py

示例2: sendReports

# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import sendMail [as 别名]
    def sendReports(self, option):
        """ Send out reports via email """

        msg = {}        # mail header and body
        mail = ''
        server = {}     # smtp server
        m = Mail()

        # smtp server address and tcp port
        server['addr'] = self.opts['smtp_host']
        server['port'] = self.opts['smtp_port']

        # smtp (static content) read from ini file
        msg['from'] = self.opts['smtp_from']

        Wrapper.msg('Sending out reports')

        if option == 'report':
            # for each report in report directory except summary.txt
            for f in os.listdir(self.opts['outdir'] + '/' + TODAY):
                if f != 'summary.txt':
                    report = self.opts['outdir'] + '/' + TODAY + '/' + f
                    name = f.split('.')[0]

                    # mail header + body
                    msg['message'] = 'Hi,\n\nplease find attached the Nessus ' \
                            'report for this week.\n\nBest Regards,\n\n' \
                            "Rocket Internet's Security Team"
                    msg['subject'] = '[{0}] Your new Nessus report for {1} ' \
                            'is ready'.format(name, TODAY)
                    msg['to'] = self.ini.config.get('addressbook', name)

                    # build and send mail
                    mail = m.buildMail(msg, (report,))
                    m.sendMail(server, mail, self.opts['smtp_login'], tls=True)
        else:
            report = self.opts['outdir'] + '/' + TODAY + '/' + 'summary.txt'
            with open(report, 'r') as f:
                report_data = f.read()

            # mail header + body
            msg['message'] = 'Hi,\n\nplease find below the Nessus ' \
                    'Summary Report for this week:\n\n'
            msg['message'] += report_data
            msg['message'] += "\n\nBest Regards,\n\nRocket Internet's " \
                    "Security Team"
            msg['subject'] = 'Nessus Summary Report ({0})'.format(TODAY)
            msg['to'] = self.ini.config.get('addressbook', 'Summary')

            # build and send mail
            mail = m.buildMail(msg, (report,))
            m.sendMail(server, mail, self.opts['smtp_login'], tls=True)

        return
开发者ID:rocket-internet-berlin,项目名称:RocketNessusHelper,代码行数:56,代码来源:controller.py


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