Mail::Message::Head::Partial - subset of header information of a message


NAME

Mail::Message::Head::Partial - subset of header information of a message


INHERITANCE

 Mail::Message::Head::Partial
   is a Mail::Message::Head::Complete
   is a Mail::Message::Head
   is a Mail::Reporter


SYNOPSIS

 my $partial = $head->strip;
 $partial->isa('Mail::Message::Head')  # true
 $partial->isDelayed                      # false
 $partial->isPartial                      # true
 $partial->removeFields( qr/^X-/ );
 $partial->removeFieldsExcept( qw/To From/ );
 $partial->removeResentGroups;
 $partial->removeListGroup;
 $partial->removeSpamGroups;


DESCRIPTION

Header information consumes a considerable amount of memory. Most of this information is only useful during a short period of time in your program, or sometimes it is not used at all. You then can decide to remove most of the header information. However, be warned that it will be lost permanently: the header (and therefore the messsage) gets mutulated!


OVERLOADED

overload: ``''

See OVERLOADED in the Mail::Message::Head manpage

overload: bool

See OVERLOADED in the Mail::Message::Head manpage


METHODS

Constructors

$obj->build([PAIR|FIELD]-LIST)

See Constructors in the Mail::Message::Head::Complete manpage

$obj->clone([FIELDS])

See Constructors in the Mail::Message::Head::Complete manpage

Mail::Message::Head::Partial->new(OPTIONS)

See Constructors in the Mail::Message::Head manpage

The header

$obj->isDelayed

See The header in the Mail::Message::Head manpage

$obj->isEmpty

See The header in the Mail::Message::Head manpage

$obj->isModified

See The header in the Mail::Message::Head manpage

$obj->knownNames

See The header in the Mail::Message::Head manpage

$obj->message([MESSAGE])

See The header in the Mail::Message::Head manpage

$obj->modified([BOOLEAN])

See The header in the Mail::Message::Head manpage

$obj->nrLines

See The header in the Mail::Message::Head::Complete manpage

$obj->orderedFields

See The header in the Mail::Message::Head manpage

$obj->size

See The header in the Mail::Message::Head::Complete manpage

$obj->wrap(INTEGER)

See The header in the Mail::Message::Head::Complete manpage

Access to the header

$obj->add(FIELD | LINE | (NAME,BODY[,ATTRS]))

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->addListGroup(OBJECT)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->addResentGroup(RESENT-GROUP|DATA)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->addSpamGroup(OBJECT)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->cleanupOrderedFields

The header maintains a list of fields which are ordered in sequence of definition. It is required to maintain the header order to keep the related fields of resent groups together. The fields are also included in a hash, sorted on their name for fast access.

The references to field objects in the hash are real, those in the ordered list are weak. So when field objects are removed from the hash, their references in the ordered list are automagically undef'd.

When many fields are removed, for instance with removeFields() or removeFieldsExcept(), then it is useful to remove the list of undefs from the ordered list as well. In those cases, this method is called automatically, however you may have your own reasons to call this method.

$obj->count(NAME)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->delete(NAME)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->get(NAME [,INDEX])

See Access to the header in the Mail::Message::Head manpage

$obj->grepNames([NAMES|ARRAY-OF-NAMES|REGEXS])

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->listGroup

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->names

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->print([FILEHANDLE])

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->printSelected(FILEHANDLE, (STRING|REGEXP)s)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->printUndisclosed([FILEHANDLE])

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->removeContentInfo

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->removeField(FIELD)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->removeFields(STRING|REGEXP, [STRING|REGEXP, ...])

Remove the fields from the header which are exactly named 'STRING' (case insensitive) or match the REGular EXPresssion. Do not forget to add the 'i' modifier to the REGEXP, because fields are case insensitive.

See also removeField() which is used to remove one field object from the header. The reverse specification can be made with removeFieldsExcept().

Example:

 $head->removeFields('bcc', 'received');
 $head->removeFields( qr/^content-/i );

$obj->removeFieldsExcept(STRING|REGEXP, [STRING|REGEXP, ...])

Remove all fields from the header which are not equivalent to one of the specified STRINGs (case-insensitive) and which are not matching one of the REGular EXPressions. Do not forget to add the 'i' modifier to the REGEXP, because fields are case insensitive.

See also removeField() which is used to remove one field object from the header. The reverse specification can be made with removeFields().

Example:

 $head->removeFieldsExcept('subject', qr/^content-/i ); 
 $head->removeFieldsExcept( qw/subject to from sender cc/ );

$obj->removeListGroup

Removes all header lines which are used to administer mailing lists. Which fields that are is explained in Mail::Message::Head::ListGroup. Returned is the number of removed lines.

$obj->removeResentGroups

Removes all header lines which are member of a resent group, which are explained in Mail::Message::Head::ResentGroup. Returned is the number of removed lines.

