Return the entire formatted message as a string. Optional 'unixfrom', when true, means include the Unix From_ envelope header. maxheaderlen is retained for backward compatibility with the base Message class, but defaults to None, meaning that the policy value for ma
(self, unixfrom=False, maxheaderlen=None, policy=None)
| 996 | |
| 997 | |
| 998 | def as_string(self, unixfrom=False, maxheaderlen=None, policy=None): |
| 999 | """Return the entire formatted message as a string. |
| 1000 | |
| 1001 | Optional 'unixfrom', when true, means include the Unix From_ envelope |
| 1002 | header. maxheaderlen is retained for backward compatibility with the |
| 1003 | base Message class, but defaults to None, meaning that the policy value |
| 1004 | for max_line_length controls the header maximum length. 'policy' is |
| 1005 | passed to the Generator instance used to serialize the message; if it |
| 1006 | is not specified the policy associated with the message instance is |
| 1007 | used. |
| 1008 | """ |
| 1009 | policy = self.policy if policy is None else policy |
| 1010 | if maxheaderlen is None: |
| 1011 | maxheaderlen = policy.max_line_length |
| 1012 | return super().as_string(unixfrom, maxheaderlen, policy) |
| 1013 | |
| 1014 | def __str__(self): |
| 1015 | return self.as_string(policy=self.policy.clone(utf8=True)) |