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;
See SYNOPSIS in Mail::Message::Head::Complete
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 message) gets mutulated!
See DESCRIPTION in Mail::Message::Head::Complete
See Ordered header fields in Mail::Message::Head
See Head class implementation in Mail::Message::Head
See Subsets of header fields in Mail::Message::Head
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.
foreach my $msg ($folder->messages) { $msg->head->removeResentGroups; $msg->head->removeResentList; }