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" in Mail::Message::Head. yes it says "stringifaction", that's the original spelling, we don't touch the sacred texts πŸ™ˆ
  • overload: bool true/false β€” inherited, see "OVERLOADED" in Mail::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" in Mail::Message::Head::Complete for the tea.
  • $obj->clone( [@names|ARRAY|Regexps] ) β€” Also inherited, same deal: "Constructors" in Mail::Message::Head::Complete.
  • $class->new( [$arg], %options ) β€” The $arg is an array with header lines. This one improves the base version, so check "Constructors" in Mail::Message::Head too. ✨

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 in mail_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" in Mail::Message::Head.
  • $obj->isEmpty() β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->isModified() β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->knownNames() β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->message( [$message] ) β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->modified( [BOOLEAN] ) β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->nrLines() β€” Inherited, see "The header" in Mail::Message::Head::Complete.
  • $obj->orderedFields() β€” Inherited, see "The header" in Mail::Message::Head.
  • $obj->size() β€” Inherited, see "The header" in Mail::Message::Head::Complete.
  • $obj->wrap($integer) β€” Inherited, see "The header" in Mail::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 calls Mail::Message::Head::add() on the header for that $line. The $index gets straight-up ignored πŸ™ˆ, and what comes back is the unfolded body of the field. Improves the base, so also see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->addListGroup($object) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->addResentGroup($resent_group|$data) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->addSpamGroup($object) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->count($name) β€” Inherited, see "Access to the header" in Mail::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" in Mail::Message::Head::Complete.
  • $obj->get( $name, [$index] ) β€” Grabs all the header fields matching $name. In scalar context you only get the first fitting $name back. 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" in Mail::Message::Head.
  • $obj->grepNames( [@names|ARRAY|Regexps] ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->listGroup() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->names() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->print( [$fh] ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->printSelected($fh, <STRING|Regexp>, ...) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->printUndisclosed( [$fh] ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeContentInfo() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeField($field) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeFields( <STRING|Regexp>, ... ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeFieldsExcept( <STRING|Regexp>, ... ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeListGroup() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeResentGroups() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->removeSpamGroups() β€” Inherited, see "Access to the header" in Mail::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 $tag is undef, it gets pulled out of $line first. Heads up: this calls Mail::Message::Head::Complete::reset() on the message's head. πŸ”
  • $obj->resentGroups() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->reset($name, @fields) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->set( $field | $line | <$name, $body, [$attrs]> ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->spamDetected() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->spamGroups( [$names] ) β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->string() β€” Inherited, see "Access to the header" in Mail::Message::Head::Complete.
  • $obj->study( $name, [$index] ) β€” Inherited, see "Access to the header" in Mail::Message::Head.

🫧 About the body 🫧

Extends "About the body" in Mail::Message::Head::Complete.

  • $obj->guessBodySize() β€” Inherited, see "About the body" in Mail::Message::Head.
  • $obj->guessTimeStamp() β€” Inherited, see "About the body" in Mail::Message::Head::Complete.
  • $obj->isMultipart() β€” Inherited, see "About the body" in Mail::Message::Head.
  • $obj->recvstamp() β€” Inherited, see "About the body" in Mail::Message::Head::Complete.
  • $obj->timestamp() β€” Inherited, see "About the body" in Mail::Message::Head::Complete.

🧚 Internals 🧚

Extends "Internals" in Mail::Message::Head::Complete.

  • $obj->addNoRealize($field) β€” Inherited, see "Internals" in Mail::Message::Head.
  • $obj->addOrderedFields($fields) β€” Inherited, see "Internals" in Mail::Message::Head.
  • $obj->createFromLine() β€” Inherited, see "Internals" in Mail::Message::Head::Complete.
  • $obj->createMessageId() β€” Inherited, see "Internals" in Mail::Message::Head::Complete.
  • $obj->fileLocation() β€” Inherited, see "Internals" in Mail::Message::Head.
  • $obj->load() β€” Inherited, see "Internals" in Mail::Message::Head.
  • $any->messageIdPrefix( [$prefix, [$hostname]|CODE] ) β€” Inherited, see "Internals" in Mail::Message::Head::Complete.
  • $obj->moveLocation($distance) β€” Inherited, see "Internals" in Mail::Message::Head.
  • $obj->setNoRealize($field) β€” Inherited, see "Internals" in Mail::Message::Head.

🚨 Error handling 🚨

Extends "Error handling" in Mail::Message::Head::Complete.

  • $obj->AUTOLOAD() β€” Inherited, see "Error handling" in Mail::Reporter.
  • $obj->notImplemented() β€” Inherited, see "Error handling" in Mail::Reporter.

🧹 Cleanup 🧹

Extends "Cleanup" in Mail::Message::Head::Complete.

  • $obj->DESTROY() β€” Inherited, see "Cleanup" in Mail::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 calls Mail::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 just clone().
  • $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 $length or whatever fold_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 $tag argument 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 the ARRAY if you gave one, then folds the fields. You get back an array with all the fields, produced via orderedFields().
  • $obj->header_hashref(HASH) β€” "If you are using this method, you must be stupid... anyway: I do not want to support it for now: use add() 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 as Mail-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" in Mail::Message::Head.
  • $obj->tags() β€” Returns all the names of fields, implemented by Mail::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, the isa() 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 $pick value that is simply not it. no cap. cast by mail_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 use delete(), reset(), or set() instead, you won't get this warning, because those methods check whether the field exists first. this one comes from removeField(). 🧚
  • 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 by notImplemented(). 😭
  • Warning: field objects have an implied name ($name) β€” cast by build(). πŸŽ€

🌈 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