Issue #5262: Improved fix.
[python.git] / Doc / library / email-examples.rst
blobc1b16da39471c5b9a5389d3266946585fb2fc48a
1 .. _email-examples:
3 :mod:`email`: Examples
4 ----------------------
6 Here are a few examples of how to use the :mod:`email` package to read, write,
7 and send simple email messages, as well as more complex MIME messages.
9 First, let's see how to create and send a simple text message:
11 .. literalinclude:: ../includes/email-simple.py
14 Here's an example of how to send a MIME message containing a bunch of family
15 pictures that may be residing in a directory:
17 .. literalinclude:: ../includes/email-mime.py
20 Here's an example of how to send the entire contents of a directory as an email
21 message: [1]_
23 .. literalinclude:: ../includes/email-dir.py
26 Here's an example of how to unpack a MIME message like the one
27 above, into a directory of files:
29 .. literalinclude:: ../includes/email-unpack.py
31 Here's an example of how to create an HTML message with an alternative plain
32 text version: [2]_
34 .. literalinclude:: ../includes/email-alternative.py
37 .. rubric:: Footnotes
39 .. [1] Thanks to Matthew Dixon Cowles for the original inspiration and examples.
40 .. [2] Contributed by Martin Matejek.