When I send email as HTML, why do erroneous whitespaces get introduced to the HTML source and a few < > chars get converted to &lt; and &gt; ???

dieter dieter at handshake.de
Sat Nov 9 02:29:00 EST 2013


richard.balbat at gmail.com writes:

> I have the following script that reads in an HTML file containing a table then sends it out via email with a content type of text/html.
>
> For some reason a few erroneous whitespaces get introduced to the HTML source and a few < > chars get converted to < and > ???
> ...
> Contents of results.html
>
> <html><head><title>Test Campaign Results</title></head><body><p>SoapUI regression testing has completed against the following: <br/><br/> Environment: Auto.QA<br/>Build: test<br/>Detailed results can be found here: http://xxxx-AUTO1.xxxx.xxx/SoapUITestResults/Auto.QA-2013-6-11_22-54-50<br/><br/></p><table border="1"><tr><th>SoapUI Project (WSDL/WADL)</th><th>Total</th><th>Pass</th><th>Failure</th><th>Pass Percentage</th></tr><tr><td>acceptancePartnerEndpointWSDefinition-soapui-project.xml</td><td>7</td><td><font color="green">7</font></td><td><font color="red">0</font></td><td>100.00%</td></tr><tr><td>AIM-Automation.xml</td><td>25</td><td><font color="green">23</font></td><td><font color="red">2</font></td><td>92.00%</td></tr><tr><td>ATM-Automation.xml</td><td>41</td><td><font color="green
> ...

I suggest to log the generated email (before sending) to verify whether
the transformation happens in your script or somewhere during the
email transport.


The email transport protocol ("SMTP" - "Simple Mail Transfer Protocol")
in principle imposes quite a strict limitation on line length
(72 characters, when I remember right). Your html input has much larger
lines - maybe, they are broken up somewhere - at the cost of spurious
whitespace. Usually, a "Content-Transfer-Encoding" is used
to satisfy the line length limitation. If this is quoted printable,
then reading the text undecoded, it may seem to have additional
characters (whitespace and control characters).

I have no idea what may replace "<" and ">" by html entity references.




More information about the Python-list mailing list