MCPcopy
hub / github.com/django/django / as_string

Method as_string

django/core/mail/message.py:164–175  ·  view source on GitHub ↗

Return the entire formatted message as a string. Optional `unixfrom' when True, means include the Unix From_ envelope header. This overrides the default as_string() implementation to not mangle lines that begin with 'From '. See bug #13433 for details.

(self, unixfrom=False, linesep="\n")

Source from the content-addressed store, hash-verified

162# RemovedInDjango70Warning.
163class MIMEMixin:
164 def as_string(self, unixfrom=False, linesep="\n"):
165 """Return the entire formatted message as a string.
166 Optional `unixfrom' when True, means include the Unix From_ envelope
167 header.
168
169 This overrides the default as_string() implementation to not mangle
170 lines that begin with 'From '. See bug #13433 for details.
171 """
172 fp = StringIO()
173 g = generator.Generator(fp, mangle_from_=False)
174 g.flatten(self, unixfrom=unixfrom, linesep=linesep)
175 return fp.getvalue()
176
177 def as_bytes(self, unixfrom=False, linesep="\n"):
178 """Return the entire formatted message as bytes.

Calls 2

flattenMethod · 0.45
getvalueMethod · 0.45