Mail::Message Module
Mail::Message Overview
Mail::Message object provides several methods to analyze a message and
manipulate messages or parts of a message.
Precisely speaking, this module analyzes the specified mail message
and build a chain of Mail::Message objects.
If not multipart
header -> body
else if multipart
header -> preamble -> part1 -> part2 -> ... -> trailor
The link between objects is double link list. Mail::Message class
provides several methods to manipulate these structures.
Each part of this chain is a Mail::Message object. In other words, one
mail message consits of a chain of plural Mail::Message objects in
&fml8; internal.
For example, "header" is a Mail::Message, which type is
text/rfc822-headers and the data is stored as Mail::Header
object. Instead "part1" is a Mail::Message object, which type is
text/plain and the data is reference to the message string.
References:
Mail::Message module manual.
Mail::Message Module: Analyze
parse() analyzes the file. The argument is the file name or the file
handle for the file which should be specified at the argument.
data_type_list() returns information of the chain.
The return value is array reference.
For example, MIME/multipart consists of the following objects.
type[ 1]: text/rfc822-headers | multipart/mixed
type[ 2]: multipart/mixed | multipart/mixed
type[ 3]: multipart.preamble | multipart/mixed
type[ 4]: multipart.delimiter | multipart/mixed
type[ 5]: text/plain | multipart/mixed
type[ 6]: multipart.delimiter | multipart/mixed
type[ 7]: image/gif | multipart/mixed
type[ 8]: multipart.close-delimiter | multipart/mixed
type[ 9]: text/plain | multipart/mixed
The center row is the object type, the right one is the mime type of
the whole message (content-type in the mail header).
Mail::Message Module: Create A New Object
new() method is used to create a new object chain.
The following MIME/multipart specific methdos exist.
build_mime_multipart_chain($args)
parse_and_build_mime_multipart_chain($args)
build_mime_header($args)
These methods are used internally now.
So these will become private methods in the furure.
Please do not use these methods.
To create a new MIME/mulitpart message, use Mail::Message::Compose. It
is MIME::Lite class in fact :-)
Mail::Message Module: Manipulate Messabe Body
Consider the following object chain.
If not multipart
header -> body
else if multipart
header -> preamble -> part1 -> part2 -> ... -> trailor
header_data_type() return the type of the whole type.
It is known from Content-Type: in the whole message header.
whole_message_body() returns body or part1 if multipart.
whole_message_body_head() is same.
find_first_plaintext_message($args) return the first text/plain type
object in the chain. This is useful in filter codes since filter
system checks the first text field in a lot of cases.
Mail::Message Module: Search
find() searches the specified type of Mail::Message in the object
chain and returns the first matched object.
Mail::Message Module: Print
print() method is usual print() function. Usually specify the file
descriptor as an argument.
print() has the concept "mode" to specify CRLF or LF. use
set_print_mode(mode) and reset_print_mode() to set the mode. By
default, mode is raw. Specify smtp mode in using print() within SMTP
codes.
Mail::Message Module: Utility Functions
Size
size() returns the size of the object not the whole message size.
is_empty() tells the object data is empty or not.
General Information
envelope_sender() returns the envelope sender as string.
data_type() returns the type of the object (a part of an object chain)
not the whole message type (Content-Type: in the whole message
header).
encoding_mechanism() returns the encoding mechanism of the object (a
part of an object chain) as string. This is not of the whole message
encoding mechanism.
Mail::Message Internals
num_paragraph() returns the number of paragraphs in the data of the
object.
nth_paragraph(N) returns N-th paragrah as the string.
Caution that N starts from 1 not 0.
header() returns the header part of a multipart block (header part of
an object). data() returns the data part (data part of an object).
Respectively, alias of message_fields($size) and message_text($size).
References
Mail::Message manual