Email and MIME Modules

email.encoders

Legacy helpers that encode message payloads for MIME transport and set Content-Transfer-Encoding. Base64 and quoted-printable preserve data across transport restrictions, not confidentiality. Modern EmailMessage.set_content normally selects an encoding for you.

Formal Syntax & Structure

python syntaxpython
import email.encoders

Return Value

module

Module namespace available through import; import is a statement, not a value-returning expression.

Working Example

Example Snippetpython
from email.message import Messagefrom email.encoders import encode_base64message = Message()message.set_payload(b"tea")encode_base64(message)print(message["Content-Transfer-Encoding"], message.get_payload().strip())
Python Reference