On this page
  1. email.message_from_string
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

email.message_from_string

Prev: email.message_from_file | Up: email
Rel: email.message_from_binary_file, email.message_from_bytes, email.message_from_file
Ref: docs.python.org — email.message_from_string
Tags: #public #python3 #stdlib #email


Import

import email
from email import message_from_string

Signature & Overview

email.message_from_string(s, *args, **kws)

Parse a string into a Message object model.

Usage

import email
from email import policy

msg = email.message_from_string("From: ada@example.com\nSubject: Hello\n\nBody", policy=policy.default)
assert msg["From"] == "ada@example.com"

Gotchas

REPL Inspect

from email import message_from_string
help(message_from_string)

Linked from

Related notes