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 f
(self, unixfrom=False, maxheaderlen=None, policy=None)
| 980 | |
| 981 | |
| 982 | def as_string(self, unixfrom=False, maxheaderlen=None, policy=None): |
| 983 | """Return the entire formatted message as a string. |
| 984 | |
| 985 | Optional 'unixfrom', when true, means include the Unix From_ envelope |
| 986 | header. maxheaderlen is retained for backward compatibility with the |
| 987 | base Message class, but defaults to None, meaning that the policy value |
| 988 | for max_line_length controls the header maximum length. 'policy' is |
| 989 | passed to the Generator instance used to serialize the message; if it |
| 990 | is not specified the policy associated with the message instance is |
| 991 | used. |
| 992 | """ |
| 993 | policy = self.policy if policy is None else policy |
| 994 | if maxheaderlen is None: |
| 995 | maxheaderlen = policy.max_line_length |
| 996 | return super().as_string(unixfrom, maxheaderlen, policy) |
| 997 | |
| 998 | def __str__(self): |
| 999 | return self.as_string(policy=self.policy.clone(utf8=True)) |