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

email.message_from_file

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


Import

import email
from email import message_from_file

Signature & Overview

email.message_from_file(fp, *args, **kws)

Read a file and parse its contents into a Message object model.

Usage

import email
from email import policy
import io

msg = email.message_from_file(io.StringIO("Subject: Note\n\nHi"), policy=policy.default)
assert msg["Subject"] == "Note"

Gotchas

REPL Inspect

from email import message_from_file
help(message_from_file)

Linked from

Related notes