title: Python Format traceback
body: <p>The goal is to print the traceback from a failed python script. I have referenced a ton of stack articles, but I can not find one tailored to  my needs. The goal is to email the traceback when there is a failure. I can email everything fine, it is just formating said traceback.</p>
  
  <p>To get my traceback:</p>
  
  <pre><code>trace = traceback.format_exc()
  send_email("Python Failure", trace, "bj@mydomain.com")
  </code></pre>
  
  <p>Email is being run through an html emailing with smtpObj and MIMEMultipart:</p>
  
  <pre><code>def send_email(subject, message, receivers):
      sender = "mydomain.com"
      msg = MIMEMultipart("alternative")
      msg["Subject"] = subject
      msg["From"] = sender
      msg["To"] = ", ".join(receivers)
  
      html = """
      &lt;html&gt;
          &lt;head&gt;&lt;/head&gt;
          &lt;body&gt;
              &lt;p&gt;&lt;b&gt;""" + subject + """&lt;/b&gt;&lt;/p&gt;
              &lt;p&gt;""" + message + """&lt;/p&gt;
          &lt;/body&gt;
      &lt;/html&gt;
      """
      part1 = MIMEText(message, "plain")
      part2 = MIMEText(html, "html")
  
      msg.attach(part1)
      msg.attach(part2)
  
      smtpObj = smtplib.SMTP("thats.not.cheddar")
      smtpObj.sendmail(sender, receivers, msg.as_string())
      smtpObj.quit()
  </code></pre>
  
  <p>When I receive the email, the traceback is there but it is all on one line. I was just wondering if anyone could help format a little bit better.</p>