title: Python SMTP with text body and file attachment
body: <p>I am trying to open a text file and mail that in the body in plain text, I also need to attach several other log files to the e-mail.</p>
  
  <pre><code>import smtplib
  from email.MIMEText import MIMEText 
  from email.MIMEMessage import MIMEMessage
  
  recipient = 'people@people.com'
  
  def mail (recipient, ):
  
          fp = open('data.txt', 'r')
          msg = MIMEText(fp.read())
          fp.close()
          me = "jeff@noname.com"
          msg['Subject'] =  "Test Results" 
          msg['From'] = me
          msg['To'] = recipient
          s = smtplib.SMTP('localhost')
          s.sendmail(me, recipient.split(), msg.as_string())
          s.quit()
  
  mail (recipient, )
  </code></pre>
  
  <p>This currently will open the data.txt file and put all  of the contents into the e-mail body.  This is working how I want to, and I need to keep this.  But I also want to add 4-6 attachments to the e-mail and keep the body.  Anyone have any tips to help with this?</p>