• Home
  • Raw
  • Download

Lines Matching full:email

1 :mod:`email.policy`: Policy Objects
4 .. module:: email.policy
12 **Source code:** :source:`Lib/email/policy.py`
16 The :mod:`email` package's prime focus is the handling of email messages as
17 described by the various email and MIME RFCs. However, the general format of
18 email messages (a block of header fields each consisting of a name followed by
21 email. Some of these uses conform fairly closely to the main email RFCs, some
22 do not. Even when working with email, there are times when it is desirable to
24 interoperate with email servers that do not themselves follow the standards, or
28 Policy objects give the email package the flexibility to handle all these
32 control the behavior of various components of the email package during use.
34 email package to alter the default behavior. The settable values and their
37 There is a default policy used by all classes in the email package. For all of
38 the :mod:`~email.parser` classes and the related convenience functions, and for
39 the :class:`~email.message.Message` class, this is the :class:`Compat32`
42 bug compatibility) with the pre-Python3.3 version of the email package.
45 :class:`~email.message.EmailMessage` is the :class:`EmailPolicy` policy, via
48 When a :class:`~email.message.Message` or :class:`~email.message.EmailMessage`
50 :mod:`~email.parser`, a policy passed to the parser will be the policy used by
53 :mod:`~email.generator`, the generator uses the policy from the message by
57 The default value for the *policy* keyword for the :mod:`email.parser` classes
61 :mod:`~email.parser` module.
66 methods that are called internally by the email package, which a custom policy
77 As an example, the following code could be used to read an email message from a
94 >>> from email import message_from_binary_file
95 >>> from email.generator import BytesGenerator
96 >>> from email import policy
113 Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC
118 Some email package methods accept a *policy* keyword argument, allowing the
120 the :meth:`~email.message.Message.as_bytes` method of the *msg* object from
228 which case :class:`~email.message.Message` is used.
233 the email library to create policy instances with custom settings:
243 The remaining :class:`Policy` methods are called by the email package code,
244 and are not intended to be called by an application using the email package.
250 Handle a *defect* found on *obj*. When the email package calls this
252 :class:`~email.errors.Defect`.
261 Register a *defect* on *obj*. In the email package, *defect* will always
262 be a subclass of :class:`~email.errors.Defect`.
265 attribute of *obj*. When the email package calls :attr:`handle_defect`,
267 method. Custom object types used with the email package (for example,
276 Called when a header is added to an :class:`~email.message.EmailMessage`
277 or :class:`~email.message.Message` object. If the returned value is not
295 The email package calls this method with a list of strings, each string
303 email package policies, *name* should be the case preserved name (all
315 The email package calls this method with the name and value provided by
322 email package policies, the *name* and *value* should be strings or
331 The email package calls this method with the *name* and *value* currently
347 The email package calls this method with the *name* and *value* currently
352 for a discussion of the rules for folding email headers.
371 compliant with the current email RFCs. These include (but are not limited
379 The default value for the :attr:`~email.policy.Policy.message_factory`
380 attribute is :class:`~email.message.EmailMessage`.
400 :mod:`~email.parser` (as opposed to being set by a program), this
422 default ``header_factory`` (see :mod:`~email.headerregistry`) is provided
431 the :meth:`~email.message.EmailMessage.get_content` or
432 :meth:`~email.message.EmailMessage.set_content` method of an
433 :class:`~email.message.EmailMessage` object is called, it calls the
437 :data:`~email.contentmanager.raw_data_manager`.
449 :attr:`~email.headerregistry.BaseHeader.max_count` attribute of the
527 Suitable for serializing messages in conformance with the email RFCs.
557 the email package is changed from the Python 3.2 API in the following ways:
559 * Setting a header on a :class:`~email.message.Message` results in that
562 * Fetching a header value from a :class:`~email.message.Message` results
572 :class:`~email.message.EmailMessage` is a header object with extra
579 :mod:`~email.headerregistry`.
586 replicates the behavior of the email package in Python 3.2. The
587 :mod:`~email.policy` module also defines an instance of this class,
589 behavior of the email package is to maintain compatibility with Python 3.2.
620 :class:`~email.header.Header` object using the ``unknown-8bit`` charset.
626 Headers are folded using the :class:`~email.header.Header` folding
634 Headers are folded using the :class:`~email.header.Header` folding
645 behavior of the email package in Python 3.2.