summaryrefslogtreecommitdiffstats
path: root/Doc/library/email-examples.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/email-examples.rst')
-rw-r--r--Doc/library/email-examples.rst30
1 files changed, 30 insertions, 0 deletions
diff --git a/Doc/library/email-examples.rst b/Doc/library/email-examples.rst
index 32cecf3..cbbcb78 100644
--- a/Doc/library/email-examples.rst
+++ b/Doc/library/email-examples.rst
@@ -40,6 +40,36 @@ text version: [2]_
.. literalinclude:: ../includes/email-alternative.py
+.. _email-contentmanager-api-examples:
+
+Examples using the Provisional 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.