<div dir="ltr">







<p class=""><span class="">From this link, <span class=""><a href="https://docs.python.org/2/library/email.message.html#email.message.Message.__str__">https://docs.python.org/2/library/email.message.html#email.message.Message.__str__</a></span></span></p>
<p class=""><span class=""><b>__str__</b></span><span class="">()</span></p>
<p class=""><span class="">  Equivalent to </span><span class="">as_string(unixfrom=True)</span><span class="">.</span></p><p class=""><span class=""><br></span></p><p class=""><span class="">Looking at the source for the Message class.</span></p><p class=""><span class=""><br></span></p><p class=""><span class=""></span></p><p class="">class Message:</p><p class="">    def __str__(self):</p><p class="">        """Return the entire formatted message as a string.</p><p class="">        This includes the headers, body, and envelope header.</p><p class="">        """</p><p class="">        return self.as_string()</p><p class=""><span class=""></span></p><p class="">    def as_string(self, unixfrom=False, maxheaderlen=0):</p><p class="">        """Return the entire formatted message as a string.</p><p class="">        Optional `unixfrom' when True, means include the Unix From_ envelope</p><p class="">        header.</p><p class=""><br></p><p class="">        This is a convenience method and may not generate the message exactly</p><p class="">        as you intend.  For more flexibility, use the flatten() method of a</p><p class="">        Generator instance.</p><p class="">        """</p><p class="">        from email.generator import Generator</p><p class="">        fp = StringIO()</p><p class="">        g = Generator(fp, mangle_from_=False, maxheaderlen=maxheaderlen)</p><p class="">        g.flatten(self, unixfrom=unixfrom)</p><p class="">        return fp.getvalue()</p><p class=""><br></p><p class="">__str__ is actually equivalent to Message.as_string(unixfrom=False)</p><div><br></div></div>