diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /rfc2045/reformime.sgml | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'rfc2045/reformime.sgml')
| -rw-r--r-- | rfc2045/reformime.sgml | 463 |
1 files changed, 463 insertions, 0 deletions
diff --git a/rfc2045/reformime.sgml b/rfc2045/reformime.sgml new file mode 100644 index 0000000..e7f95dd --- /dev/null +++ b/rfc2045/reformime.sgml @@ -0,0 +1,463 @@ +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> +<!-- Copyright 1998 - 2010 Double Precision, Inc. See COPYING for --> +<!-- distribution information. --> +<refentry> + <info><author><firstname>Sam</firstname><surname>Varshavchik</surname><contrib>Author</contrib></author><productname>Courier Mail Server</productname></info> + + <refmeta> + <refentrytitle>reformime</refentrytitle> + <manvolnum>1</manvolnum> + <refmiscinfo class='manual'>Double Precision, Inc.</refmiscinfo> + </refmeta> + + <refnamediv> + <refname>reformime</refname> + <refpurpose>MIME E-mail reformatting tool</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <cmdsynopsis sepchar=" "> + <command moreinfo="none">reformime</command> + <arg rep="repeat" choice="opt"><replaceable>options</replaceable></arg> + </cmdsynopsis> + </refsynopsisdiv> + + <refsect1> + <title>DESCRIPTION</title> + <para> +<command moreinfo="none">reformime</command> is a utility for reformatting +MIME messages.</para> + + <para> +Generally, <command moreinfo="none">reformime</command> expects to see an +<ulink url="http://www.rfc-editor.org/rfc/rfc2045.txt">RFC 2045</ulink> +compliant message on standard input, except in few cases +such as the <option>-m</option> option.</para> + + <para> +If no options are given, <command moreinfo="none">reformime</command> prints the MIME +structure of the message. The output consists of so-called +"MIME reference tags", one per line. +For example:</para> + <blockquote> + <informalexample> +<programlisting format="linespecific"> +1 +1.1 +1.2 +</programlisting> + </informalexample> + </blockquote> + +<para> +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 <literal moreinfo="none">multipart/mixed</literal> +message. "1.1" refers to the first section of the multipart message, which +happens to be a +<literal moreinfo="none">text/plain</literal> section. "1.2" refers to the second +section of the message, which happens to be an +<literal moreinfo="none">application/octet-stream</literal> section.</para> + + <para> +If the message is not a MIME message, or it does not contain any +attachments, <command moreinfo="none">reformime</command> prints only "1", that refers +to the entire message itself:</para> + +<blockquote> + <informalexample> + <programlisting format="linespecific"> +1 +</programlisting> + </informalexample> + </blockquote> + + <para> +Here's the output from +<command moreinfo="none">reformime</command> when the first part of the message was itself a +<literal moreinfo="none">multipart/alternative</literal> section:</para> +<blockquote> + <informalexample> + <programlisting format="linespecific"> +1 +1.1 +1.1.1 +1.1.2 +1.2 +</programlisting> + </informalexample> + </blockquote> + + <para> +Arbitrarily complex MIME constructs are possible.</para> + </refsect1> + <refsect1> + <title>OPTIONS</title> + + <variablelist> + <varlistentry> + <term>-d</term> + <listitem> + <para> +Parse a delivery status notification MIME message +(<ulink url="http://www.rfc-editor.org/rfc/rfc1894.txt">RFC 1894</ulink>). +<command moreinfo="none">reformime</command> +expects to see on standard input a MIME message that consists of +a delivery status notification, as defined by RFC 1894. +<command moreinfo="none">reformime</command> +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 +<command moreinfo="none">reformime</command> +consists of a delivery +status, a space, and the address. +<command moreinfo="none">reformime</command> then terminates with a 0 exit status. +<command moreinfo="none">reformime</command> produces no output and terminates with an exit +status of 1 if the standard input does not contain a delivery status +notification.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-D</term> + <listitem> + <para> +Like the <option>-d</option> except that +<command moreinfo="none">reformime</command> lists the address +found in the <literal moreinfo="none">Original-Recipient:</literal> header, +if it exists.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-e</term> + <listitem> + <para> +Extract the contents of the indicated MIME section, and display it +on standard output. +The <option>-s</option> option is required when +<option>-e</option> is specified. If the +specified section or +sections use either the <literal moreinfo="none">base64</literal> or +<literal moreinfo="none">quoted-printable</literal> encoding method, +<command moreinfo="none">reformime</command> automatically +decodes it. In this case you're better off redirecting the standard output +into a file.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-i</term> + <listitem> + <para> +Display MIME information for each section. <command moreinfo="none">reformime</command> +displays the contents of the +<literal moreinfo="none">Content-Type:</literal> header, any encoding used, +and the character set. +<command moreinfo="none">reformime</command> 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).</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-m</term> + <listitem> + <para> +Create a <literal moreinfo="none">multipart/digest</literal> MIME message digest.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-r</term> + <listitem> + <para> +Rewrite message, adding or standardizing +<ulink url="http://www.rfc-editor.org/rfc/rfc2045.txt">RFC 2045</ulink> +MIME headers.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-r7</term> + <listitem> + <para> +Like <option>-r</option> but also convert <literal moreinfo="none">8bit</literal>-encoded +MIME sections to <literal moreinfo="none">quoted-printable</literal>.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-r8</term> + <listitem> + <para> +Like <option>-r</option> but also convert +<literal moreinfo="none">quoted-printable</literal>-encoded MIME sections to +<literal moreinfo="none">8bit</literal>.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-s <replaceable>section</replaceable></term> + <listitem> + <para> +Display MIME information for this section only. +<replaceable>section</replaceable> is +a MIME specification tag. The <option>-s</option> option is required if +<option>-e</option> is also +specified, and is optional with <option>-i</option>.</para> + + <para> +Multiple sections may be specified by separating them with commas. +<command>reformime</command> processes each section using the other options +that were specified.</para> + + </listitem> + </varlistentry> + <varlistentry> + <term>-x</term> + <listitem> + <para> +Extract the contents of the indicated MIME section to a file.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-X</term> + <listitem> + <para> +Pipe the contents of the indicated MIME section to a program.</para> + </listitem> + </varlistentry> + </variablelist> + + <refsect2> + <title>Extracting RFC 2045 MIME section(s) to file(s)</title> + + <para> +The <option>-x</option> and <option>-X</option> options extract a specific +MIME section to a file or to a pipe to an external program. +Use the <option>-s</option> option to identify the MIME section +to extract. If the <option>-s</option> option is not specified, +every MIME section in the message is extracted, one at a time. +If <option>-s</option> lists multiple sections, each section gets +extracted separately. +<literal moreinfo="none">quoted-printable</literal> and <literal moreinfo="none">base64</literal> encoding are +automatically decoded.</para> + + <variablelist> + <varlistentry> + <term>-x</term> + <listitem> + <para> +Interactive extraction. <command moreinfo="none">reformime</command> 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. <command moreinfo="none">reformime</command> +prompts with a default filename. +<command moreinfo="none">reformime</command> tries to choose the default +filename based on the MIME headers, if possible. If not, the default +filename will be <literal moreinfo="none">attachment1.dat</literal> (if the -s option is not +specified, the next filename will be <literal moreinfo="none">attachment2.dat</literal>, +and so on).</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-x<replaceable>PREFIX</replaceable></term> + <listitem> + <para> +Automatic extraction. <command moreinfo="none">reformime</command> automatically +extracts one or more MIME sections, and saves them to a file. +The filename is formed by taking +<replaceable>PREFIX</replaceable>, and appending the default filename to it. +Note that there's no space between "-x" and "PREFIX". For example:</para> + <blockquote> + <informalexample> + <programlisting format="linespecific"> +reformime -xfiles- +</programlisting> + </informalexample> + </blockquote> + <para> +This command saves MIME sections as +<filename moreinfo="none">files-attachment1.dat</filename>, then +<filename moreinfo="none">files-attachment2.dat</filename>, etc. +<command moreinfo="none">reformime</command> tries to append the filename specified in the +MIME headers for each section, where possible. +<command moreinfo="none">reformime</command> replaces all suspect characters with the +underscore character.</para> + </listitem> + </varlistentry> + <varlistentry> + <term>-X prog arg1 arg2 ...</term> + <listitem> + <para> +The <option>-X</option> option must be the last option to +<command moreinfo="none">reformime</command>. <command moreinfo="none">reformime</command> runs an external +program <command moreinfo="none">prog</command>, and pipes the contents of the MIME section to +the program. <command moreinfo="none">reformime</command> sets the environment variable +<envar>CONTENT_TYPE</envar> to the MIME content type. The environment +variable <envar>FILENAME</envar> gets set to the default filename of +<command moreinfo="none">reformime</command>'s liking. If the <option>-s</option> option is +not specified, the program runs once +for every MIME section in the message. +The external program, <command moreinfo="none">prog</command> must terminate with a zero +exit status in order for <command moreinfo="none">reformime</command> to proceed to the +next MIME section in the message (or the next section specified by +<option>-s</option>). +In any case, if <command moreinfo="none">prog</command> terminates with a non-zero exit +status, <command moreinfo="none">reformime</command> terminates with the exit status of +20 plus <command moreinfo="none">prog</command>'s exit status.</para> + </listitem> + </varlistentry> + </variablelist> + + <note> + <para> +<command moreinfo="none">reformime</command> extracts every MIME section in the message +unless the <option>-s</option> option is specified. +This includes even the <literal moreinfo="none">text/plain</literal> MIME +content that usually precedes a binary attachment.</para> + </note> + </refsect2> + + <refsect2> + <title>Adding RFC 2045 MIME headers</title> + + <para> +The <option>-r</option> option performs the following actions:</para> + + <para> +If there is no <literal moreinfo="none">Mime-Version:</literal>, +<literal moreinfo="none">Content-Type:</literal>, or +<literal moreinfo="none">Content-Transfer-Encoding:</literal> header, +<command moreinfo="none">reformime</command> adds one.</para> + + <para> +If the <literal moreinfo="none">Content-Transfer-Encoding:</literal> header contains +<literal moreinfo="none">8bit</literal> or <literal moreinfo="none">raw</literal>, but only seven-bit data is +found, <command moreinfo="none">reformime</command> changes +the <literal moreinfo="none">Content-Transfer-Encoding</literal> header to +<literal moreinfo="none">7bit</literal>.</para> + + <para><option>-r7</option> does the same thing, but also converts +<literal moreinfo="none">8bit</literal>-encoded content that contains eight-bit characters to +<literal moreinfo="none">quoted-printable</literal> encoding.</para> + + <para><option>-r8</option> does the same thing, but also converts +<literal moreinfo="none">quoted-printable</literal>-encoded content to +<literal moreinfo="none">8bit</literal>, except in some situations.</para> + </refsect2> + + <refsect2> + <title>Creating <literal moreinfo="none">multipart/digest</literal> MIME digests</title> + + <para>The <option>-m</option> option creates a MIME digest. +<command moreinfo="none">reformime</command> 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. +<command moreinfo="none">reformime</command> splices all files into a +<command moreinfo="none">multipart/digest</command> MIME section, +and writes it to standard output.</para> + </refsect2> + + <refsect2> + <title>Translating MIME headers</title> + + <para> +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.</para> + + <variablelist> + <varlistentry> + <term>-h "<replaceable>header</replaceable>"</term> + <listitem> + <para> +Decode a MIME-encoded "<replaceable>header</replaceable>" and print the +decoded 8-bit content on standard output. +The decoding gets carried out as if the contents occurred in the +<quote>Subject</quote> header. +Example:</para> + <informalexample> + <programlisting format="linespecific"> +$ reformime -h '=?iso-8859-1?Q?H=F3la!?=' +Hóla! +</programlisting> + </informalexample> + </listitem> + </varlistentry> + + <varlistentry> + <term>-H "<replaceable>header</replaceable>"</term> + <listitem> + <para> +Like <option>-h</option> except that <replaceable>header</replaceable> is +parsed as a list of +email addresses, like <quote>From</quote> or <quote>To</quote>.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term>-o "<replaceable>text</replaceable>"</term> + <listitem> + <para> +MIME-encode "<replaceable>text</replaceable>", and print the results +on standard output.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term>-O "<replaceable>text</replaceable>"</term> + <listitem> + <para> +Like the <option>-o option</option>, except that +<replaceable>text</replaceable> +is a structured header with RFC 2822 addresses.</para> + </listitem> + </varlistentry> + + <varlistentry> + <term>-c "<replaceable>charset</replaceable>"</term> + <listitem> + <para> + Use <replaceable>charset</replaceable> as the character set + setting, by the + <option>-h</option>, + <option>-H</option>, + <option>-o</option> and + <option>-O</option> options. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term>-u</term> + + <listitem> + <para> + This <quote>undocumented</quote> 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. + </para> + + <para> + The standard output receives a concatenated amalgam of the + headers and <quote>text</quote> 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 + <literal>quoted-printable</literal> and <literal>base64</literal> + transfer encodings of <quote>text</quote> MIME objects. + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect2> + </refsect1> + + <refsect1> + <title>SEE ALSO</title> + + <para> +<ulink url="reformail.html"><citerefentry><refentrytitle>reformail</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>, +<citerefentry><refentrytitle>sendmail</refentrytitle><manvolnum>8</manvolnum></citerefentry>, +<ulink url="mailbot.html"><citerefentry><refentrytitle>mailbot</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>, +<ulink url="maildrop.html"><citerefentry><refentrytitle>maildrop</refentrytitle><manvolnum>1</manvolnum></citerefentry></ulink>, +<ulink url="maildropfilter.html"><citerefentry><refentrytitle>maildropfilter</refentrytitle><manvolnum>5</manvolnum></citerefentry></ulink>, +<citerefentry><refentrytitle>egrep</refentrytitle><manvolnum>1</manvolnum></citerefentry>, +<citerefentry><refentrytitle>grep</refentrytitle><manvolnum>1</manvolnum></citerefentry>, +<citerefentry><refentrytitle>sendmail</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para> + </refsect1> +</refentry> |
