我有四个python函数用于发送邮件。如果程序做了一件事,它会将一组结果发送给多个收件人;如果程序做了另一件事,则会有一个单独的函数将结果发送给一个收件人。在def smail(to,sub,body):
addr_from = 'alert@'
msg = MIMEMultipart()
msg['From'] = addr_from
msg['To'] = to
msg['Subject'] = sub
msg.attach(body)
s = smtplib.SMTP('')
s.sendmail(addr_from, [to], msg.as_string())
s.quit()
def email_format2(results):
text = ""
text += 'The following applications in are non-compliant\n'
text += '
'
text += 'Here are there names and locations. Please inform the developer.'
text += '
'
text += '
'
table = pd.DataFrame.from_records(results)
table_str = table.to_html()
text += "%s" % table_str
return text
def mail_results_aq(results):
body = email_format2(results)
msg = MIMEText(body, 'html')
sub = "Placeholder subject"
to = 'email1@, email2@, email3@'
smail(to, sub, msg)
def mail_results_prd(results):
body = email_format2(results)
msg = MIMEText(body, 'html')
sub = "Placeholder subject"
to = 'email4@'
smail(to, sub, msg)
mail_results_aq功能将只将结果通过电子邮件发送给第一个收件人(电子邮件1@). 在
在其他类似的问题中,我看到一个收件人被输入到一个列表中,即
^{pr2}$
然而,这个用例似乎只有在同一个函数中使用时才有效。如何在上述四个功能中实现此功能?在
提前谢谢!在