title: Python: send email to multiple addresses
body: <p>I have four python functions that I am using to send mail.  If the program does one thing, it mails a set of results to a multiple recipients, if it does another thing, a separate function mails the results to one recipient.</p>
  
  <pre><code>def smail(to,sub,body):
      addr_from = 'alert@example.com'
      msg = MIMEMultipart()
      msg['From'] = addr_from
      msg['To'] = to
      msg['Subject'] = sub
      msg.attach(body)
      s = smtplib.SMTP('webmail.example.com')
      s.sendmail(addr_from, [to], msg.as_string())
      s.quit()
  
  def email_format2(results):
      text = ""
      text += 'The following applications in &lt;environment&gt; are non-compliant\n'
      text += '&lt;br&gt;'
      text += 'Here are there names and locations.  Please inform the developer.'
      text += '&lt;br&gt;'
      text += '&lt;br&gt;'
      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@example.com, email2@example.com, email3@example.com'
      smail(to, sub, msg)
  
  def mail_results_prd(results):
      body = email_format2(results)
      msg = MIMEText(body, 'html')
      sub = "Placeholder subject"
      to = 'email4@example.com'
      smail(to, sub, msg)
  </code></pre>
  
  <p>The mail_results_aq function will only email results to the first recipient (email1@example.com).  </p>
  
  <p>In other questions similar to this one, I've seen a the recipients being entered into a list i.e</p>
  
  <pre><code>import smtplib
  from email.mime.text import MIMEText
  
  s = smtplib.SMTP('smtp.uk.xensource.com')
  s.set_debuglevel(1)
  msg = MIMEText("""body""")
  sender = 'me@example.com'
  recipients = ['john.doe@example.com', 'john.smith@example.co.uk']
  msg['Subject'] = "subject line"
  msg['From'] = sender
  msg['To'] = ", ".join(recipients)
  s.sendmail(sender, recipients, msg.as_string())
  </code></pre>
  
  <p>However, this use case only seems to work when used in the same function.  How can I implement this feature across the four functions I have above?</p>
  
  <p>Thanks in advance!</p>