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: ""

overload: bool

METHODS

Constructors

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

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

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

The header

$obj->isDelayed

$obj->isEmpty

$obj->isModified

$obj->knownNames

$obj->message([MESSAGE])

$obj->modified([BOOLEAN])

$obj->nrLines

$obj->orderedFields

$obj->size

$obj->wrap(INTEGER)

Access to the header

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

$obj->addListGroup(OBJECT)

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

$obj->addSpamGroup(OBJECT)

$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)

$obj->delete(NAME)

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

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

$obj->listGroup

$obj->names

$obj->print([FILEHANDLE])

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

$obj->printUndisclosed([FILEHANDLE])

$obj->removeContentInfo

$obj->removeField(FIELD)

$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

$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

$obj->reset(NAME, FIELDS)

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

$obj->spamDetected

$obj->spamGroups([NAMES])

$obj->string

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

About the body

$obj->guessBodySize

$obj->guessTimeStamp

$obj->isMultipart

$obj->recvstamp

$obj->timestamp

Internals

$obj->addNoRealize(FIELD)

$obj->addOrderedFields(FIELDS)

$obj->createFromLine

$obj->createMessageId

$obj->fileLocation

$obj->load

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

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

$obj->moveLocation(DISTANCE)

$obj->read(PARSER)

$obj->setNoRealize(FIELD)

Error handling

$obj->AUTOLOAD

$obj->addReport(OBJECT)

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

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

$obj->errors

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

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

$obj->logPriority(LEVEL)

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

$obj->logSettings

$obj->notImplemented

$obj->report([LEVEL])

$obj->reportAll([LEVEL])

$obj->trace([LEVEL])

$obj->warnings

Cleanup

$obj->DESTROY

$obj->inGlobalDestruction

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;
}

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.

SEE ALSO

This module is part of Mail-Box distribution version 2.088, built on March 19, 2009. Website: http://perl.overmeer.net/mailbox/

LICENSE

Copyrights 2001-2009 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html