summaryrefslogtreecommitdiffstats
path: root/Doc/library/email-examples.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-02-07 15:55:17 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-02-07 15:55:17 (GMT)
commit02384bfa9481d7e6276dfa6cf2fcfb0f59012be2 (patch)
tree9e173714bcbd00f2e47d25be5103df8de74a7356 /Doc/library/email-examples.rst
parentaa21297457ef0e5647602e19a89c4b797183c16e (diff)
downloadcpython-02384bfa9481d7e6276dfa6cf2fcfb0f59012be2.zip
cpython-02384bfa9481d7e6276dfa6cf2fcfb0f59012be2.tar.gz
cpython-02384bfa9481d7e6276dfa6cf2fcfb0f59012be2.tar.bz2
#20477: add examples of using the new contentmanager API.
Diffstat (limited to 'Doc/library/email-examples.rst')
-rw-r--r--Doc/library/email-examples.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/Doc/library/email-examples.rst b/Doc/library/email-examples.rst
index 32cecf3..294e131 100644
--- a/Doc/library/email-examples.rst
+++ b/Doc/library/email-examples.rst
@@ -40,6 +40,34 @@ text version: [2]_
.. literalinclude:: ../includes/email-alternative.py
+Examples using the Provision API
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Here is a reworking of the last example using the provisional API. To make
+things a bit more interesting, we include a related image in the html part, and
+we save a copy of what we are going to send to disk, as well as sending it.
+
+This example also shows how easy it is to include non-ASCII, and simplifies the
+sending of the message using the :meth:`.send_message` method of the
+:mod:`smtplib` module.
+
+.. literalinclude:: ../includes/email-alternative-new-api.py
+
+If we were instead sent the message from the last example, here is one
+way we could process it:
+
+.. literalinclude:: ../includes/email-read-alternative-new-api.py
+
+Up to the prompt, the output from the above is::
+
+ To: Penelope Pussycat <"penelope@example.com">, Fabrette Pussycat <"fabrette@example.com">
+ From: Pepé Le Pew <pepe@example.com>
+ Subject: Ayons asperges pour le déjeuner
+
+ Salut!
+
+ Cela ressemble à un excellent recipie[1] déjeuner.
+
+
.. rubric:: Footnotes
.. [1] Thanks to Matthew Dixon Cowles for the original inspiration and examples.