Mail::M...nternet(3)

✨ Mail::Message::Replace::MailInternet(3) ✨

okay bestie, buckle UP β€” this is the manual page for Mail::Message::Replace::MailInternet, straight out of the User Contributed Perl Documentation. 🫢


πŸ’– NAME πŸ’–

Mail::Message::Replace::MailInternet β€” it's a fake Mail::Internet, no cap. Like, cosplaying as the original so hard you can't even tell. 🎭


🌸 INHERITANCE 🌸

Lowkey a whole family tree. Here's the tea:

 Mail::Message::Replace::MailInternet
   is a Mail::Message
   is a Mail::Reporter

πŸ¦‹ SYNOPSIS πŸ¦‹

Bestie, it's a find-and-replace moment. Watch:

# change
use Mail::Internet;
# 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 one line and your old code keeps on slaying, except now it's got all the Mail::Message features underneath. πŸ’…


✨ DESCRIPTION ✨

So here's what's happening. This module is a wrapper around a Mail::Message, and what it does is simulate a Mail::Internet object. The name-space of that module gets straight-up hijacked (iconic behavior honestly) and a whole bunch of methods get added on top.

Most methods will work with zero changes on your end β€” no edits, no drama. But you may need to peek at your smtpsend() and send() calls, just saying. πŸ‘€

It also extends "DESCRIPTION" in Mail::Message.


πŸ”₯ OVERLOADED πŸ”₯

(nothing under here, it just vibes)

πŸ‘‘ METHODS πŸ‘‘

Extends "METHODS" in Mail::Message.

πŸŽ€ Constructors πŸŽ€

Extends "Constructors" in Mail::Message.

  • $obj->clone(%options) β€” Inherited, see "Constructors" in Mail::Message.
  • $obj->dup() β€” Duplicate the message. And guess what, the result is again a Mail::Internet compatible object. So it stays in character. πŸ’–
  • $obj->empty() β€” Remove all data from this object. Very dangerous! Like, delete-everything levels of dangerous. 😭
  • $class->new( [$arg], [%options] ) β€” Inherited, see "Constructors" in Mail::Reporter.

Here's the option table, exactly as it is:

 -Option    --Defined in     --Default
  Body                         undef
  FoldLength                   79
  Header                       undef
  MailFrom                     'KEEP'
  Modify                       false
  body        Mail::Message    undef
  body_type   Mail::Message    Mail::Message::Body::Lines
  deleted     Mail::Message    false
  field_type  Mail::Message    undef
  head        Mail::Message    undef
  head_type   Mail::Message    Mail::Message::Replace::MailHeader
  labels      Mail::Message    +{}
  messageId   Mail::Message    undef
  modified    Mail::Message    false
  trusted     Mail::Message    false

Now let's break those down, bestie:

  • Body => \@lines β€” An array of "\n" terminated lines. If you don't specify it, the lines get read from $arg. Easy peasy.
  • FoldLength => $octets β€” How many characters (encoded $octets) are allowed on any refolded header line. This gets passed along to Mail::Message::Replace::MailHeader::new(FoldLength).
  • Header => $head β€” The Mail::Header object you pass here is a fake one too, ngl... It gets translated into a new(head). If you don't give one, the header gets parsed from the $arg.
  • MailFrom => 'IGNORE'|'ERROR'|'COERCE'|'KEEP' β€” What to do with leading "From " lines in e-mail data. Passed to Mail::Message::Replace::MailHeader::new(MailFrom).
  • Modify => BOOLEAN β€” Whether to re-fold all the incoming fields. Passed to Mail::Message::Replace::MailHeader::new(Modify).
  • body => $object
  • body_type => $class
  • deleted => BOOLEAN
  • field_type => $class
  • head => $object
  • head_type => $class
  • labels => \@pairs|\%settings
  • messageId => $id
  • modified => BOOLEAN
  • trusted => BOOLEAN

Β» example: replace traditional Mail::Internet by this wrapper

# was
use Mail::Internet;
my $mi = Mail::Internet->new(@options);

# becomes
use Mail::Message::Replace::MailInternet;
my $mi = Mail::Internet->new(@options);

Look at that glow-up. Same call, new energy. ✨

🧚 Attributes 🧚

Extends "Attributes" in Mail::Message.

  • $obj->MailFrom( [STRING] ) β€” Your email address. That's the whole thing. πŸ’Œ

