parthtamu/rag-code-assistant
0
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4 <head>5 <meta charset="utf-8" />6 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="email — An email and MIME handling package" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/email.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/email/__init__.py The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP ( RFC 2821), NNTP, or othe..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_email_278b9b37.png" />15<meta property="og:image:alt" content="Source code: Lib/email/__init__.py The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP ( RFC 2821), NNTP, or othe..." />16<meta name="description" content="Source code: Lib/email/__init__.py The email package is a library for managing email messages. It is specifically not designed to do any sending of email messages to SMTP ( RFC 2821), NNTP, or othe..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20 <title>email — An email and MIME handling package — Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21 22 <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23 <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24 <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25 <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26 <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27 28 <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29 <script src="../_static/doctools.js?v=9bcbadda"></script>30 <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31 <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32 33 <script src="../_static/sidebar.js"></script>34 35 <link rel="search" type="application/opensearchdescription+xml"36 title="Search within Python 3.15.0a6 documentation"37 href="../_static/opensearch.xml"/>38 <link rel="author" title="About these documents" href="../about.html" />39 <link rel="index" title="Index" href="../genindex.html" />40 <link rel="search" title="Search" href="../search.html" />41 <link rel="copyright" title="Copyright" href="../copyright.html" />42 <link rel="next" title="email.message: Representing an email message" href="email.message.html" />43 <link rel="prev" title="Internet Data Handling" href="netdata.html" />44 45 46 <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47 48 <link rel="canonical" href="https://docs.python.org/3/library/email.html">49 50 51 52 53 <style>54 @media only screen {55 table.full-width-table {56 width: 100%;57 }58 }59 </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61 <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62 <script type="text/javascript" src="../_static/copybutton.js"></script>63 <script type="text/javascript" src="../_static/menu.js"></script>64 <script type="text/javascript" src="../_static/search-focus.js"></script>65 <script type="text/javascript" src="../_static/themetoggle.js"></script> 66 <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67 <meta name="readthedocs-addons-api-version" content="1">68 69 </head>70<body>71<div class="mobile-nav">72 <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73 aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74 <nav class="nav-content" role="navigation">75 <label for="menuToggler" class="toggler__label">76 <span></span>77 </label>78 <span class="nav-items-wrapper">79 <a href="https://www.python.org/" class="nav-logo">80 <img src="../_static/py.svg" alt="Python logo">81 </a>82 <span class="version_switcher_placeholder"></span>83 <form role="search" class="search" action="../search.html" method="get">84 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85 <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86 </svg>87 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88 <input type="submit" value="Go">89 </form>90 </span>91 </nav>92 <div class="menu-wrapper">93 <nav class="menu" role="navigation" aria-label="main navigation">94 <div class="language_switcher_placeholder"></div>95 96<label class="theme-selector-label">97 Theme98 <select class="theme-selector" oninput="activateTheme(this.value)">99 <option value="auto" selected>Auto</option>100 <option value="light">Light</option>101 <option value="dark">Dark</option>102 </select>103</label>104 <div>105 <h4>Previous topic</h4>106 <p class="topless"><a href="netdata.html"107 title="previous chapter">Internet Data Handling</a></p>108 </div>109 <div>110 <h4>Next topic</h4>111 <p class="topless"><a href="email.message.html"112 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message</span></code>: Representing an email message</a></p>113 </div>114 <script>115 document.addEventListener('DOMContentLoaded', () => {116 const title = document.querySelector('meta[property="og:title"]').content;117 const elements = document.querySelectorAll('.improvepage');118 const pageurl = window.location.href.split('?')[0];119 elements.forEach(element => {120 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));121 url.searchParams.set('pagetitle', title);122 url.searchParams.set('pageurl', pageurl);123 url.searchParams.set('pagesource', "library/email.rst");124 element.href = url.toString();125 });126 });127 </script>128 <div role="note" aria-label="source link">129 <h3>This page</h3>130 <ul class="this-page-menu">131 <li><a href="../bugs.html">Report a bug</a></li>132 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>133 <li>134 <a href="https://github.com/python/cpython/blob/main/Doc/library/email.rst?plain=1"135 rel="nofollow">Show source136 </a>137 </li>138 139 </ul>140 </div>141 </nav>142 </div>143</div>144 145 146 <div class="related" role="navigation" aria-label="Related">147 <h3>Navigation</h3>148 <ul>149 <li class="right" style="margin-right: 10px">150 <a href="../genindex.html" title="General Index"151 accesskey="I">index</a></li>152 <li class="right" >153 <a href="../py-modindex.html" title="Python Module Index"154 >modules</a> |</li>155 <li class="right" >156 <a href="email.message.html" title="email.message: Representing an email message"157 accesskey="N">next</a> |</li>158 <li class="right" >159 <a href="netdata.html" title="Internet Data Handling"160 accesskey="P">previous</a> |</li>161 162 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>163 <li><a href="https://www.python.org/">Python</a> »</li>164 <li class="switchers">165 <div class="language_switcher_placeholder"></div>166 <div class="version_switcher_placeholder"></div>167 </li>168 <li>169 170 </li>171 <li id="cpython-language-and-version">172 <a href="../index.html">3.15.0a6 Documentation</a> »173 </li>174 175 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>176 <li class="nav-item nav-item-2"><a href="netdata.html" accesskey="U">Internet Data Handling</a> »</li>177 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> — An email and MIME handling package</a></li>178 <li class="right">179 180 181 <div class="inline-search" role="search">182 <form class="inline-search" action="../search.html" method="get">183 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">184 <input type="submit" value="Go">185 </form>186 </div>187 |188 </li>189 <li class="right">190<label class="theme-selector-label">191 Theme192 <select class="theme-selector" oninput="activateTheme(this.value)">193 <option value="auto" selected>Auto</option>194 <option value="light">Light</option>195 <option value="dark">Dark</option>196 </select>197</label> |</li>198 199 </ul>200 </div> 201 202 <div class="document">203 <div class="documentwrapper">204 <div class="bodywrapper">205 <div class="body" role="main">206 207 <section id="module-email">208<span id="email-an-email-and-mime-handling-package"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> — An email and MIME handling package<a class="headerlink" href="#module-email" title="Link to this heading">¶</a></h1>209<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/email/__init__.py">Lib/email/__init__.py</a></p>210<hr class="docutils" />211<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> package is a library for managing email messages. It is212specifically <em>not</em> designed to do any sending of email messages to SMTP213(<span class="target" id="index-0"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2821.html"><strong>RFC 2821</strong></a>), NNTP, or other servers; those are functions of modules such as214<a class="reference internal" href="smtplib.html#module-smtplib" title="smtplib: SMTP protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">smtplib</span></code></a>. The <code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> package attempts to be as215RFC-compliant as possible, supporting <span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5322.html"><strong>RFC 5322</strong></a> and <span class="target" id="index-2"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc6532.html"><strong>RFC 6532</strong></a>, as well as216such MIME-related RFCs as <span class="target" id="index-3"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2045.html"><strong>RFC 2045</strong></a>, <span class="target" id="index-4"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2046.html"><strong>RFC 2046</strong></a>, <span class="target" id="index-5"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2047.html"><strong>RFC 2047</strong></a>, <span class="target" id="index-6"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2183.html"><strong>RFC 2183</strong></a>,217and <span class="target" id="index-7"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2231.html"><strong>RFC 2231</strong></a>.</p>218<p>The overall structure of the email package can be divided into three major219components, plus a fourth component that controls the behavior of the other220components.</p>221<p>The central component of the package is an “object model” that represents email222messages. An application interacts with the package primarily through the223object model interface defined in the <a class="reference internal" href="email.message.html#module-email.message" title="email.message: The base class representing email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">message</span></code></a> sub-module. The224application can use this API to ask questions about an existing email, to225construct a new email, or to add or remove email subcomponents that themselves226use the same object model interface. That is, following the nature of email227messages and their MIME subcomponents, the email object model is a tree228structure of objects that all provide the <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>229API.</p>230<p>The other two major components of the package are the <a class="reference internal" href="email.parser.html#module-email.parser" title="email.parser: Parse flat text email messages to produce a message object structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">parser</span></code></a> and231the <a class="reference internal" href="email.generator.html#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">generator</span></code></a>. The parser takes the serialized version of an232email message (a stream of bytes) and converts it into a tree of233<a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> objects. The generator takes an234<code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code> and turns it back into a serialized byte235stream. (The parser and generator also handle streams of text characters, but236this usage is discouraged as it is too easy to end up with messages that are237not valid in one way or another.)</p>238<p>The control component is the <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> module. Every239<a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>, every <a class="reference internal" href="email.generator.html#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">generator</span></code></a>, and every240<a class="reference internal" href="email.parser.html#module-email.parser" title="email.parser: Parse flat text email messages to produce a message object structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">parser</span></code></a> has an associated <code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code> object that241controls its behavior. Usually an application only needs to specify the policy242when an <code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code> is created, either by directly243instantiating an <code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code> to create a new email,244or by parsing an input stream using a <code class="xref py py-mod docutils literal notranslate"><span class="pre">parser</span></code>. But the policy can245be changed when the message is serialized using a <code class="xref py py-mod docutils literal notranslate"><span class="pre">generator</span></code>.246This allows, for example, a generic email message to be parsed from disk, but247to serialize it using standard SMTP settings when sending it to an email248server.</p>249<p>The email package does its best to hide the details of the various governing250RFCs from the application. Conceptually the application should be able to251treat the email message as a structured tree of unicode text and binary252attachments, without having to worry about how these are represented when253serialized. In practice, however, it is often necessary to be aware of at254least some of the rules governing MIME messages and their structure,255specifically the names and nature of the MIME “content types” and how they256identify multipart documents. For the most part this knowledge should only be257required for more complex applications, and even then it should only be the258high level structure in question, and not the details of how those structures259are represented. Since MIME content types are used widely in modern internet260software (not just email), this will be a familiar concept to many programmers.</p>261<p>The following sections describe the functionality of the <code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> package.262We start with the <a class="reference internal" href="email.message.html#module-email.message" title="email.message: The base class representing email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">message</span></code></a> object model, which is the primary263interface an application will use, and follow that with the264<a class="reference internal" href="email.parser.html#module-email.parser" title="email.parser: Parse flat text email messages to produce a message object structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">parser</span></code></a> and <a class="reference internal" href="email.generator.html#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">generator</span></code></a> components. Then we cover the265<a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> controls, which completes the treatment of the main266components of the library.</p>267<p>The next three sections cover the exceptions the package may raise and the268defects (non-compliance with the RFCs) that the <a class="reference internal" href="email.parser.html#module-email.parser" title="email.parser: Parse flat text email messages to produce a message object structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">parser</span></code></a> may269detect. Then we cover the <a class="reference internal" href="email.headerregistry.html#module-email.headerregistry" title="email.headerregistry: Automatic Parsing of headers based on the field name"><code class="xref py py-mod docutils literal notranslate"><span class="pre">headerregistry</span></code></a> and the270<a class="reference internal" href="email.contentmanager.html#module-email.contentmanager" title="email.contentmanager: Storing and Retrieving Content from MIME Parts"><code class="xref py py-mod docutils literal notranslate"><span class="pre">contentmanager</span></code></a> sub-components, which provide tools for doing more271detailed manipulation of headers and payloads, respectively. Both of these272components contain features relevant to consuming and producing non-trivial273messages, but also document their extensibility APIs, which will be of interest274to advanced applications.</p>275<p>Following those is a set of examples of using the fundamental parts of the APIs276covered in the preceding sections.</p>277<p>The foregoing represent the modern (unicode friendly) API of the email package.278The remaining sections, starting with the <a class="reference internal" href="email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a>279class, cover the legacy <a class="reference internal" href="email.policy.html#email.policy.compat32" title="email.policy.compat32"><code class="xref py py-data docutils literal notranslate"><span class="pre">compat32</span></code></a> API that deals much more280directly with the details of how email messages are represented. The281<code class="xref py py-data docutils literal notranslate"><span class="pre">compat32</span></code> API does <em>not</em> hide the details of the RFCs from282the application, but for applications that need to operate at that level, they283can be useful tools. This documentation is also relevant for applications that284are still using the <a class="reference internal" href="email.policy.html#email.policy.compat32" title="email.policy.compat32"><code class="xref py py-mod docutils literal notranslate"><span class="pre">compat32</span></code></a> API for backward285compatibility reasons.</p>286<div class="versionchanged">287<p><span class="versionmodified changed">Changed in version 3.6: </span>Docs reorganized and rewritten to promote the new288<a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>/<a class="reference internal" href="email.policy.html#email.policy.EmailPolicy" title="email.policy.EmailPolicy"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailPolicy</span></code></a>289API.</p>290</div>291<p>Contents of the <code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> package documentation:</p>292<div class="toctree-wrapper compound">293<ul>294<li class="toctree-l1"><a class="reference internal" href="email.message.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message</span></code>: Representing an email message</a></li>295<li class="toctree-l1"><a class="reference internal" href="email.parser.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.parser</span></code>: Parsing email messages</a><ul>296<li class="toctree-l2"><a class="reference internal" href="email.parser.html#feedparser-api">FeedParser API</a></li>297<li class="toctree-l2"><a class="reference internal" href="email.parser.html#parser-api">Parser API</a></li>298<li class="toctree-l2"><a class="reference internal" href="email.parser.html#additional-notes">Additional notes</a></li>299</ul>300</li>301<li class="toctree-l1"><a class="reference internal" href="email.generator.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.generator</span></code>: Generating MIME documents</a></li>302<li class="toctree-l1"><a class="reference internal" href="email.policy.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code>: Policy Objects</a></li>303<li class="toctree-l1"><a class="reference internal" href="email.errors.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.errors</span></code>: Exception and Defect classes</a></li>304<li class="toctree-l1"><a class="reference internal" href="email.headerregistry.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.headerregistry</span></code>: Custom Header Objects</a></li>305<li class="toctree-l1"><a class="reference internal" href="email.contentmanager.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.contentmanager</span></code>: Managing MIME Content</a><ul>306<li class="toctree-l2"><a class="reference internal" href="email.contentmanager.html#content-manager-instances">Content Manager Instances</a></li>307</ul>308</li>309<li class="toctree-l1"><a class="reference internal" href="email.examples.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code>: Examples</a></li>310</ul>311</div>312<p>Legacy API:</p>313<div class="toctree-wrapper compound">314<ul>315<li class="toctree-l1"><a class="reference internal" href="email.compat32-message.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message.Message</span></code>: Representing an email message using the <code class="xref py py-data docutils literal notranslate"><span class="pre">compat32</span></code> API</a></li>316<li class="toctree-l1"><a class="reference internal" href="email.mime.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.mime</span></code>: Creating email and MIME objects from scratch</a></li>317<li class="toctree-l1"><a class="reference internal" href="email.header.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.header</span></code>: Internationalized headers</a></li>318<li class="toctree-l1"><a class="reference internal" href="email.charset.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.charset</span></code>: Representing character sets</a></li>319<li class="toctree-l1"><a class="reference internal" href="email.encoders.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.encoders</span></code>: Encoders</a></li>320<li class="toctree-l1"><a class="reference internal" href="email.utils.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.utils</span></code>: Miscellaneous utilities</a></li>321<li class="toctree-l1"><a class="reference internal" href="email.iterators.html"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.iterators</span></code>: Iterators</a></li>322</ul>323</div>324<div class="admonition seealso">325<p class="admonition-title">See also</p>326<dl class="simple">327<dt>Module <a class="reference internal" href="smtplib.html#module-smtplib" title="smtplib: SMTP protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">smtplib</span></code></a></dt><dd><p>SMTP (Simple Mail Transport Protocol) client</p>328</dd>329<dt>Module <a class="reference internal" href="poplib.html#module-poplib" title="poplib: POP3 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">poplib</span></code></a></dt><dd><p>POP (Post Office Protocol) client</p>330</dd>331<dt>Module <a class="reference internal" href="imaplib.html#module-imaplib" title="imaplib: IMAP4 protocol client (requires sockets)."><code class="xref py py-mod docutils literal notranslate"><span class="pre">imaplib</span></code></a></dt><dd><p>IMAP (Internet Message Access Protocol) client</p>332</dd>333<dt>Module <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a></dt><dd><p>Tools for creating, reading, and managing collections of messages on disk334using a variety standard formats.</p>335</dd>336</dl>337</div>338</section>339 340 341 <div class="clearer"></div>342 </div>343 </div>344 </div>345 <div class="sphinxsidebar" role="navigation" aria-label="Main">346 <div class="sphinxsidebarwrapper">347 <div>348 <h4>Previous topic</h4>349 <p class="topless"><a href="netdata.html"350 title="previous chapter">Internet Data Handling</a></p>351 </div>352 <div>353 <h4>Next topic</h4>354 <p class="topless"><a href="email.message.html"355 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message</span></code>: Representing an email message</a></p>356 </div>357 <script>358 document.addEventListener('DOMContentLoaded', () => {359 const title = document.querySelector('meta[property="og:title"]').content;360 const elements = document.querySelectorAll('.improvepage');361 const pageurl = window.location.href.split('?')[0];362 elements.forEach(element => {363 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));364 url.searchParams.set('pagetitle', title);365 url.searchParams.set('pageurl', pageurl);366 url.searchParams.set('pagesource', "library/email.rst");367 element.href = url.toString();368 });369 });370 </script>371 <div role="note" aria-label="source link">372 <h3>This page</h3>373 <ul class="this-page-menu">374 <li><a href="../bugs.html">Report a bug</a></li>375 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>376 <li>377 <a href="https://github.com/python/cpython/blob/main/Doc/library/email.rst?plain=1"378 rel="nofollow">Show source379 </a>380 </li>381 382 </ul>383 </div>384 </div>385<div id="sidebarbutton" title="Collapse sidebar">386<span>«</span>387</div>388 389 </div>390 <div class="clearer"></div>391 </div> 392 <div class="related" role="navigation" aria-label="Related">393 <h3>Navigation</h3>394 <ul>395 <li class="right" style="margin-right: 10px">396 <a href="../genindex.html" title="General Index"397 >index</a></li>398 <li class="right" >399 <a href="../py-modindex.html" title="Python Module Index"400 >modules</a> |</li>401 <li class="right" >402 <a href="email.message.html" title="email.message: Representing an email message"403 >next</a> |</li>404 <li class="right" >405 <a href="netdata.html" title="Internet Data Handling"406 >previous</a> |</li>407 408 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>409 <li><a href="https://www.python.org/">Python</a> »</li>410 <li class="switchers">411 <div class="language_switcher_placeholder"></div>412 <div class="version_switcher_placeholder"></div>413 </li>414 <li>415 416 </li>417 <li id="cpython-language-and-version">418 <a href="../index.html">3.15.0a6 Documentation</a> »419 </li>420 421 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>422 <li class="nav-item nav-item-2"><a href="netdata.html" >Internet Data Handling</a> »</li>423 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> — An email and MIME handling package</a></li>424 <li class="right">425 426 427 <div class="inline-search" role="search">428 <form class="inline-search" action="../search.html" method="get">429 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">430 <input type="submit" value="Go">431 </form>432 </div>433 |434 </li>435 <li class="right">436<label class="theme-selector-label">437 Theme438 <select class="theme-selector" oninput="activateTheme(this.value)">439 <option value="auto" selected>Auto</option>440 <option value="light">Light</option>441 <option value="dark">Dark</option>442 </select>443</label> |</li>444 445 </ul>446 </div> 447 <div class="footer">448 © <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.449 <br>450 This page is licensed under the Python Software Foundation License Version 2.451 <br>452 Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.453 <br>454 455 See <a href="/license.html">History and License</a> for more information.<br>456 457 458 <br>459 460 The Python Software Foundation is a non-profit corporation.461<a href="https://www.python.org/psf/donations/">Please donate.</a>462<br>463 <br>464 Last updated on Mar 10, 2026 (08:58 UTC).465 466 <a href="/bugs.html">Found a bug</a>?467 468 <br>469 470 Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.471 </div>472 473 </body>474</html>