本文整理汇总了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()
示例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