🌈 Constructing a message 🌈

Extends "Constructing a message" in Mail::Message.

  • $obj->add_signature( [$filename] ) β€” Replaced by sign(), but still usable. $filename is the file which contains the signature, and it defaults to "$ENV{HOME}/.signature".
  • $obj->bounce( [<$rg_object|%options>] ) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Bounce.
  • $class->build( [$message|$part|$body], @fields, %options ) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Build.
  • $class->buildFromBody($body, [$head], $headers) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Build.
  • $obj->extract(\@lines|$fh) β€” Read header and body from an ARRAY or $fh.
  • $obj->forward(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardAttach(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardEncapsulate(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardInline(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardNo(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardPostlude() β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardPrelude() β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $obj->forwardSubject(STRING) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Forward.
  • $any->read(\@lines|$fh, %options) β€” Read header and body from the specified ARRAY or $fh. When you use it as an object method, Mail::Message::read() gets called, so it stays MailBox compliant. As a class method, the Mail::Internet compatible read is called instead. Heads up: %options are only available in the first case. Improves base, see "Constructing a message" in Mail::Message::Construct::Read.

Option table for read, verbatim:

 -Option             --Defined in                    --Default
  body_type            Mail::Message::Construct::Read  undef
  parser_class         Mail::Message::Construct::Read  undef
  seekable             Mail::Message::Construct::Read  false
  strip_status_fields  Mail::Message::Construct::Read  true
  trusted              Mail::Message::Construct::Read  true
  • body_type => $type
  • parser_class => $type
  • seekable => BOOLEAN
  • strip_status_fields => BOOLEAN
  • trusted => BOOLEAN
  • $obj->read_body(\@lines|$fh) β€” Read only the message's body from the ARRAY or $fh.
  • $obj->read_header(\@lines|$fh) β€” Read only the message's header from the ARRAY or $fh.
  • $obj->rebuild(%options) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Rebuild.
  • $obj->reply(%options) β€” BE WARNED: the main job for creating a reply is done by Mail::Message::reply(), which may produce a result which is compatible, but may be different from Mail::Internet's version. Improves base, see "Constructing a message" in Mail::Message::Construct::Reply.

Option table for reply, exactly:

 -Option         --Defined in                     --Default
  Bcc              Mail::Message::Construct::Reply  undef
  Cc               Mail::Message::Construct::Reply  <'cc' in current>
  Exclude                                           []
  From             Mail::Message::Construct::Reply  <'to' in current>
  Inline                                            >
  Keep                                              []
  Message-ID       Mail::Message::Construct::Reply  <uniquely generated>
  ReplyAll                                          <C<false>>
  Subject          Mail::Message::Construct::Reply  replySubject()
  To               Mail::Message::Construct::Reply  <sender in current>
  body             Mail::Message::Construct::Reply  undef
  group_reply      Mail::Message::Construct::Reply  true
  header_template                                   $ENV{HOME}/.mailhdr
  include          Mail::Message::Construct::Reply  'INLINE'
  max_signature    Mail::Message::Construct::Reply  10
  message_type     Mail::Message::Construct::Reply  Mail::Message
  postlude         Mail::Message::Construct::Reply  undef
  prelude          Mail::Message::Construct::Reply  undef
  quote            Mail::Message::Construct::Reply  '> '
  signature        Mail::Message::Construct::Reply  undef
  strip_signature  Mail::Message::Construct::Reply  qr/^--\s/

And the breakdown:

  • Bcc => $body|$address|\@addresses
  • Cc => $body|$address|\@addresses
  • Exclude => \@names β€” Remove the fields with the specified names from the produced reply message.
  • From => $body|$address|\@addresses
  • Inline => STRING β€” Quotation STRING, which is translated into reply(quote). The normal default of "quote" is "> ", in stead of ">".
  • Keep => \@names β€” Copy all header fields with the specified NAMES from the source to the reply message.
  • Message-ID => STRING
  • ReplyAll => BOOLEAN β€” Reply to the group? Translated into reply(group_reply), which has as default the exact oposite of this option, being "true".
  • Subject => STRING|CODE
  • To => $body|$address|\@addresses
  • body => $body
  • group_reply => BOOLEAN
  • header_template => $filename|undef β€” Read the return header from the template file. When this is explicitly set to "undef", or the file does not exist, then a header will be created.
  • include => 'NO'|'INLINE'|'ATTACH'
  • max_signature => INTEGER
  • message_type => CLASS
  • postlude => $body|\@lines
  • prelude => $body|\@lines
  • quote => CODE|STRING
  • signature => $body|$message
  • strip_signature => REGEXP|STRING|CODE
  • $obj->replyPrelude( [STRING|$field|$address|\@addrs|\@fields] ) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Reply.
  • $any->replySubject(STRING) β€” Inherited, see "Constructing a message" in Mail::Message::Construct::Reply.
  • $obj->sign(%options) β€” Add a signature (a few extra lines) to the message. πŸ’Œ

Option table for sign:

 -Option   --Default
  File       undef
  Signature  ''
  • File => $filename β€” Specifies a filename where the signature is in.
  • Signature => STRING|\@lines β€” The signature in memory.

πŸ’œ The message πŸ’œ

Extends "The message" in Mail::Message.

  • $obj->container() β€” Inherited, see "The message" in Mail::Message.
  • $obj->endsOnNewline() β€” Inherited, see "The message" in Mail::Message.
  • $obj->isDummy() β€” Inherited, see "The message" in Mail::Message.
  • $obj->isPart() β€” Inherited, see "The message" in Mail::Message.
  • $obj->messageId() β€” Inherited, see "The message" in Mail::Message.
  • $obj->partNumber() β€” Inherited, see "The message" in Mail::Message.
  • $obj->print( [$fh] ) β€” Spits the whole message out to the $fh you hand it, and if you don't hand it one it defaults to STDOUT. Under the hood it calls Mail::Message::print(). Improves base, see "The message" in Mail::Message.
  • $obj->send($type, %options) β€” Sends your message out through Mail Transfer Agents (MUA) πŸ¦‹ β€” the actual delivery gets handled by a whole lil squad of Mail::Transport::Send extensions. Heads up tho: the "test" $type is not supported. Improves base, see "The message" in Mail::Message.
  • $obj->size() β€” ✨ Inherited, see "The message" in Mail::Message.
  • $obj->toplevel() β€” ✨ Inherited, see "The message" in Mail::Message.
  • $obj->write( [$fh] ) β€” ✨ Inherited, see "The message" in Mail::Message.

πŸŽ€ The header πŸŽ€

Extends "The header" in Mail::Message.

  • $obj->add(\@lines) β€” Adds header lines, which honestly just calls Mail::Message::Head::add() on the header once for every LINE you passed in. The last LINE that got added is what comes back to you πŸ’…
  • $obj->bcc() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->cc() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->clean_header() β€” Not to be used, it got replaced by header().
  • $obj->combine( $tag, [$with] ) β€” Not implemented, because the author genuinely sees no use for it πŸ’€
  • $obj->date() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->delete( $name, [$index]] ) β€” Deletes the fields carrying that $name, and hands the deleted fields right back to you.
BE WARNED: if you don't specify a $name, the "delete" gets read as deleting the whole message out of a folder, so Mail::Box::Message::delete() will get called instead 😭 This may have no negative effect at all...

Calls Mail::Message::Replace::MailHeader::delete(). Improves base, see "Flags" in Mail::Message.

  • $obj->destinations() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->fold( [$length] ) β€” Folds every field down to a certain maximum $length. Implemented by Mail::Message::Replace::MailHeader::fold().
  • $obj->fold_length( [[$tag], $length] ) β€” Sets that maximum line $length. The $tag? ignored, bestie. Implemented by Mail::Message::Replace::MailHeader::fold_length().
  • $obj->from() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->get( $name, [$index] ) β€” Grabs every header field matching that $name. In scalar context, only the first fitting $name comes back. And even when you only name one $name, you can still get multiple lines back β€” because some fields just show up more than once in a header, that's their whole vibe 🌸 Calls Mail::Message::Replace::MailHeader::get(). Improves base, see "The header" in Mail::Message.
  • $obj->guessTimestamp() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->head( [$head] ) β€” Returns the head of the message, or makes an empty one if none is defined yet. The $head argument β€” which sets the header β€” is not available for Mail::Internet, it's only there so things stay compatible with the "head" method over in Mail::Message. Improves base, see "The header" in Mail::Message.
  • $obj->header( [\@lines] ) β€” Optionally reads a header in from that ARRAY of lines, then returns those fields as an array-ref, nicely folded 🫢 Implemented by Mail::Message::Replace::MailHeader::header().
  • $obj->nrLines() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->print_header($fh) β€” Calls Mail::Message::Head::Complete::print().
  • $obj->replace( $tag, $line, [$index] ) β€” Adds LINES to the header, but yeets any fields with the same name if they're already hanging around. Calls Mail::Message::Replace::MailHeader::replace().
  • $obj->sender() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->study($fieldname) β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->subject() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->tidy_headers() β€” No effect anymore (it's always performed).
  • $obj->timestamp() β€” ✨ Inherited, see "The header" in Mail::Message.
  • $obj->to() β€” ✨ Inherited, see "The header" in Mail::Message.

πŸ¦‹ The body πŸ¦‹

Extends "The body" in Mail::Message.

  • $obj->body($lines|@lines) β€” Returns an ARRAY of lines that represents the body. Pass arguments and a brand new body gets created instead. Fun fact: in Mail::Internet, the body isn't an object at all β€” it's just a plain old array πŸ’€
BE WARNED: this overrules the Mail::Message::body() method, which can cause some real confusion. Use bodyObject() if you want access to that body's data. Improves base, see "The body" in Mail::Message.
  • $obj->bodyObject( [$body] ) β€” Calls Mail::Message::body(), because that "body" method got overruled by the one with the Mail::Internet-compatible interface.
  • $obj->contentType() β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->decoded(%options) β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->encode(%options) β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->isMultipart() β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->isNested() β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->parts( [<'ALL'|'ACTIVE'|'DELETED'|'RECURSE'|$filter>] ) β€” ✨ Inherited, see "The body" in Mail::Message.
  • $obj->print_body( [$fh] ) β€” Prints the body out to $fh, which defaults to STDOUT. Calls Mail::Message::Body::print().
  • $obj->remove_sig( [$nrlines] ) β€” Removes the signature off a message with a max of $nrlines lines, defaulting to 10. The work happens on the decoded body content, done by Mail::Message::Body::stripSignature().
  • $obj->smtpsend(%options) β€” This one calls Mail::Message::send() via "smtp", which is implemented in Mail::Transport::SMTP. Ngl the implementation is slightly different, so this method is not 100% compliant πŸ™ˆ
 -Option  --Default
  Debug     false
  Hello     <helo_domain from Net::Config>
  Host      $ENV{SMTPHOSTS} or from Net::Config
  MailFrom  $ENV{MAILADDRESS} or $ENV{USER}
  Port      25

Debug => BOOLEAN

Hello => STRING

Host => $hostname Only the first detected $hostname gets taken, so this differs from the original implementation.

MailFrom => STRING Your e-mail address. This simulated Mail::Internet object does not try to cook up an e-mail address from the sendmail configuration file, because that's generally a bad idea in environments with virtual hosts, as we have now-adays πŸ’…

Port => INTEGER

  • $obj->tidy_body() β€” Removes blank lines from the begin and end of the body ✨

πŸ‘‘ Flags πŸ‘‘

Extends "Flags" in Mail::Message.

  • $obj->deleted( [BOOLEAN] ) β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->isDeleted() β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->isModified() β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->label($label|PAIRS) β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->labels() β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->labelsToStatus() β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->modified( [BOOLEAN] ) β€” ✨ Inherited, see "Flags" in Mail::Message.
  • $obj->statusToLabels() β€” ✨ Inherited, see "Flags" in Mail::Message.

🌈 The whole message as text 🌈

Extends "The whole message as text" in Mail::Message.

  • $obj->as_mbox_string() β€” Returns the whole message as one single string, ready to be included in an MBOX folder (while not using Mail::Box::Mbox). Any lines in the body that start with "From " get escaped with a > 🫢
  • $obj->file() β€” ✨ Inherited, see "The whole message as text" in Mail::Message::Construct::Text.
  • $obj->lines() β€” ✨ Inherited, see "The whole message as text" in Mail::Message::Construct::Text.
  • $obj->printStructure( [$fh|undef],[$indent] ) β€” ✨ Inherited, see "The whole message as text" in Mail::Message::Construct::Text.
  • $obj->string() β€” ✨ Inherited, see "The whole message as text" in Mail::Message::Construct::Text.

πŸ’€ The nasty bits πŸ’€

  • $any->isa($class) β€” Obviously the isa() class inheritance check should not be seeing our nasty lil trick πŸ’…

🧚 Internals 🧚

Extends "Internals" in Mail::Message.

  • $obj->clonedFrom() β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $class->coerce($message) β€” Coerces (adapts the type of) that $message β€” anything Mail::Message::coerce() accepts β€” into an Mail::Internet-simulating object. Improves base, see "Internals" in Mail::Message.
  • $obj->isDelayed() β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $obj->readBody( $parser, $head, [$bodytype] ) β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $obj->readFromParser( $parser, [$bodytype] ) β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $obj->readHead( $parser, [$class] ) β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $obj->recursiveRebuildPart($part, %options) β€” ✨ Inherited, see "Internals" in Mail::Message::Construct::Rebuild.
  • $obj->storeBody($body) β€” ✨ Inherited, see "Internals" in Mail::Message.
  • $obj->takeMessageId( [STRING] ) β€” ✨ Inherited, see "Internals" in Mail::Message.

πŸ“ Error handling πŸ“

Extends "Error handling" in Mail::Message.

  • $obj->AUTOLOAD() β€” ✨ Inherited, see "METHODS" in Mail::Message::Construct.
  • $obj->notImplemented() β€” ✨ Inherited, see "Error handling" in Mail::Reporter.
  • $any->shortSize( [$value] ) β€” ✨ Inherited, see "Error handling" in Mail::Message.
  • $obj->shortString() β€” ✨ Inherited, see "Error handling" in Mail::Message.

πŸ’œ Cleanup πŸ’œ

Extends "Cleanup" in Mail::Message.

  • $obj->DESTROY() β€” ✨ Inherited, see "Cleanup" in Mail::Reporter.
  • $obj->destruct() β€” ✨ Inherited, see "Cleanup" in Mail::Message.

⭐ DETAILS ⭐

Extends "DETAILS" in Mail::Message.

πŸ’€ DIAGNOSTICS πŸ’€

okay bestie, this is the part where the module yells at you. Every single one of these is a real message you might see, and they all mean business, so let's go one by one πŸ’–

  • Error: Cannot include forward source as $kind. β€” you tried to forward(include) with something that isn't a real choice. The only valid options are "NO", "INLINE", "ATTACH", and "ENCAPSULATE". Cast by forward() ✨
  • Error: Mail::Internet does not support $what data. β€” the only data types allowed are a file handle or an ARRAY. Anything else? nope, not supported (peep read() if you want to do more). Cast by new() 🫢
  • Error: class $package does not implement method $method. β€” this one's fatal, bestie 😭 the specific $package (or one of its superclasses) just does not implement this method, even though it really should. What it means: some other related classes do implement it, but this one doesn't. So like… investigate, and probably tell the author of the package. Cast by notImplemented()
  • Error: method bounce requires To, Cc, or Bcc. β€” bounce() forwards a received message off to someone else with zero modification, so you must specify its new destination. If you're feeling like not specifying a destination, you're actually looking for reply(). And if you wanna modify the content? that's forward(). Cast by bounce() πŸ’…
  • Error: method forwardAttach requires a preamble. β€” Cast by forwardAttach()
  • Error: method forwardEncapsulate requires a preamble. β€” Cast by forwardEncapsulate()
  • Error: method forwardNo requires a To. β€” Cast by forwardNo()
  • Error: method forwardNo requires a body. β€” Cast by forwardNo()
  • Error: no rebuild rule $name defined. β€” Cast by rebuild()
  • Error: only build() Mail::Message's; they are not in a folder yet. β€” so you wanna construct a message to be stored in some kind of folder, but bestie you gotta do it in two steps. First, create a normal Mail::Message, and then add it to the folder. During that Mail::Box::addMessage() process, the message gets coerce()-d into the right message type, storage information and all that good stuff gets added. Cast by build() 🌸
  • Error: select parts via '$what'? β€” Cast by parts()
  • Warning: skipped unknown key '$key' in build. β€” 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/ πŸ¦‹


πŸ“œ LICENSE πŸ“œ

For contributors see file ChangeLog.

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. slay πŸ’–


and that's the whole page bestie!! this was Mail::M...nternet(3) from perl v5.42.0, dated 2026-02-05 β€” tysm for reading, go forth and email responsibly πŸ‘‘πŸ’…βœ¨

πŸ“¦ where this page comes from