Mail::M...Partial(3)
π Mail::Message::Head::Partial β bestie edition π
okay so real talk, this is Mail::Message::Head::Partial from the User Contributed Perl Documentation, section 3. it's a subset of header information of a message. like, you took a header and you trimmed it down. slay but also be careful, more on that in a sec.
πΈ NAME πΈ
Mail::Message::Head::Partial β a subset of header information of a message. it's giving "just the highlights" energy.
π¦ INHERITANCE π¦
the family tree goes like this, and it's honestly iconic:
Mail::Message::Head::Partial
is a Mail::Message::Head::Complete
is a Mail::Message::Head
is a Mail::Reporter
so yeah, it's the grandbaby of Mail::Reporter, no cap.
β¨ SYNOPSIS β¨
here's the whole vibe in code, bestie:
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 how it's isPartial true and isDelayed false? yeah. that's the whole point.
π DESCRIPTION π
okay so here's the tea. header information? it eats up a considerable amount of memory. like, a lot. and most of that info is only useful during a short period of time in your program, or sometimes it's not used at all. so you can decide to remove most of the header information. π
β οΈ BUT. be warned, bestie. it will be lost permanently. the header (and therefore the message) gets mutulated! (that's the original's typo and i'm keeping it, periodt.) this is not a vibe check you can undo. π
extends "DESCRIPTION" in Mail::Message::Head::Complete.
π₯ OVERLOADED π₯
extends "OVERLOADED" in Mail::Message::Head::Complete.
""stringifaction β inherited, see"OVERLOADED"inMail::Message::Head. (yes it says "stringifaction", iconic, we don't fix it.)booltrue/false β inherited, see"OVERLOADED"inMail::Message::Head.
π METHODS π
extends "METHODS" in Mail::Message::Head::Complete.
π Constructors π
extends "Constructors" in Mail::Message::Head::Complete.
$class->build( [PAIR|$field], ... )β inherited, see"Constructors"inMail::Message::Head::Complete.$obj->clone( [@names|ARRAY|Regexps] )β inherited, see"Constructors"inMail::Message::Head::Complete.$class->new(%options)β inherited, see"Constructors"inMail::Message::Head.
π§ Attributes π§
extends "Attributes" in Mail::Message::Head::Complete.
πΈ The header πΈ
extends "The header" in Mail::Message::Head::Complete.
$obj->isDelayed()β inherited, see"The header"inMail::Message::Head.$obj->isEmpty()β inherited, see"The header"inMail::Message::Head.$obj->isModified()β inherited, see"The header"inMail::Message::Head.$obj->knownNames()β inherited, see"The header"inMail::Message::Head.$obj->message( [$message] )β inherited, see"The header"inMail::Message::Head.$obj->modified( [BOOLEAN] )β inherited, see"The header"inMail::Message::Head.$obj->nrLines()β inherited, see"The header"inMail::Message::Head::Complete.$obj->orderedFields()β inherited, see"The header"inMail::Message::Head.$obj->size()β inherited, see"The header"inMail::Message::Head::Complete.$obj->wrap($integer)β inherited, see"The header"inMail::Message::Head::Complete.
π Access to the header π
extends "Access to the header" in Mail::Message::Head::Complete.
$obj->add( $field | $line | <$name, $body, [$attrs]> )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->addListGroup($object)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->addResentGroup($resent_group|$data)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->addSpamGroup($object)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->cleanupOrderedFields()β so the header maintains a list of fields which are ordered in sequence of definition. it needs 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, and the ones in the ordered list are weak. so when field objects are removed from the hash, their references in the ordered list are automagicallyundef'd. πͺ and when a lot of fields get removed β say withremoveFields()orremoveFieldsExcept()β then it's useful to also remove that list of undefs from the ordered list. in those cases this method is called automatically, but you can call it yourself if you have your own reasons. you do you, bestie.$obj->count($name)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->delete($name)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->get( $name, [$index] )β inherited, see"Access to the header"inMail::Message::Head.$obj->grepNames( [@names|ARRAY|Regexps] )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->listGroup()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->names()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->print( [$fh] )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->printSelected($fh, <STRING|Regexp>, ...)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->printUndisclosed( [$fh] )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeContentInfo()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeField($field)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeFields( <STRING|Regexp>, ... )β removes the fields from the header which are exactly named"STRING"(case insensitive) or which match the regular expresssion. β οΈ do not forget to add the'i'modifier to the regexp, because fields are case insensitive! also seeremoveField(), which is used to remove one field object from the header. you can do the reverse specification withremoveFieldsExcept(). improves base, see"Access to the header"inMail::Message::Head::Complete.
Β» example:
$head->removeFields('bcc', 'received');
$head->removeFields( qr/^content-/i );
$obj->removeFieldsExcept(STRING|Regexp, ...)β removes 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. β οΈ again, do not forget to add the'i'modifier to the Regexp, because fields are case insensitive. also seeremoveField()which removes one field object from the header. reverse specification isremoveFields(). improves base, see"Access to the header"inMail::Message::Head::Complete.
Β» 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 those are is explained inMail::Message::Head::ListGroup. what you get back is the number of removed lines. improves base, see"Access to the header"inMail::Message::Head::Complete.$obj->removeResentGroups()β removes all header lines which are member of a resent group, which are explained inMail::Message::Head::ResentGroup. returned is the number of removed lines. for removing single groups (say, because you want to keep the last one), useMail::Message::Head::FieldGroup::delete(). improves base, see"Access to the header"inMail::Message::Head::Complete.$obj->removeSpamGroups()β removes all header lines which were produced by spam detection and spam-fighting software. which fields those are is explained inMail::Message::Head::SpamGroup. returned is the number of removed lines. improves base, see"Access to the header"inMail::Message::Head::Complete. bye bye spam headers, we do not claim them. π$obj->resentGroups()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->reset($name, @fields)β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->set( $field | $line | <$name, $body, [$attrs]> )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->spamDetected()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->spamGroups( [$names] )β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->string()β inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->study( $name, [$index] )β inherited, see"Access to the header"inMail::Message::Head.
π About the body π
extends "About the body" in Mail::Message::Head::Complete.
$obj->guessBodySize()β inherited, see"About the body"inMail::Message::Head.$obj->guessTimeStamp()β inherited, see"About the body"inMail::Message::Head::Complete.$obj->isMultipart()β inherited, see"About the body"inMail::Message::Head.$obj->recvstamp()β inherited, see"About the body"inMail::Message::Head::Complete.$obj->timestamp()β inherited, see"About the body"inMail::Message::Head::Complete.
β Internals β
extends "Internals" in Mail::Message::Head::Complete.
$obj->addNoRealize($field)β inherited, see"Internals"inMail::Message::Head.$obj->addOrderedFields($fields)β inherited, see"Internals"inMail::Message::Head.$obj->createFromLine()β inherited, see"Internals"inMail::Message::Head::Complete.$obj->createMessageId()β inherited, see"Internals"inMail::Message::Head::Complete.$obj->fileLocation()β inherited, see"Internals"inMail::Message::Head.$obj->load()β inherited, see"Internals"inMail::Message::Head.$any->messageIdPrefix( [$prefix, [$hostname]|CODE] )β inherited, see"Internals"inMail::Message::Head::Complete.$obj->moveLocation($distance)β inherited, see"Internals"inMail::Message::Head.$obj->read($parser)β inherited, see"Internals"inMail::Message::Head.$obj->setNoRealize($field)β inherited, see"Internals"inMail::Message::Head.
π Error handling π
extends "Error handling" in Mail::Message::Head::Complete.
$obj->AUTOLOAD()β inherited, see"Error handling"inMail::Reporter.$obj->notImplemented()β inherited, see"Error handling"inMail::Reporter.
π«Ά Cleanup π«Ά
extends "Cleanup" in Mail::Message::Head::Complete.
$obj->DESTROY()β inherited, see"Cleanup"inMail::Reporter.
to be continued, bestie β part 2 is coming ππ
π DETAILS π
Extends "DETAILS" in Mail::Message::Head::Complete.
πΈ Ordered header fields πΈ
Extends "Ordered header fields" in Mail::Message::Head::Complete.
π¦ Head class implementation π¦
Extends "Head class implementation" in Mail::Message::Head::Complete.
π Subsets of header fields π
Extends "Subsets of header fields" in Mail::Message::Head::Complete.
β¨ Reducing the header size β¨
okay bestie, listen β a message header is HUGE in memory and pretty dang large on disk too, so it's like, the perfect glow-up candidate for size reduction. One way to shrink it? Just yeet the superfluous header fields. Each field eats at least 100 bytes of run-time memory, so yeah, this genuinely helps! π
Before you start messing around with <code>removeFields()</code> and <code>removeFieldsExcept()</code>, peep these two big groups of fields that can be removed as whole sets: the resent headers and the mailinglist headers.
Resent headers describe the intermediate steps in the transmission process for the messages. After a successful delivery, they're rarely useful. ποΈ
And when you're archiving a mailinglist, it's hardly ever useful to store the list administration lines for each message as well.
Β» see <code>examples/reduce.pl</code> in distribution
foreach my $msg ($folder->messages)
{ $msg->head->removeResentGroups;
$msg->head->removeResentList;
}
π DIAGNOSTICS π
- Warning: cannot remove field <code>$name</code> from header: not found. β You asked to remove a field that the header literally does not know about. π But plot twist: using <code>delete()</code>, <code>reset()</code>, or <code>set()</code> to do the job will not result in warnings β those methods check whether the field even exists first. Cast by <code>removeField()</code>.
- Error: class <code>$package</code> does not implement method <code>$method</code>. β Fatal error, no cap: the specific <code>$package</code> (or one of its superclasses) does not implement this method where it should. This message means some <em>other</em> related classes do implement this method, but the class at hand does not. You should probably investigate this, and probably inform the author of the package. Cast by <code>notImplemented()</code>.
- Warning: field objects have an implied name (<code>$name</code>) β Cast by <code>build()</code>.
π SEE ALSO π
This module is part of Mail-Message version 4.04, built on February 04, 2026. Website: http://perl.overmeer.net/CPAN/
π LICENSE π
For contributors see file <code>ChangeLog</code>.
This software is copyright (c) 2001-2026 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π«Ά
and that's a wrap on Mail::M...Partial(3) bestie!! π this one's perl v5.42.0, dated 2026-02-05 β go forth and shrink those headers, you absolute icon β¨π
π¦ where this page comes from
- fedora 44: perl-Mail-Message 4.04-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms