my $head = Mail::Message::Head->new; $head->add('From: me@localhost'); $head->add(From => 'me@localhost'); $head->add(Mail::Message::Field->new(From => 'me')); my Mail::Message::Field $subject = $head->get('subject'); my Mail::Message::Field @rec = $head->get('received'); $head->delete('From');
See SYNOPSIS in Mail::Reporter
Mail::Message::Head
MIME headers are part of Mail::Message messages,
which are grouped in Mail::Box folders.
ATTENTION!!! most functionality about e-mail headers is described in Mail::Message::Head::Complete, which is a matured header object. Other kinds of headers will be translated to that type when time comes.
On this page, the general methods which are available on any header are described. Read about differences in the sub-class specific pages.
See DESCRIPTION in Mail::Reporter
Many Perl implementations make a big mistake by disturbing the order of header fields. For some fields (especially the resent groups, see Mail::Message::Head::ResentGroup) the order shall be maintained.
MailBox will keep the order of the fields as they were found in the source. When your add a new field, it will be added at the end. If your replace a field with a new value, it will stay in the original order.
The header of a MIME message object contains a set of lines, which are called fields (by default represented by Mail::Message::Field objects). Dependent on the situation, the knowledge about the fields can be in one of three situations, each represented by a sub-class of this module:
In this case, it is sure that all knowledge about the header is available. When you get() information from the header and it is not there, it will never be there.
There is no certainty whether all header lines are known (probably not). This may be caused as result of reading a fast index file, as described in Mail::Box::MH::Index. The object is automatically transformed into a Mail::Message::Head::Complete when all header lines must be known.
A partial header is like a subset header: probably the header is incomplete. The means that you are not sure whether a get() for a field fails because the field is not a part of the message or that it fails because it is not yet known to the program. Where the subset header knows where to get the other fields, the partial header does not know it. It cannot hide its imperfection.
In this case, there is no single field known. Access to this header will always trigger the loading of the full header.
Message headers can be quite large, and therefore MailBox provides simplified access to some subsets of information. You can grab these sets of fields together, create and delete them as group.
On the moment, the following sets are defined:
Each step adds a set of headers to indicate when the message was received and how it was forwarded (without modification). These fields are best created using Mail::Message::bounce().