title: How to send a properly formatted email using Python and SMTP?
body: <p>I am trying to send an email using Python script but somehow in the format I am expecting the email to come in my mailbox, it is not coming in that format. Below is my method which is sending an email - </p>
  
  <pre><code>def send_mail(data):
      sender = 'fromuser@host.com'
      receivers = ['touser@host.com']
  
      message = """From: fromuser@host.com
      To: touser@host.com
      Subject: Send mail from python!!
  
      """
      body = 'Some Text\n'
      for item in data:
          body = body + '{name} - {res}\n'.format(name=item['name'], res=item['res'])
  
      message = message + body
  
      try:
         smtpObj = smtplib.SMTP('corp.host.com' )
         smtpObj.sendmail(sender, receivers, message)
         print "Mail sent"
      except smtplib.SMTPException:
         print "You can't spam. Mail sending failed!"
  </code></pre>
  
  <p>Here data just have key - value pair.</p>
  
  <p>And I am getting an email like this in my Outlook mailbox - </p>
  
  <p>In the <code>From:</code> section in my outlook, below string is coming as it is which is wrong - </p>
  
  <pre><code>fromuser@host.com To: touser@host.com Subject: Send mail from python!!
  </code></pre>
  
  <p>And <code>To:</code> , <code>Subject:</code> section is coming as Empty which is also wrong.</p>
  
  <p>And in the body I am seeing everything coming in a single line but I want the result to be shown as - </p>
  
  <pre><code>Some Text
  
  machinA - 0
  machineB - 0
  machineC - 0
  </code></pre>
  
  <p>How can I represent my data to be shown like this in my Outlook mailbox?</p>