HTML Email Rendered Incorrectly When Carriage Returns Are Not Used
Question: The following python script generates an email file that can be piped to
sendmail. When I send this to my gmail account, lines 25, 50, and 51 are not
what I would have expected. All other lines appear as expected.

    
    
    import sys
    print "From:test@test.com"
    print "To:you@you.com"
    print "Subject: test no carriage return"
    print "MIME-Version: 1.0"
    print "Content-Disposition: inline;"
    print "Content-Type: text/html"
    sys.stdout.write ("<html>" )
    count = 1
    while ( count < 55):
     # output without a carriage return 
     sys.stdout.write( "<tr><td>test" + str(count) + " no carriage returns!</td>")
     count = count + 1
    sys.stdout.write ("</html>")
    

In the email I would expect this for lines 25,50,51:

    
    
     test25 no carriage returns!
     test50 no carriage returns!
     test51 no carriage returns!
    

instead, this is rendered:

    
    
     test25 no carriage retur! ns!
     test50 no ca! rriage returns!
     test51 no carriage returns!        test52 no carriage returns!
    

If I change the output to use `print` instead of `stdout`, then the email
displays as expected. I have also tried this in an MS Outlook with the same
effect. What is the reasoning for the unexpected result when carriage returns
are not used?


Answer: Not sure if it is a typo, but for one thing you are not closing your row. You
are missing a:

    
    
    </tr>
    

As well as opening and closing table tags.

