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.
Here are some excerpts from RFC-1521 explaining the terminology: each is accompanied by the equivalent in MIME:: terms:
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.
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.
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).
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.
"multipart"
content-type.
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.
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.
Note that this says nothing about whether or not parts were extracted.
$x = $entity->mime_type; $x = $entity->head->mime_type;
If there is no head, returns undef in a scalar context and the empty array in a list context.
Note that, while parsed entities still have MIME types, they do not have MIME encodings, or MIME versions, or fields, etc., etc... for those attributes, you still have to go to the head explicitly.
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.
"multipart"
.
get()
method (for retrieveing a field's value) does a brute-force, regexp-based
search through a linear array of the field values - worse, with a
dynamically-compiled search pattern. Even given small headers, I was simply
too uncomfortable with this approach for the MIME header applications,
which could be fairly get()-intensive.
$entity->head->get('subject');
...can work even if MIME::Head
objects are eliminated, and
MIME::Entity
objects become the ones that handle the get()
method. To do this, we'd simply define MIME::Entity::head()
to return the ``self'' object, which would ``pretend'' to be the ``header''
object. Like this:
sub head { $_[0] }
read()
(or from_file()
), the original parsed header is stored, in all its flat-text glory, in the
MIME::Head object, and may be recovered via the original_text()
method.
from_mail()
and to_mail are provided in MIME::Entity class.
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.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.