View file File name : reformime.html Content :<?xml version="1.0"?> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>reformime</title><link rel="stylesheet" type="text/css" href="style.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"/><link rel="home" href="#idm255220000832" title="reformime"/><link xmlns="" rel="stylesheet" type="text/css" href="manpage.css"/><meta xmlns="" name="MSSmartTagsPreventParsing" content="TRUE"/><link xmlns="" rel="icon" href="icon.gif" type="image/gif"/><!-- Copyright 1998 - 2009 Double Precision, Inc. See COPYING for distribution information. --></head><body><div class="refentry"><a id="idm255220000832" shape="rect"> </a><div class="titlepage"/><div class="refnamediv"><h2>Name</h2><p>reformime — MIME E-mail reformatting tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">reformime</code> [<em class="replaceable"><code>options</code></em>...]</p></div></div><div class="refsect1"><a id="idm255224454544" shape="rect"> </a><h2>DESCRIPTION</h2><p> <span class="command"><strong>reformime</strong></span> is a utility for reformatting MIME messages.</p><p> Generally, <span class="command"><strong>reformime</strong></span> expects to see an <a class="ulink" href="http://www.rfc-editor.org/rfc/rfc2045.txt" target="_top" shape="rect">RFC 2045</a> compliant message on standard input, except in few cases such as the <code class="option">-m</code> option.</p><p> If no options are given, <span class="command"><strong>reformime</strong></span> prints the MIME structure of the message. The output consists of so-called "MIME reference tags", one per line. For example:</p><div class="blockquote"><blockquote class="blockquote"><div class="informalexample"><pre class="programlisting" xml:space="preserve"> 1 1.1 1.2 </pre></div></blockquote></div><p> This shows that the message contains two different MIME sections. The first line of the MIME structure output will always contain "1", which refers to the entire message. In this case it happens to be a <code class="literal">multipart/mixed</code> message. "1.1" refers to the first section of the multipart message, which happens to be a <code class="literal">text/plain</code> section. "1.2" refers to the second section of the message, which happens to be an <code class="literal">application/octet-stream</code> section.</p><p> If the message is not a MIME message, or it does not contain any attachments, <span class="command"><strong>reformime</strong></span> prints only "1", that refers to the entire message itself:</p><div class="blockquote"><blockquote class="blockquote"><div class="informalexample"><pre class="programlisting" xml:space="preserve"> 1 </pre></div></blockquote></div><p> Here's the output from <span class="command"><strong>reformime</strong></span> when the first part of the message was itself a <code class="literal">multipart/alternative</code> section:</p><div class="blockquote"><blockquote class="blockquote"><div class="informalexample"><pre class="programlisting" xml:space="preserve"> 1 1.1 1.1.1 1.1.2 1.2 </pre></div></blockquote></div><p> Arbitrarily complex MIME constructs are possible.</p></div><div class="refsect1"><a id="idm255222804272" shape="rect"> </a><h2>OPTIONS</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term">-d</span></dt><dd><p> Parse a delivery status notification MIME message (<a class="ulink" href="http://www.rfc-editor.org/rfc/rfc1894.txt" target="_top" shape="rect">RFC 1894</a>). <span class="command"><strong>reformime</strong></span> expects to see on standard input a MIME message that consists of a delivery status notification, as defined by RFC 1894. <span class="command"><strong>reformime</strong></span> reads the message and prints on standard output a list of addresses and their corresponding delivery status, as specified in the delivery status notification. Each line printed by <span class="command"><strong>reformime</strong></span> consists of a delivery status, a space, and the address. <span class="command"><strong>reformime</strong></span> then terminates with a 0 exit status. <span class="command"><strong>reformime</strong></span> produces no output and terminates with an exit status of 1 if the standard input does not contain a delivery status notification.</p></dd><dt><span class="term">-D</span></dt><dd><p> Like the <code class="option">-d</code> except that <span class="command"><strong>reformime</strong></span> lists the address found in the <code class="literal">Original-Recipient:</code> header, if it exists.</p></dd><dt><span class="term">-e</span></dt><dd><p> Extract the contents of the indicated MIME section, and display it on standard output. The <code class="option">-s</code> option is required when <code class="option">-e</code> is specified. If the specified section or sections use either the <code class="literal">base64</code> or <code class="literal">quoted-printable</code> encoding method, <span class="command"><strong>reformime</strong></span> automatically decodes it. In this case you're better off redirecting the standard output into a file.</p></dd><dt><span class="term">-i</span></dt><dd><p> Display MIME information for each section. <span class="command"><strong>reformime</strong></span> displays the contents of the <code class="literal">Content-Type:</code> header, any encoding used, and the character set. <span class="command"><strong>reformime</strong></span> also displays the byte offset in the message where each section starts and ends (and where the actual contents of the section start, after skipping all the headers).</p></dd><dt><span class="term">-m</span></dt><dd><p> Create a <code class="literal">multipart/digest</code> MIME message digest.</p></dd><dt><span class="term">-r</span></dt><dd><p> Rewrite message, adding or standardizing <a class="ulink" href="http://www.rfc-editor.org/rfc/rfc2045.txt" target="_top" shape="rect">RFC 2045</a> MIME headers.</p></dd><dt><span class="term">-r7</span></dt><dd><p> Like <code class="option">-r</code> but also convert <code class="literal">8bit</code>-encoded MIME sections to <code class="literal">quoted-printable</code>.</p></dd><dt><span class="term">-r8</span></dt><dd><p> Like <code class="option">-r</code> but also convert <code class="literal">quoted-printable</code>-encoded MIME sections to <code class="literal">8bit</code>.</p></dd><dt><span class="term">-s <em class="replaceable"><code>section</code></em></span></dt><dd><p> Display MIME information for this section only. <em class="replaceable"><code>section</code></em> is a MIME specification tag. The <code class="option">-s</code> option is required if <code class="option">-e</code> is also specified, and is optional with <code class="option">-i</code>.</p><p> Multiple sections may be specified by separating them with commas. <span class="command"><strong>reformime</strong></span> processes each section using the other options that were specified.</p></dd><dt><span class="term">-x</span></dt><dd><p> Extract the contents of the indicated MIME section to a file.</p></dd><dt><span class="term">-X</span></dt><dd><p> Pipe the contents of the indicated MIME section to a program.</p></dd></dl></div><div class="refsect2"><a id="idm255222765808" shape="rect"> </a><h3>Extracting RFC 2045 MIME section(s) to file(s)</h3><p> The <code class="option">-x</code> and <code class="option">-X</code> options extract a specific MIME section to a file or to a pipe to an external program. Use the <code class="option">-s</code> option to identify the MIME section to extract. If the <code class="option">-s</code> option is not specified, every MIME section in the message is extracted, one at a time. If <code class="option">-s</code> lists multiple sections, each section gets extracted separately. <code class="literal">quoted-printable</code> and <code class="literal">base64</code> encoding are automatically decoded.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">-x</span></dt><dd><p> Interactive extraction. <span class="command"><strong>reformime</strong></span> prints the MIME content type of each section. Answer with 'y' or 'Y' to extract the MIME section. Specify the filename at the next prompt. <span class="command"><strong>reformime</strong></span> prompts with a default filename. <span class="command"><strong>reformime</strong></span> tries to choose the default filename based on the MIME headers, if possible. If not, the default filename will be <code class="literal">attachment1.dat</code> (if the -s option is not specified, the next filename will be <code class="literal">attachment2.dat</code>, and so on).</p></dd><dt><span class="term">-x<em class="replaceable"><code>PREFIX</code></em></span></dt><dd><p> Automatic extraction. <span class="command"><strong>reformime</strong></span> automatically extracts one or more MIME sections, and saves them to a file. The filename is formed by taking <em class="replaceable"><code>PREFIX</code></em>, and appending the default filename to it. Note that there's no space between "-x" and "PREFIX". For example:</p><div class="blockquote"><blockquote class="blockquote"><div class="informalexample"><pre class="programlisting" xml:space="preserve"> reformime -xfiles- </pre></div></blockquote></div><p> This command saves MIME sections as <code class="filename">files-attachment1.dat</code>, then <code class="filename">files-attachment2.dat</code>, etc. <span class="command"><strong>reformime</strong></span> tries to append the filename specified in the MIME headers for each section, where possible. <span class="command"><strong>reformime</strong></span> replaces all suspect characters with the underscore character.</p></dd><dt><span class="term">-X prog arg1 arg2 ...</span></dt><dd><p> The <code class="option">-X</code> option must be the last option to <span class="command"><strong>reformime</strong></span>. <span class="command"><strong>reformime</strong></span> runs an external program <span class="command"><strong>prog</strong></span>, and pipes the contents of the MIME section to the program. <span class="command"><strong>reformime</strong></span> sets the environment variable <code class="envar">CONTENT_TYPE</code> to the MIME content type. The environment variable <code class="envar">FILENAME</code> gets set to the default filename of <span class="command"><strong>reformime</strong></span>'s liking. If the <code class="option">-s</code> option is not specified, the program runs once for every MIME section in the message. The external program, <span class="command"><strong>prog</strong></span> must terminate with a zero exit status in order for <span class="command"><strong>reformime</strong></span> to proceed to the next MIME section in the message (or the next section specified by <code class="option">-s</code>). In any case, if <span class="command"><strong>prog</strong></span> terminates with a non-zero exit status, <span class="command"><strong>reformime</strong></span> terminates with the exit status of 20 plus <span class="command"><strong>prog</strong></span>'s exit status.</p></dd></dl></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p> <span class="command"><strong>reformime</strong></span> extracts every MIME section in the message unless the <code class="option">-s</code> option is specified. This includes even the <code class="literal">text/plain</code> MIME content that usually precedes a binary attachment.</p></div></div><div class="refsect2"><a id="idm255218960144" shape="rect"> </a><h3>Adding RFC 2045 MIME headers</h3><p> The <code class="option">-r</code> option performs the following actions:</p><p> If there is no <code class="literal">Mime-Version:</code>, <code class="literal">Content-Type:</code>, or <code class="literal">Content-Transfer-Encoding:</code> header, <span class="command"><strong>reformime</strong></span> adds one.</p><p> If the <code class="literal">Content-Transfer-Encoding:</code> header contains <code class="literal">8bit</code> or <code class="literal">raw</code>, but only seven-bit data is found, <span class="command"><strong>reformime</strong></span> changes the <code class="literal">Content-Transfer-Encoding</code> header to <code class="literal">7bit</code>.</p><p><code class="option">-r7</code> does the same thing, but also converts <code class="literal">8bit</code>-encoded content that contains eight-bit characters to <code class="literal">quoted-printable</code> encoding.</p><p><code class="option">-r8</code> does the same thing, but also converts <code class="literal">quoted-printable</code>-encoded content to <code class="literal">8bit</code>, except in some situations.</p></div><div class="refsect2"><a id="idm255220933056" shape="rect"> </a><h3>Creating <code class="literal">multipart/digest</code> MIME digests</h3><p>The <code class="option">-m</code> option creates a MIME digest. <span class="command"><strong>reformime</strong></span> reads a list of filenames on standard input. Each line read from standard input contains the name of a file that is presumed to contain an RFC 2822-formatted message. <span class="command"><strong>reformime</strong></span> splices all files into a <span class="command"><strong>multipart/digest</strong></span> MIME section, and writes it to standard output.</p></div><div class="refsect2"><a id="idm255222147536" shape="rect"> </a><h3>Translating MIME headers</h3><p> The following options do not read a message from standard input. These options process MIME headers via the command line, and are designed to be conveniently used by mail-handling scripts.</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">-h "<em class="replaceable"><code>header</code></em>"</span></dt><dd><p> Decode a MIME-encoded "<em class="replaceable"><code>header</code></em>" and print the decoded 8-bit content on standard output. The decoding gets carried out as if the contents occurred in the <span class="quote">“<span class="quote">Subject</span>”</span> header. Example:</p><div class="informalexample"><pre class="programlisting" xml:space="preserve"> $ reformime -h '=?iso-8859-1?Q?H=F3la!?=' Hóla! </pre></div></dd><dt><span class="term">-H "<em class="replaceable"><code>header</code></em>"</span></dt><dd><p> Like <code class="option">-h</code> except that <em class="replaceable"><code>header</code></em> is parsed as a list of email addresses, like <span class="quote">“<span class="quote">From</span>”</span> or <span class="quote">“<span class="quote">To</span>”</span>.</p></dd><dt><span class="term">-o "<em class="replaceable"><code>text</code></em>"</span></dt><dd><p> MIME-encode "<em class="replaceable"><code>text</code></em>", and print the results on standard output.</p></dd><dt><span class="term">-O "<em class="replaceable"><code>text</code></em>"</span></dt><dd><p> Like the <code class="option">-o option</code>, except that <em class="replaceable"><code>text</code></em> is a structured header with RFC 2822 addresses.</p></dd><dt><span class="term">-c "<em class="replaceable"><code>charset</code></em>"</span></dt><dd><p> Use <em class="replaceable"><code>charset</code></em> as the character set setting, by the <code class="option">-h</code>, <code class="option">-H</code>, <code class="option">-o</code> and <code class="option">-O</code> options. </p></dd><dt><span class="term">-u</span></dt><dd><p> This <span class="quote">“<span class="quote">undocumented</span>”</span> option reads a MIME message on standard input, and converts its contents to an UTF-8-encoded character stream, which is written to standard output. </p><p> The standard output receives a concatenated amalgam of the headers and <span class="quote">“<span class="quote">text</span>”</span> MIME object data. It is meant to be used as part of a generic search function. This option decodes various kinds of header MIME encoding, the <code class="literal">quoted-printable</code> and <code class="literal">base64</code> transfer encodings of <span class="quote">“<span class="quote">text</span>”</span> MIME objects. </p></dd></dl></div></div></div><div class="refsect1"><a id="idm255221166624" shape="rect"> </a><h2>SEE ALSO</h2><p> <a class="ulink" href="reformail.html" target="_top" shape="rect"><span class="citerefentry"><span class="refentrytitle">reformail</span>(1)</span></a>, <span class="citerefentry"><span class="refentrytitle">sendmail</span>(8)</span>, <a class="ulink" href="mailbot.html" target="_top" shape="rect"><span class="citerefentry"><span class="refentrytitle">mailbot</span>(1)</span></a>, <a class="ulink" href="maildrop.html" target="_top" shape="rect"><span class="citerefentry"><span class="refentrytitle">maildrop</span>(1)</span></a>, <a class="ulink" href="maildropfilter.html" target="_top" shape="rect"><span class="citerefentry"><span class="refentrytitle">maildropfilter</span>(5)</span></a>, <span class="citerefentry"><span class="refentrytitle">egrep</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">grep</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">sendmail</span>(8)</span>.</p></div></div></body></html>