NAME

MIME::Entity - class for parsed-and-decoded MIME message


ALPHA-RELEASE WARNING

This code is in an evaluation phase until 1 August 1996. Depending on any comments/complaints received before this cutoff date, the interface may change in a non-backwards-compatible manner.


DESCRIPTION

This package provides a class for representing MIME message entities, as specified in RFC 1521, Multipurpose Internet Mail Extensions .

Here are some excerpts from RFC-1521 explaining the terminology: each is accompanied by the equivalent in MIME:: terms:

Message
From RFC-1521:

    The term "message", when not further qualified, means either the
    (complete or "top-level") message being transferred on a network, or
    a message encapsulated in a body of type "message".

There currently is no explicit package for messages; under MIME::, messages may be read in from readable files or filehandles. A future extension will allow them to be read from any object reference that responds to a special ``next line'' method.

Body part
From RFC-1521:

    The term "body part", 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.

Since a body part is just a kind of entity (see below), a body part is represented by an instance of MIME::Entity.

Entity
From RFC-1521:

    The term "entity", 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.

An entity is represented by an instance of MIME::Entity. There are instance methods for recovering the header (a MIME::Head) and the body (see below).

Body
From RFC-1521:

    The term "body", when not further qualified, means the body of an
    entity, that is the body of either a message or of a body part.

Well, this is a toughie. Both Mail::Internet (1.17) and Mail::MIME (1.03) represent message bodies in-core; unfortunately, this is not always the best way to handle things, especially for MIME streams that contain multi-megabyte tar files.


THE NITTY GRITTY

A MIME::Entity is composed of the following elements:


DESIGN ISSUES


To subclass or not to subclass?

When I rewrote this module for the CPAN, I agonized for a long time about whether or not it really should just be a subclass of Mail::Internet (or the experimental Mail::MIME ). There were plusses:

And, unfortunately, minuses:

The compromise. Currently, MIME::Head is its own module. However:


Some things just can't be ignored

In multipart messages, the "preamble" is the portion that precedes the first encapsulation boundary, and the "epilogue" is the portion that follows the last encapsulation boundary.

According to RFC-1521:

    There appears to be room for additional information prior to the
    first encapsulation boundary and following the final boundary.  These
    areas should generally be left blank, and implementations must ignore
    anything that appears before the first boundary or after the last
    one.

    NOTE: These "preamble" and "epilogue" areas are generally not used
    because of the lack of proper typing of these parts and the lack
    of clear semantics for handling these areas at gateways,
    particularly X.400 gateways.  However, rather than leaving the
    preamble area blank, many MIME implementations have found this to
    be a convenient place to insert an explanatory note for recipients
    who read the message with pre-MIME software, since such notes will
    be ignored by MIME-compliant software.

In the world of standards-and-practices, that's the standard. Now for the practice:

Some MIME mailers may incorrectly put a "part" in the preamble , Since we have to parse over the stuff anyway , in the future I will allow the parser option of creating special MIME::Entity objects for the preamble and epilogue, with bogus MIME::Head objects.


PUBLIC INTERFACE


Constructors and converters

new
Class method. Create a new, empty MIME entity.

from_mail MAIL
Class method. Create a new MIME entity from a MAIL::Internet object. Currently unimplemented .

to_mail
Instance method. Convert a MIME entity to a MAIL::Internet object. Currently unimplemented .


Instance methods

add_part
Assuming we are a multipart message, add a body part (a MIME::Entity) to the array of body parts. Do not call this for single-part messages; i.e., don't call it unless the header has a "multipart" content-type.

body OPTVALUE
Get or set the path to the file containing the body.

If OPTVALUE is not given, the current body file is returned. If OPTVALUE is given, the body file is set to the new value, and the previous value is returned.

head OPTVALUE
Get or set the head.

If OPTVALUE is not given, the current head is returned. If OPTVALUE is given, the head is set to the new value, and the previous value is returned.

is_multipart
Does this entity's MIME type indicate that it's a multipart entity? Returns undef (false) if the answer couldn't be determined, 0 (false) if it was determined to be false, and true otherwise.

Note that this says nothing about whether or not parts were extracted.

parts
Return an array of all sub parts (each of which is a MIME::Entity), or the empty array if there are none.

For single-part messages, the empty array will be returned. For multipart messages, the preamble and epilogue parts are not in the list! If you want them, use all_parts() instead.

dump_skeleton FILEHANDLE
Dump the skeleton of the entity to the given FILEHANDLE, or to the currently-selected one if none given.


SEE ALSO

MIME::Decoder, MIME::Entity, MIME::Head, MIME::Parser.


AUTHOR

Copyright (c) 1996 by Eryq / eryq@rhine.gsfc.nasa.gov

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


VERSION

$Revision: 1.7 $ $Date: 1996/04/30 14:32:00 $