Mail::M...lHeader(3)
π Mail::Message::Replace::MailHeader(3)
okay bestie, welcome to Mail::Message::Replace::MailHeader(3) β yes that's the whole name, she's long but she's worth it π
. This is the User Contributed Perl Documentation corner of the universe, and we're about to make a fake Mail::Header and have it be, lowkey, iconic.
β¨ NAME β¨
Mail::Message::Replace::MailHeader β a fake Mail::Header, no cap π
πΈ INHERITANCE πΈ
she's got a whole ancestry tree and honestly the bloodline ate:
Mail::Message::Replace::MailHeader
is a Mail::Message::Head::Complete
is a Mail::Message::Head
is a Mail::Reporter
like, look at that lineage. main character energy all the way up π«Ά
π¦ SYNOPSIS π¦
here's the glow-up, bestie. you take this:
# change
use Mail::Internet;
use Mail::Header;
and you turn it into this:
# into
use Mail::Message::Replace::MailInternet;
# in existing code, and the code should still work, but
# with the Mail::Message features.
that's it. swap the use, keep your existing code, and she still runs β but now she's got all the Mail::Message features. glow-up complete β¨
π DESCRIPTION π
so here's the tea π: this module is a lil wrapper around a Mail::Message::Head::Complete, and what it does is simulate a Mail::Header object. it literally hijacks that module's name-space and then piles a whole bunch of extra methods on top of it. not me committing identity theft for the greater good π
most methods will just work with zero changes, but bestie, you should test your software again. no skipping the vibe check. small changes have been made to fold_length() and header_hashref(). so, like, mostly fine, but not identical fine.
also, this extends "DESCRIPTION" in Mail::Message::Head::Complete β so go read that one too, iykyk π
π OVERLOADED π
extends "OVERLOADED" in Mail::Message::Head::Complete. the family keeps growing π
- overload:
""stringifaction β inherited, see"OVERLOADED"inMail::Message::Head. yes it says "stringifaction", that's the original spelling, we don't touch the sacred texts π - overload:
booltrue/false β inherited, see"OVERLOADED"inMail::Message::Head
ngl "overload" sounds like a lot but it's just Perl letting objects pretend to be strings and booleans. cute, honestly. π§
π οΈ METHODS π οΈ
Extends "METHODS" in Mail::Message::Head::Complete. So like, everything below is the bonus content on top of what that class already gives you, bestie. π
π Constructors π
Extends "Constructors" in Mail::Message::Head::Complete.
$class->build( [PAIR|$field], ... )β Inherited, so go peep"Constructors"inMail::Message::Head::Completefor the tea.$obj->clone( [@names|ARRAY|Regexps] )β Also inherited, same deal:"Constructors"inMail::Message::Head::Complete.$class->new( [$arg], %options )β The$argis an array with header lines. This one improves the base version, so check"Constructors"inMail::Message::Headtoo. β¨
Here's the whole options lineup, fr fr:
-Option --Defined in --Default
FoldLength 79
MailFrom 'KEEP'
Modify false
field_type Mail::Message::Head Mail::Message::Field::Fast
message Mail::Message::Head undef
modified Mail::Message::Head false
Now let's break each one down:
FoldLength => $octetsβ the fold length, in octets. That's it, that's the whole vibe.MailFrom => 'IGNORE'|'ERROR'|'COERCE'|'KEEP'β how you wanna handle those"From "lines. Full deets live inmail_from(). πModify => BOOLEANβ reformat every header line as it comes in, i.e. change the folding. Glow-up on arrival.field_type => CLASSβ which class the fields get built as.message => $messageβ the message this header belongs to.modified => BOOLEANβ whether it's been modified.
π 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( $line, [$index] )β Adds a header line, and honestly it just callsMail::Message::Head::add()on the header for that$line. The$indexgets straight-up ignored π, and what comes back is the unfolded body of the field. Improves the base, so also 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->count($name)β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->delete( $tag, [$index] )β Deletes the fields with that$tag, and hands you back the deleted fields. No index given? Then all of them go. π Improves the base β see"Access to the header"inMail::Message::Head::Complete.$obj->get( $name, [$index] )β Grabs all the header fields matching$name. In scalar context you only get the first fitting$nameback. And even when you name just one$name, you might get multiple lines back in list context, because some fields just show up more than once in a header. Iconic, honestly. Improves the base β 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>, ... )β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeFieldsExcept( <STRING|Regexp>, ... )β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeListGroup()β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeResentGroups()β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->removeSpamGroups()β Inherited, see"Access to the header"inMail::Message::Head::Complete.$obj->replace( $tag, $line, [$index] )β Swaps out the field named$tag, from place$index(defaulting to the first one), with$line. If$tagisundef, it gets pulled out of$linefirst. Heads up: this callsMail::Message::Head::Complete::reset()on the message's head. π$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->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.
π Access to the header π
(yes, bestie, it's back β same heading, new vibes π )
π Simulating Mail::Header π
$obj->as_string()β Hands you the entire header as one big scalar. Under the hood it callsMail::Message::Head::Complete::string().$obj->cleanup()β Cleans up memory usage. Not needed here, so like, nothing to do. π§Ό$obj->combine( $tag, [$with] )β "I do not see any valid reason for this command, so did not implement it." No notes, the author said what they said. π$obj->dup()β Duplicates the header, which is literally justclone().$obj->empty()β Cleans out the whole hash. Better not use this (just make another header object instead), although it should work. π$obj->exists()β Tells you whether there are any fields at all.$obj->extract(\@lines)β Extracts (and removes) header fields from the array.$obj->fold( [$length] )β Refolds every field in the header, to$lengthor whateverfold_length()gives back.$obj->fold_length( [[$tag], $length] )β Returns the line wrap, optionally after setting it to$length. You get the old value back. The$tagargument is ignored, because having different lines fold in different ways is silly. β οΈ Heads up: this method cannot be called statically anymore.$obj->header( [ARRAY] )β Extracts the fields from theARRAYif you gave one, then folds the fields. You get back an array with all the fields, produced viaorderedFields().$obj->header_hashref(HASH)β "If you are using this method, you must be stupid... anyway: I do not want to support it for now: useadd()and friends." Okay drag us a little, king. π$obj->mail_from( ['IGNORE'|'ERROR'|'COERCE'|'KEEP'] )β What to do when a header line in the form`From 'shows up. The valid values are"IGNORE"β ignore it and discard the header,"ERROR"β invoke an error (die),"COERCE"β rename them asMail-From, and"KEEP"β keep them. Choose wisely bestie. β¨$obj->modify( [BOOLEAN] )β Refolds the headers as they get added.$obj->read($file)β Reads the header from$file. Improves the base β see"Internals"inMail::Message::Head.$obj->tags()β Returns all the names of fields, implemented byMail::Message::Head::Complete::names().$obj->unfold( [$tag] )β Removes the folding for every instance of$tag, or for all fields at once if you skip it.
π The nasty bits π
$any->isa($class)β Obviously, theisa()class inheritance check should not see our nasty little trick. π€«
π DETAILS π
Extends "DETAILS" in Mail::Message::Head::Complete.
π DIAGNOSTICS π
okay bestie, here's where the module yells at you. these are the messages it can throw, and what they actually mean π
Error: bad Mail-From choice: '$pick'.β you passed a$pickvalue that is simply not it. no cap. cast bymail_from(). π«Warning: cannot remove field $name from header: not found.β you asked to remove a field that the header literally does not know about. but here's the tea: if you usedelete(),reset(), orset()instead, you won't get this warning, because those methods check whether the field exists first. this one comes fromremoveField(). π§Error: class $package does not implement method $method.β this is a fatal error, so pay attention π . it means the specific$package(or one of its superclasses, like, going all the way up the family tree) doesn't implement this method even though it should. the vibe is: some other related classes do implement it, but this class right here does not. you should probably investigate this, and honestly probably tell the author of the package about it. cast bynotImplemented(). πWarning: field objects have an implied name ($name)β cast bybuild(). π
π SEE ALSO π
this module is part of Mail-Message version 4.04, built on February 04, 2026. πΈ
website: http://perl.overmeer.net/CPAN/
like. go look at it. it's giving resource. π
π LICENSE π
contributors, check out the file ChangeLog bestie. π«Ά
this software is copyright (c) 2001-2026 by Mark Overmeer. periodt.
it's free software, so you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. iconic behavior honestly. β¨
and that's the whole page, bestie!! π this one came from the perl v5.42.0 manual, dated 2026-02-05 β so like, fresh off the press. go forth and header responsibly. mwah ππ
π¦ 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