<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>18.9. mimify — MIME processing of mail messages — Python v2.6.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.6.6',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python v2.6.6 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="Python v2.6.6 documentation" href="../index.html" />
<link rel="up" title="18. Internet Data Handling" href="netdata.html" />
<link rel="next" title="18.10. multifile — Support for files containing distinct parts" href="multifile.html" />
<link rel="prev" title="18.8. MimeWriter — Generic MIME file writer" href="mimewriter.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
accesskey="M">modules</a> |</li>
<li class="right" >
<a href="multifile.html" title="18.10. multifile — Support for files containing distinct parts"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="mimewriter.html" title="18.8. MimeWriter — Generic MIME file writer"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="netdata.html" accesskey="U">18. Internet Data Handling</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-mimify">
<h1>18.9. <tt class="xref docutils literal"><span class="pre">mimify</span></tt> — MIME processing of mail messages<a class="headerlink" href="#module-mimify" title="Permalink to this headline">¶</a></h1>
<p class="deprecated">
<span class="versionmodified">Deprecated since version 2.3: </span>The <a title="Package supporting the parsing, manipulating, and generating email messages, including MIME documents." class="reference external" href="email.html#module-email"><tt class="xref docutils literal"><span class="pre">email</span></tt></a> package should be used in preference to the <tt class="xref docutils literal"><span class="pre">mimify</span></tt>
module. This module is present only to maintain backward compatibility.</p>
<p>The <tt class="xref docutils literal"><span class="pre">mimify</span></tt> module defines two functions to convert mail messages to and
from MIME format. The mail message can be either a simple message or a
so-called multipart message. Each part is treated separately. Mimifying (a part
of) a message entails encoding the message as quoted-printable if it contains
any characters that cannot be represented using 7-bit ASCII. Unmimifying (a
part of) a message entails undoing the quoted-printable encoding. Mimify and
unmimify are especially useful when a message has to be edited before being
sent. Typical use would be:</p>
<div class="highlight-python"><pre>unmimify message
edit message
mimify message
send message</pre>
</div>
<p>The modules defines the following user-callable functions and user-settable
variables:</p>
<dl class="function">
<dt id="mimify.mimify">
<tt class="descclassname">mimify.</tt><tt class="descname">mimify</tt><big>(</big><em>infile</em>, <em>outfile</em><big>)</big><a class="headerlink" href="#mimify.mimify" title="Permalink to this definition">¶</a></dt>
<dd>Copy the message in <em>infile</em> to <em>outfile</em>, converting parts to quoted-printable
and adding MIME mail headers when necessary. <em>infile</em> and <em>outfile</em> can be file
objects (actually, any object that has a <tt class="xref docutils literal"><span class="pre">readline()</span></tt> method (for <em>infile</em>)
or a <tt class="xref docutils literal"><span class="pre">write()</span></tt> method (for <em>outfile</em>)) or strings naming the files. If
<em>infile</em> and <em>outfile</em> are both strings, they may have the same value.</dd></dl>
<dl class="function">
<dt id="mimify.unmimify">
<tt class="descclassname">mimify.</tt><tt class="descname">unmimify</tt><big>(</big><em>infile</em>, <em>outfile</em><span class="optional">[</span>, <em>decode_base64</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#mimify.unmimify" title="Permalink to this definition">¶</a></dt>
<dd>Copy the message in <em>infile</em> to <em>outfile</em>, decoding all quoted-printable parts.
<em>infile</em> and <em>outfile</em> can be file objects (actually, any object that has a
<tt class="xref docutils literal"><span class="pre">readline()</span></tt> method (for <em>infile</em>) or a <tt class="xref docutils literal"><span class="pre">write()</span></tt> method (for
<em>outfile</em>)) or strings naming the files. If <em>infile</em> and <em>outfile</em> are both
strings, they may have the same value. If the <em>decode_base64</em> argument is
provided and tests true, any parts that are coded in the base64 encoding are
decoded as well.</dd></dl>
<dl class="function">
<dt id="mimify.mime_decode_header">
<tt class="descclassname">mimify.</tt><tt class="descname">mime_decode_header</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#mimify.mime_decode_header" title="Permalink to this definition">¶</a></dt>
<dd>Return a decoded version of the encoded header line in <em>line</em>. This only
supports the ISO 8859-1 charset (Latin-1).</dd></dl>
<dl class="function">
<dt id="mimify.mime_encode_header">
<tt class="descclassname">mimify.</tt><tt class="descname">mime_encode_header</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#mimify.mime_encode_header" title="Permalink to this definition">¶</a></dt>
<dd>Return a MIME-encoded version of the header line in <em>line</em>.</dd></dl>
<dl class="data">
<dt id="mimify.MAXLEN">
<tt class="descclassname">mimify.</tt><tt class="descname">MAXLEN</tt><a class="headerlink" href="#mimify.MAXLEN" title="Permalink to this definition">¶</a></dt>
<dd>By default, a part will be encoded as quoted-printable when it contains any
non-ASCII characters (characters with the 8th bit set), or if there are any
lines longer than <a title="mimify.MAXLEN" class="reference internal" href="#mimify.MAXLEN"><tt class="xref docutils literal"><span class="pre">MAXLEN</span></tt></a> characters (default value 200).</dd></dl>
<dl class="data">
<dt id="mimify.CHARSET">
<tt class="descclassname">mimify.</tt><tt class="descname">CHARSET</tt><a class="headerlink" href="#mimify.CHARSET" title="Permalink to this definition">¶</a></dt>
<dd>When not specified in the mail headers, a character set must be filled in. The
string used is stored in <a title="mimify.CHARSET" class="reference internal" href="#mimify.CHARSET"><tt class="xref docutils literal"><span class="pre">CHARSET</span></tt></a>, and the default value is ISO-8859-1
(also known as Latin1 (latin-one)).</dd></dl>
<p>This module can also be used from the command line. Usage is as follows:</p>
<div class="highlight-python"><pre>mimify.py -e [-l length] [infile [outfile]]
mimify.py -d [-b] [infile [outfile]]</pre>
</div>
<p>to encode (mimify) and decode (unmimify) respectively. <em>infile</em> defaults to
standard input, <em>outfile</em> defaults to standard output. The same file can be
specified for input and output.</p>
<p>If the <strong>-l</strong> option is given when encoding, if there are any lines longer than
the specified <em>length</em>, the containing part will be encoded.</p>
<p>If the <strong>-b</strong> option is given when decoding, any base64 parts will be decoded as
well.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt>Module <a title="Encode and decode files using the MIME quoted-printable encoding." class="reference external" href="quopri.html#module-quopri"><tt class="xref docutils literal"><span class="pre">quopri</span></tt></a></dt>
<dd>Encode and decode MIME quoted-printable files.</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="mimewriter.html"
title="previous chapter">18.8. <tt class="docutils literal docutils literal docutils literal"><span class="pre">MimeWriter</span></tt> — Generic MIME file writer</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="multifile.html"
title="next chapter">18.10. <tt class="docutils literal"><span class="pre">multifile</span></tt> — Support for files containing distinct parts</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li><a href="../_sources/library/mimify.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
>modules</a> |</li>
<li class="right" >
<a href="multifile.html" title="18.10. multifile — Support for files containing distinct parts"
>next</a> |</li>
<li class="right" >
<a href="mimewriter.html" title="18.8. MimeWriter — Generic MIME file writer"
>previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="netdata.html" >18. Internet Data Handling</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
<br />
The Python Software Foundation is a non-profit corporation.
<a href="http://www.python.org/psf/donations/">Please donate.</a>
<br />
Last updated on Jul 20, 2011.
<a href="../bugs.html">Found a bug</a>?
<br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.6.
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez