<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!-- Generated by pod2coolhtml 1.101
  -- Using Pod::CoolHTML 1.104 , (C) 1997 by Eryq (eryq@enteract.com).
  --
  -- DO NOT EDIT THIS HTML FILE! All your changes will be lost.
  -- Edit the POD or Perl file that was used to create it.
  -->
<HTML>

<HEAD>
<TITLE>MIME::Tools</TITLE>
</HEAD>
<BODY LINK=#C00000 ALINK=#FF2020 VLINK=#900000>
<A NAME="__top"> </A><CENTER><TABLE BORDER=2 CELLPADDING=2 WIDTH=100%>

<TR>
<TD WIDTH=25% ALIGN=CENTER><B><FONT SIZE=+1>
MIME::Tools</FONT></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Body.pm.html">MIME::Body</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Decoder.pm.html">MIME::Decoder</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Entity.pm.html">MIME::Entity</A></SMALL></B></TD>

<TR>
<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Head.pm.html">MIME::Head</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="IO.pm.html">MIME::IO</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Latin1.pm.html">MIME::Latin1</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Parser.pm.html">MIME::Parser</A></SMALL></B></TD>

<TR>
<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="ParserBase.pm.html">MIME::ParserBase</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="ToolUtils.pm.html">MIME::ToolUtils</A></SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
MIME::Tools</SMALL></B></TD>

<TD WIDTH=25% ALIGN=CENTER><B><SMALL>
<A HREF="Words.pm.html">MIME::Words</A></SMALL></B></TD>
</TABLE></CENTER>

<P><TABLE WIDTH="100%">

<TR VALIGN="TOP"><TD ALIGN="LEFT"><CENTER>
<H1><FONT SIZE=7 COLOR=#600020><B>MIME::<BR>Tools</B></FONT></H1><IMG SRC="mime-sm.gif" ALT="MIME!"></CENTER>
<TD>
<UL>
<LI><A HREF="#name">NAME</A>
</LI><LI><A HREF="#synopsis">SYNOPSIS</A>
</LI><LI><A HREF="#description">DESCRIPTION</A>
</LI><LI><A HREF="#a_quick_tour">A QUICK TOUR</A>
</LI><UL>
<LI><A HREF="#overview_of_the_classes">Overview of the classes</A>
</LI><LI><A HREF="#parsing_in_a_nutshell">Parsing, in a nutshell</A>
</LI><LI><A HREF="#composing_in_a_nutshell">Composing, in a nutshell</A>
</LI><LI><A HREF="#encodingdecoding_in_a_nutshell">Encoding/decoding, in a nutshell</A>
</LI><LI><A HREF="#other_stuff_you_can_do">Other stuff you can do</A>
</LI><LI><A HREF="#good_advice">Good advice</A>
</LI></UL>
<LI><A HREF="#notes">NOTES</A>
</LI><UL>
<LI><A HREF="#terminology">Terminology</A>
</LI><LI><A HREF="#compatibility">Compatibility</A>
</LI><LI><A HREF="#design_issues">Design issues</A>
</LI><LI><A HREF="#questionable_practices">Questionable practices</A>
</LI></UL>
<LI><A HREF="#a_mime_primer">A MIME PRIMER</A>
</LI><UL>
<LI><A HREF="#content_types">Content types</A>
</LI><LI><A HREF="#content_transfer_encodings">Content transfer encodings</A>
</LI></UL>
<LI><A HREF="#terms_and_conditions">TERMS AND CONDITIONS</A>
</LI><LI><A HREF="#support">SUPPORT</A>
</LI><LI><A HREF="#change_log">CHANGE LOG</A>
</LI><LI><A HREF="#author">AUTHOR</A>
</LI><LI><A HREF="#version">VERSION</A>
</LI><LI><A HREF="#acknowledgments">ACKNOWLEDGMENTS</A>
</LI><LI><A HREF="#see_also">SEE ALSO</A>
</LI></UL>

</TABLE>

<P><HR>
<A NAME="name">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
NAME</FONT></H1>
</A>


<P>
MIME-tools - modules for parsing (and creating!) MIME entities


<P><HR>
<A NAME="synopsis">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
SYNOPSIS</FONT></H1>
</A>


<P>
Here's some pretty basic code for <B>parsing a MIME message,</B> and outputting
its decoded components to a given directory:


<P>
<PRE>    use MIME::Parser;</PRE>



<P>
<PRE>    # Create parser, and set the output directory:
    my $parser = new MIME::Parser;
    $parser-&gt;output_dir(&quot;$ENV{HOME}/mimemail&quot;);</PRE>



<P>
<PRE>    # Parse input:
    $entity = $parser-&gt;read(\*STDIN) or die &quot;couldn't parse MIME stream&quot;;</PRE>



<P>
<PRE>    # Take a look at the top-level entity (and any parts it has):
    $entity-&gt;dump_skeleton; </PRE>



<P>
Here's some code which <B>composes and sends a MIME message</B> containing 
three parts: a text file, an attached GIF, and some more text:


<P>
<PRE>    use MIME::Entity;</PRE>



<P>
<PRE>    # Create the top-level, and set up the mail headers:
    $top = build MIME::Entity Type    =&gt;&quot;multipart/mixed&quot;,
                              From    =&gt; &quot;me\@myhost.com&quot;,
	                      To      =&gt; &quot;you\@yourhost.com&quot;,
                              Subject =&gt; &quot;Hello, nurse!&quot;;</PRE>



<P>
<PRE>    # Part #1: a simple text document: 
    attach $top  Path=&gt;&quot;./testin/short.txt&quot;;</PRE>



<P>
<PRE>    # Part #2: a GIF file:
    attach $top  Path        =&gt; &quot;./docs/mime-sm.gif&quot;,
                 Type        =&gt; &quot;image/gif&quot;,
                 Encoding    =&gt; &quot;base64&quot;;</PRE>



<P>
<PRE>    # Part #3: some literal text:
    attach $top  Data=&gt;$message;</PRE>



<P>
<PRE>    # Send it:
    open MAIL, &quot;| /usr/lib/sendmail -t -i&quot; or die &quot;open: $!&quot;;
    $top-&gt;print(\*MAIL);
    close MAIL;</PRE>



<P><HR>
<A NAME="description">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
DESCRIPTION</FONT></H1>
</A>


<P>
MIME-tools is a collection of Perl5 MIME:: modules for parsing, decoding,
<I>and generating</I> single- or multipart (even nested multipart) MIME 
messages.  (Yes, kids, that means you can send messages with attached 
GIF files).


<P><HR>
<A NAME="a_quick_tour">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
A QUICK TOUR</FONT></H1>
</A>


<P><HR>
<A NAME="overview_of_the_classes">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Overview of the classes</FONT></H2>
</A>


<P>
Here are the classes you'll generally be dealing with directly:


<P>
<PRE>           .------------.       .------------.           
           | MIME::     |------&gt;| MIME::     |
           | Parser     |  isa  | ParserBase |   
           `------------'       `------------'
              | parse()
              | returns a...
              |
              |
              |
              |    head()       .--------.
              |    returns...   | MIME:: | get()
              V       .--------&gt;| Head   | etc... 
           .--------./          `--------'      
     .---&gt; | MIME:: | 
     `-----| Entity |           .--------. 
   parts() `--------'\          | MIME:: | 
   returns            `--------&gt;| Body   |
   sub-entities    bodyhandle() `--------'
   (if any)        returns...       | open() 
                                    | returns...
                                    | 
                                    V  
                                .--------. read()    
                                | IO::   | getline()  
                                | Handle | print()          
                                `--------' etc...    </PRE>



<P>
To illustrate, parsing works this way:

<UL>

<P><LI><B>The &quot;parser&quot; parses the MIME stream.</B>
Every &quot;parser&quot; inherits from the &quot;parser base&quot; class, which does
the real work.  When a message is parsed, the result is an &quot;entity&quot;.


<P><LI><B>An &quot;entity&quot; has a &quot;head&quot; and a &quot;body&quot;.</B>  
Entities are MIME message parts.


<P><LI><B>A &quot;body&quot; knows where the data is.</B>  
You can ask to &quot;open&quot; this data source for <I>reading</I> or <I>writing</I>, 
and you will get back an &quot;I/O handle&quot;.


<P><LI><B>An &quot;I/O handle&quot; knows how to read/write the data.</B>
It is an object that is basically like an IO::Handle or 
a FileHandle... it can be any class, so long as it supports a small,
standard set of methods for reading from or writing to the underlying
data source.

</UL>


<P>
A typical multipart message containing two parts -- a textual greeting 
and an &quot;attached&quot; GIF file -- would be a tree of MIME::Entity objects,
each of which would have its own MIME::Head.  Like this:


<P>
<PRE>    .--------.
    | MIME:: | Content-type: multipart/mixed 
    | Entity | Subject: Happy Samhaine!
    `--------'
         `----.
        parts |
              |   .--------.   
              |---| MIME:: | Content-type: text/plain; charset=us-ascii
              |   | Entity | Content-transfer-encoding: 7bit
              |   `--------' 
              |   .--------.   
              |---| MIME:: | Content-type: image/gif
                  | Entity | Content-transfer-encoding: base64
                  `--------' Content-disposition: inline; filename=&quot;hs.gif&quot;</PRE>



<P><HR>
<A NAME="parsing_in_a_nutshell">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Parsing, in a nutshell</FONT></H2>
</A>


<P>
You usually start by creating an instance of <B><A HREF="Parser.pm.html">MIME::Parser</A></B> (a subclass
of the abstract <B><A HREF="ParserBase.pm.html">MIME::ParserBase</A></B>), and setting up
certain parsing parameters: what directory to save extracted files 
to, how to name the files, etc.


<P>
You then give that instance a readable filehandle on which waits a
MIME message.  If all goes well, you will get back a <B><A HREF="Entity.pm.html">MIME::Entity</A></B>
object (a subclass of <B>Mail::Internet</B>), which consists of...

<UL>

<P><LI>A <B>MIME::Head</B> (a subclass of <B>Mail::Header</B>) which holds the MIME 
header data.


<P><LI>A <B>MIME::Body</B>, which is a object that knows where the body data is.
You ask this object to &quot;open&quot; itself for reading, and it
will hand you back an &quot;I/O handle&quot; for reading the data: this is
a FileHandle-like object, and could be of any class, so long as it
conforms to a subset of the <B>IO::Handle</B> interface.

</UL>


<P>
If the original message was a multipart document, the MIME::Entity
object will have a non-empty list of &quot;parts&quot;, each of which is in 
turn a MIME::Entity (which might also be a multipart entity, etc, 
etc...).


<P>
Internally, the parser (in MIME::ParserBase) asks for instances 
of <B>MIME::Decoder</B> whenever it needs to decode an encoded file.  
MIME::Decoder has a mapping from supported encodings (e.g., 'base64') 
to classes whose instances can decode them.  You can add to this mapping 
to try out new/experiment encodings.  You can also use 
MIME::Decoder by itself.


<P><HR>
<A NAME="composing_in_a_nutshell">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Composing, in a nutshell</FONT></H2>
</A>


<P>
All message composition is done via the <B><A HREF="Entity.pm.html">MIME::Entity</A></B> class.
For single-part messages, you can use the <A HREF="Entity.pm.html#build">MIME::Entity/build</A>
constructor to create MIME entities very easily.


<P>
For multipart messages, you can start by creating a top-level
<CODE>multipart</CODE> entity with <A HREF="Entity.pm.html#build">MIME::Entity/build</A>, and then use
the similar <A HREF="Entity.pm.html#attach">MIME::Entity/attach</A> method to attach parts to 
that message.  <I>Please note:</I> what most people think of as 
&quot;a text message with an attached GIF file&quot; is <I>really</I> a multipart
message with 2 parts: the first being the text message, and the
second being the GIF file.


<P>
When building MIME a entity, you'll have to provide two very important
pieces of information: the <I>content type</I> and the 
<I>content transfer encoding</I>.  The type is usually easy, as it is directly 
determined by the file format; e.g., an HTML file is <CODE>text/html</CODE>.   
The encoding, however, is trickier... for example, some HTML files are
<CODE>7bit</CODE>-compliant, but others might have very long lines and would need to be
sent <CODE>quoted-printable</CODE> for reliability.


<P>
See the section on encoding/decoding for more details, as well as
<A HREF="#a_mime_primer">&quot;A MIME PRIMER&quot;</A>.


<P><HR>
<A NAME="encodingdecoding_in_a_nutshell">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Encoding/decoding, in a nutshell</FONT></H2>
</A>


<P>
The <A HREF="Decoder.pm.html">MIME::Decoder</A> class can be used to <I>encode</I> as well; this is done
when printing MIME entities.  All the standard encodings are supported
(see <A HREF="#a_mime_primer">&quot;A MIME PRIMER&quot;</A> for details):


<P>
<PRE>    Encoding...       Normally used when message contents are...
    -------------------------------------------------------------------
    7bit              7-bit data with under 1000 chars/line, or multipart.
    8bit              8-bit data with under 1000 chars/line.
    binary            8-bit data with possibly long lines (or no line breaks).
    quoted-printable  Text files with some 8-bit chars (e.g., Latin-1 text).
    base64            Binary files.</PRE>



<P>
Which encoding you choose for a given document depends largely on 
(1) what you know about the document's contents (text vs binary), and
(2) whether you need the resulting message to have a reliable encoding
for 7-bit Internet email transport.


<P>
In general, only <CODE>quoted-printable</CODE> and <CODE>base64</CODE> guarantee reliable
transport of all data; the other three &quot;no-encoding&quot; encodings simply
pass the data through, and are only reliable if that data is 7bit ASCII 
with under 1000 characters per line, and has no conflicts with the
multipart boundaries.


<P>
I've considered making it so that the content-type and encoding
can be automatically inferred from the file's path, but that seems
to be asking for trouble... or at least, for Mail::Cap...


<P><HR>
<A NAME="other_stuff_you_can_do">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Other stuff you can do</FONT></H2>
</A>


<P>
If you want to tweak the way this toolkit works (for example, to 
turn on debugging), use the routines in the <B><A HREF="ToolUtils.pm.html">MIME::ToolUtils</A></B> module.


<P><HR>
<A NAME="good_advice">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Good advice</FONT></H2>
</A>

<UL>

<P><LI><B>Run with -w.</B>  If you see a warning about a deprecated method,
change your code ASAP.  This will ease upgrades tremendously.


<P><LI><B>Don't try to MIME-encode using the non-standard MIME encodings.</B>
It's just not a good practice if you want people to be able to
read your messages.


<P><LI><B>Be aware of possible thrown exceptions.</B>
For example, if your mail-handling code absolutely must not die, 
then perform mail parsing like this:


<P>
<PRE>    $entity = eval { $parser-&gt;parse(\*INPUT) };</PRE>



<P>
Parsing is a complex process, and some components may throw exceptions
if seriously-bad things happen.  Since &quot;seriously-bad&quot; is in the
eye of the beholder, you're better off <I>catching</I> possible exceptions 
instead of asking me to propagate <CODE>undef</CODE> up the stack.  Use of exceptions in
reusable modules is one of those religious issues we're never all 
going to agree upon; thankfully, that's what <CODE>eval{}</CODE> is good for.

</UL>


<P><HR>
<A NAME="notes">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
NOTES</FONT></H1>
</A>


<P><HR>
<A NAME="terminology">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Terminology</FONT></H2>
</A>


<P>
Here are some excerpts from RFC-1521 explaining the terminology
we use; each is accompanied by the equivalent in MIME:: module terms...

<DL>
<P><DT><B><A NAME="message">Message</A></B><DD>

From RFC-1521:


<P>
<PRE>    The term &quot;message&quot;, when not further qualified, means either the
    (complete or &quot;top-level&quot;) message being transferred on a network, or
    a message encapsulated in a body of type &quot;message&quot;.</PRE>



<P>
There currently is no explicit package for messages; under MIME::, 
messages are streams of data which may be read in from files or 
filehandles.


<P><DT><B><A NAME="body">Body part</A></B><DD>

From RFC-1521:


<P>
<PRE>    The term &quot;body part&quot;, in this document, means one of the parts of the
    body of a multipart entity. A body part has a header and a body, so
    it makes sense to speak about the body of a body part.</PRE>



<P>
Since a body part is just a kind of entity (see below), a body part 
is represented by an instance of <A HREF="Entity.pm.html">MIME::Entity</A>.


<P><DT><B><A NAME="entity">Entity</A></B><DD>

From RFC-1521:


<P>
<PRE>    The term &quot;entity&quot;, in this document, means either a message or a body
    part.  All kinds of entities share the property that they have a
    header and a body.</PRE>



<P>
An entity is represented by an instance of <A HREF="Entity.pm.html">MIME::Entity</A>.
There are instance methods for recovering the header (a <A HREF="Head.pm.html">MIME::Head</A>)
and the body (a <A HREF="Body.pm.html">MIME::Body</A>).


<P><DT><B><A NAME="header">Header</A></B><DD>

This is the top portion of the MIME message, which contains the
Content-type, Content-transfer-encoding, etc.  Every MIME entity has
a header, represented by an instance of <A HREF="Head.pm.html">MIME::Head</A>.  You get the
header of an entity by sending it a head() message.


<P><DT><B><A NAME="body">Body</A></B><DD>

From RFC-1521:


<P>
<PRE>    The term &quot;body&quot;, when not further qualified, means the body of an
    entity, that is the body of either a message or of a body part.</PRE>



<P>
A body is represented by an instance of <A HREF="Body.pm.html">MIME::Body</A>.  You get the
body of an entity by sending it a bodyhandle() message.

</DL>


<P><HR>
<A NAME="compatibility">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Compatibility</FONT></H2>
</A>


<P>
As of 4.x, MIME-tools can no longer emulate the old MIME-parser
distribution.  If you're installing this as a replacement for the 
MIME-parser 1.x release, you'll have to do a little tinkering with
your code.


<P><HR>
<A NAME="design_issues">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Design issues</FONT></H2>
</A>

<DL>
<P><DT><B><A NAME="why">Why assume that MIME objects are email objects?</A></B><DD>

I quote from Achim Bohnet, who gave feedback on v.1.9 (I think
he's using the word <I>header</I> where I would use <I>field</I>; e.g.,
to refer to &quot;Subject:&quot;, &quot;Content-type:&quot;, etc.):


<P>
<PRE>    There is also IMHO no requirement [for] MIME::Heads to look 
    like [email] headers; so to speak, the MIME::Head [simply stores] 
    the attributes of a complex object, e.g.:</PRE>



<P>
<PRE>        new MIME::Head type =&gt; &quot;text/plain&quot;,
                       charset =&gt; ...,
                       disposition =&gt; ..., ... ;</PRE>



<P>
I agree in principle, but (alas and dammit) RFC-1521 says otherwise.
RFC-1521 [MIME] headers are a syntactic subset of RFC-822 [email] headers.
Perhaps a better name for these modules would be RFC1521:: instead of
MIME::, but we're a little beyond that stage now.  (<I>Note: RFC-1521 
has recently been obsoleted by RFCs 2045-2049, so it's just as well 
we didn't go that route...</I>)


<P>
However, in my mind's eye, I see a mythical abstract class which does what 
Achim suggests... so you could say:


<P>
<PRE>     my $attrs = new MIME::Attrs type =&gt; &quot;text/plain&quot;,
				 charset =&gt; ...,
                                 disposition =&gt; ..., ... ;</PRE>



<P>
We could even make it a superclass or companion class of MIME::Head, 
such that MIME::Head would allow itself to be initiallized from a 
MIME::Attrs object.


<P>
<B>In the meanwhile,</B> look at the build() and attach() methods of MIME::Entity:
they follow the spirit of this mythical class.


<P><DT><B><A NAME="to">To subclass or not to subclass?</A></B><DD>

When I originally wrote these modules for the CPAN, I agonized for a long
time about whether or not they really should subclass from <B>Mail::Internet</B> 
(then at version 1.17).  Thanks to Graham Barr, who graciously evolved
MailTools 1.06 to be more MIME-friendly, unification was achieved
at MIME-tools release 2.0.   The benefits in reuse alone have been
substantial.

</DL>


<P><HR>
<A NAME="questionable_practices">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Questionable practices</FONT></H2>
</A>

<DL>
<P><DT><B><A NAME="fuzzing">Fuzzing of CRLF and newline on input</A></B><DD>

RFC-1521 dictates that MIME streams have lines terminated by CRLF
(<CODE>&quot;\r\n&quot;</CODE>).  However, it is extremely likely that folks will want to 
parse MIME streams where each line ends in the local newline 
character <CODE>&quot;\n&quot;</CODE> instead.


<P>
An attempt has been made to allow the parser to handle both CRLF 
and newline-terminated input.


<P>
<I>See MIME::ParserBase for further details.</I>


<P><DT><B><A NAME="fuzzing">Fuzzing of CRLF and newline when decoding</A></B><DD>

The <CODE>&quot;7bit&quot;</CODE> and <CODE>&quot;8bit&quot;</CODE> decoders will decode both
a <CODE>&quot;\n&quot;</CODE> and a <CODE>&quot;\r\n&quot;</CODE> end-of-line sequence into a <CODE>&quot;\n&quot;</CODE>.


<P>
The <CODE>&quot;binary&quot;</CODE> decoder (default if no encoding specified) 
still outputs stuff verbatim... so a MIME message with CRLFs 
and no explicit encoding will be output as a text file 
that, on many systems, will have an annoying ^M at the end of
each line... <I>but this is as it should be</I>.


<P>
<I>See MIME::ParserBase for further details.</I>


<P><DT><B><A NAME="fuzzing">Fuzzing of CRLF and newline when encoding/composing</A></B><DD>

All encoders currently output the end-of-line sequence as a <CODE>&quot;\n&quot;</CODE>,
with the assumption that the local mail agent will perform
the conversion from newline to CRLF when sending the mail.


<P>
However, there probably should be an option to output CRLF as per RFC-1521.
I'm currently working on a good mechanism for this.


<P>
<I>See MIME::ParserBase for further details.</I>


<P><DT><B><A NAME="inability">Inability to handle multipart boundaries with embedded newlines</A></B><DD>

First, let's get something straight: this is an evil, EVIL practice.
If your mailer creates multipart boundary strings that contain 
newlines, give it two weeks notice and find another one.  If your
mail robot receives MIME mail like this, regard it as syntactically
incorrect, which it is.


<P>
<I>See MIME::ParserBase for further details.</I>

</DL>


<P><HR>
<A NAME="a_mime_primer">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
A MIME PRIMER</FONT></H1>
</A>


<P>
So you need to parse (or create) MIME, but you're not quite up on 
the specifics?  No problem...


<P><HR>
<A NAME="content_types">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Content types</FONT></H2>
</A>


<P>
This indicates what kind of data is in the MIME message, usually
as <I>majortype/minortype</I>.  The standard major types are shown below.
A more-comprehensive listing may be found in RFC-2046.

<DL>
<P><DT><B><A NAME="application">application</A></B><DD>

Data which does not fit in any of the other categories, particularly 
data to be processed by some type of application program. 
<CODE>application/octet-stream</CODE>, <CODE>application/gzip</CODE>, <CODE>application/postscript</CODE>...


<P><DT><B><A NAME="audio">audio</A></B><DD>

Audio data.
<CODE>audio/basic</CODE>...


<P><DT><B><A NAME="image">image</A></B><DD>

Graphics data.
<CODE>image/gif</CODE>, <CODE>image/jpeg</CODE>...


<P><DT><B><A NAME="message">message</A></B><DD>

A message, usually another mail or MIME message.
<CODE>message/rfc822</CODE>...


<P><DT><B><A NAME="multipart">multipart</A></B><DD>

A message containing other messages.
<CODE>multipart/mixed</CODE>, <CODE>multipart/alternative</CODE>...


<P><DT><B><A NAME="text">text</A></B><DD>

Textual data, meant for humans to read.
<CODE>text/plain</CODE>, <CODE>text/html</CODE>...


<P><DT><B><A NAME="video">video</A></B><DD>

Video or video+audio data.
<CODE>video/mpeg</CODE>...

</DL>


<P><HR>
<A NAME="content_transfer_encodings">
<H2><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h2bullet.gif" ALT="" BORDER="0"></A>
Content transfer encodings</FONT></H2>
</A>


<P>
This is how the message body is packaged up for safe transit.
There are the 5 major MIME encodings.
A more-comprehensive listing may be found in RFC-2045.

<DL>
<P><DT><B><A NAME="7bit">7bit</A></B><DD>

No encoding is done at all.  This label simply asserts that no
8-bit characters are present, and that lines do not exceed 1000 characters 
in length (including the CRLF).


<P><DT><B><A NAME="8bit">8bit</A></B><DD>

No encoding is done at all.  This label simply asserts that the message 
might contain 8-bit characters, and that lines do not exceed 1000 characters 
in length (including the CRLF).


<P><DT><B><A NAME="binary">binary</A></B><DD>

No encoding is done at all.  This label simply asserts that the message 
might contain 8-bit characters, and that lines may exceed 1000 characters 
in length.  Such messages are the <I>least</I> likely to get through mail 
gateways.


<P><DT><B><A NAME="base64">base64</A></B><DD>

A standard encoding, which maps arbitrary binary data to the 7bit domain.
Like &quot;uuencode&quot;, but very well-defined.  This is how you should send
essentially binary information (tar files, GIFs, JPEGs, etc.).


<P><DT><B><A NAME="quoted">quoted-printable</A></B><DD>

A standard encoding, which maps arbitrary line-oriented data to the
7bit domain.  Useful for encoding messages which are textual in
nature, yet which contain non-ASCII characters (e.g., Latin-1,
Latin-2, or any other 8-bit alphabet).

</DL>


<P><HR>
<A NAME="terms_and_conditions">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
TERMS AND CONDITIONS</FONT></H1>
</A>


<P>
Copyright (c) 1996, 1997 by Eryq.  All rights reserved.  This program is free
software; you can redistribute it and/or modify it under the same terms as
Perl itself.  See the COPYING file in the distribution for details.


<P><HR>
<A NAME="support">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
SUPPORT</FONT></H1>
</A>


<P>
Please email me directly with questions/problems (see AUTHOR below).


<P>
If you want to be placed on an email distribution list (not a mailing list!)
for MIME-tools, and receive bug reports, patches, and updates as to when new 
MIME-tools releases are planned, just email me and say so.  If your project
is using MIME-tools, it might not be a bad idea to find out about those
bugs <I>before</I> they become problems...


<P><HR>
<A NAME="change_log">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
CHANGE LOG</FONT></H1>
</A>


<P>
See the README file in the distribution for the most-recent changes.
For a full history, see the ./docs/MIME-tools.pod file in the distribution.


<P><HR>
<A NAME="author">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
AUTHOR</FONT></H1>
</A>


<P>
MIME-tools was created by:


<P>
<PRE>    ___  _ _ _   _  ___ _     
   / _ \| '_| | | |/ _ ' /    Eryq (President, Zero G Inc.)
  |  __/| | | |_| | |_| |     http://www.zeegee.com/
   \___||_|  \__, |\__, |__   eryq@zeegee.com
             |___/    |___/</PRE>



<P>
Release as MIME-parser (1.0): 28 April 1996.
Release as MIME-tools (2.0): Halloween 1996.
Release of 4.0: Christmas 1997.


<P><HR>
<A NAME="version">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
VERSION</FONT></H1>
</A>


<P>
$Revision: 4.112 $


<P><HR>
<A NAME="acknowledgments">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
ACKNOWLEDGMENTS</FONT></H1>
</A>


<P>
<B>This kit would not have been possible</B> but for the direct 
contributions of the following:


<P>
<PRE>    Gisle Aas             The MIME encoding/decoding modules.
    Laurent Amon          Bug reports and suggestions.
    Graham Barr           The new MailTools.
    Achim Bohnet          Numerous good suggestions, including the I/O model.
    Kent Boortz           Initial code for RFC-1522-decoding of MIME headers.
    Andreas Koenig        Numerous good ideas, tons of beta testing,
                            and help with CPAN-friendly packaging.
    Igor Starovoitov      Bug reports and suggestions.
    Jason L Tibbitts III  Bug reports, suggestions, patches.</PRE>



<P>
Not to mention the Accidental Beta Test Team, whose bug reports (and
comments) have been invaluable in improving the whole:


<P>
<PRE>    Phil Abercrombie
    Brandon Browning
    Kurt Freytag
    Steve Kilbane
    Jake Morrison
    Rolf Nelson
    Joel Noble    
    Michael W. Normandin 
    Tim Pierce
    Andrew Pimlott
    Dragomir R. Radev
    Nickolay Saukh
    Russell Sutherland
    Larry Virden
    Zyx</PRE>



<P>
Please forgive me if I've accidentally left you out.  
Better yet, email me, and I'll put you in.


<P><HR>
<A NAME="see_also">
<H1><FONT COLOR=#600020>
<A HREF="#__top"><IMG SRC="h1bullet.gif" ALT="" BORDER="0"></A>
SEE ALSO</FONT></H1>
</A>


<P>
Users of this toolkit may wish to read the documentation of Mail::Header 
and Mail::Internet.


<P>
The MIME format is documented in RFCs 1521-1522, and more recently
in RFCs 2045-2049.


<P>
The MIME header format is an outgrowth of the mail header format
documented in RFC 822.


<P><HR>
<SMALL>
		Last updated: Sat Jan 17 23:02:05 1998 <BR>
		Generated by pod2coolhtml 1.101.  Want a copy?  Just email
		<A HREF="mailto:eryq@enteract.com">eryq@enteract.com</A>.
		(Yes, it's free.)
		</SMALL></BODY>
</HTML>