For removing single groups (for instance because you want to keep the last), use Mail::Message::Head::FieldGroup::delete().

$obj->removeSpamGroups

Removes all header lines which were produced by spam detection and spam-fighting software. Which fields that are is explained in Mail::Message::Head::SpamGroup. Returned is the number of removed lines.

$obj->resentGroups

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->reset(NAME, FIELDS)

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->set(FIELD | LINE | (NAME, BODY [,ATTRS]))

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->spamDetected

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->spamGroups([NAMES])

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->string

See Access to the header in the Mail::Message::Head::Complete manpage

$obj->study(NAME [,INDEX])

See Access to the header in the Mail::Message::Head manpage

About the body

$obj->guessBodySize

See About the body in the Mail::Message::Head manpage

$obj->guessTimeStamp

See About the body in the Mail::Message::Head::Complete manpage

$obj->isMultipart

See About the body in the Mail::Message::Head manpage

$obj->recvstamp

See About the body in the Mail::Message::Head::Complete manpage

$obj->timestamp

See About the body in the Mail::Message::Head::Complete manpage

Internals

$obj->addNoRealize(FIELD)

See Internals in the Mail::Message::Head manpage

$obj->addOrderedFields(FIELDS)

See Internals in the Mail::Message::Head manpage

$obj->createFromLine

See Internals in the Mail::Message::Head::Complete manpage

$obj->createMessageId

See Internals in the Mail::Message::Head::Complete manpage

$obj->fileLocation

See Internals in the Mail::Message::Head manpage

$obj->load

See Internals in the Mail::Message::Head manpage

$obj->messageIdPrefix([PREFIX, [HOSTNAME]|CODE])

Mail::Message::Head::Partial->messageIdPrefix([PREFIX, [HOSTNAME]|CODE])

See Internals in the Mail::Message::Head::Complete manpage

$obj->moveLocation(DISTANCE)

See Internals in the Mail::Message::Head manpage

$obj->read(PARSER)

See Internals in the Mail::Message::Head manpage

$obj->setNoRealize(FIELD)

See Internals in the Mail::Message::Head manpage

Error handling

$obj->AUTOLOAD

See Error handling in the Mail::Reporter manpage

$obj->addReport(OBJECT)

See Error handling in the Mail::Reporter manpage

$obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])

Mail::Message::Head::Partial->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK])

See Error handling in the Mail::Reporter manpage

$obj->errors

See Error handling in the Mail::Reporter manpage

$obj->log([LEVEL [,STRINGS]])

Mail::Message::Head::Partial->log([LEVEL [,STRINGS]])

See Error handling in the Mail::Reporter manpage

$obj->logPriority(LEVEL)

Mail::Message::Head::Partial->logPriority(LEVEL)

See Error handling in the Mail::Reporter manpage

$obj->logSettings

See Error handling in the Mail::Reporter manpage

$obj->notImplemented

See Error handling in the Mail::Reporter manpage

$obj->report([LEVEL])

See Error handling in the Mail::Reporter manpage

$obj->reportAll([LEVEL])

See Error handling in the Mail::Reporter manpage

$obj->trace([LEVEL])

See Error handling in the Mail::Reporter manpage

$obj->warnings

See Error handling in the Mail::Reporter manpage

Cleanup

$obj->DESTROY

See Cleanup in the Mail::Reporter manpage

$obj->inGlobalDestruction

See Cleanup in the Mail::Reporter manpage


DIAGNOSTICS

Warning: Cannot remove field $name from header: not found.

You ask to remove a field which is not known in the header. Using delete(), reset(), or set() to do the job will not result in warnings: those methods check the existence of the field first.

Warning: Field objects have an implied name ($name)

Error: Package $package does not implement $method.

Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package.


DETAILS

Reducing the header size

A message header is very large in memory and quite large on disk, and therefore a good candidate for size reduction. One way to reduce the size is by simply eliminating superfluous header fields. Each field requires at least 100 bytes of run-time memory, so this may help!

Before you start playing around with removeFields() and removeFieldsExcept(), you may take a look at two large groups of fields which can be removes as sets: the resent headers and the mailinglist headers.

Resent headers describe the intermediate steps in the transmission process for the messages. After successful delivery, they are rarely useful.

When you are archiving a mailinglist, it is hardly ever useful to store a the list administration lines for each message as well.

Example: see examples/reduce.pl in distribution

 foreach my $msg ($folder->messages)
 {  $msg->head->removeResentGroups;
    $msg->head->removeResentList;
 }


REFERENCES

See the MailBox website at http://perl.overmeer.net/mailbox/ for more details.


COPYRIGHTS

Distribution version 2.059. Written by Mark Overmeer (mark@overmeer.net) See the ChangeLog for other contributors.

Copyright (c) 2001-2003 by the author(s). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Mail::Message::Head::Partial - subset of header information of a message