SafeMIMEText
This class provides a secure implementation of MIMEText that prevents header injection by forbidding multi-line headers. It automatically manages payload encoding, specifically handling long lines in UTF-8 content by applying Quoted-Printable encoding to ensure compliance with RFC 5322 line length limits.
Attributes
| Attribute | Type | Description |
|---|---|---|
| encoding | string or Charset | The character set used to encode the email content and headers, typically passed during initialization. |
Constructor
Signature
def SafeMIMEText(
_text: string,
_subtype: string = plain,
_charset: string = null
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| _text | string | The text content of the message. |
| _subtype | string = plain | The minor type of the MIME message. |
| _charset | string = null | The character set of the message. |
Methods
set_payload()
@classmethod
def set_payload(
payload: string,
charset: string = null
) - > null
Sets the content of the email message and automatically selects an appropriate transfer encoding to handle long lines if UTF-8 is used.
Parameters
| Name | Type | Description |
|---|---|---|
| payload | string | The actual text content or body to be stored in the email message. |
| charset | string = null | The character set of the payload; if set to 'utf-8', the method may force Quoted-Printable encoding to ensure RFC 5322 compliance for long lines. |
Returns
| Type | Description |
|---|---|
null | No value is returned. |