Mail::M...t::Text(3)

πŸ’Œ Mail::M...t::Text β€” capture a Mail::Message as text

okay bestie so this is a User Contributed Perl Documentation page, filed under Mail::M...t::Text(3) πŸ’… and it's literally the glow-up guide for turning a whole message object into plain ol' text. no cap.


🌸 NAME

Mail::Message::Construct::Text β€” capture a Mail::Message as text ✨


πŸŽ€ SYNOPSIS

my $text = $msg->string;
my $text = "$msg";   # via overload

my @text = $msg->lines;
my @text = @$lines;  # via overload

my $fh   = $msg->file;
my $line = <$fh>;

$msg->printStructure;

like. look at it. it's giving effortless πŸ’–


πŸ¦‹ DESCRIPTION

so here's the tea β˜• β€” complex functionality on Mail::Message objects lives in a bunch of different files, and those files get autoloaded. this particular file implements the functionality related to creating message replies. that's the vibe. that's the whole vibe check. 🌈


πŸ‘‘ METHODS

πŸ’œ The whole message as text

  • $obj->file() β€” hands you the message back as a file-handle. yes, an actual handle. go wild. πŸ”₯
  • $obj->lines() β€” hands you the whole message back as a set of lines. in LIST context you get copies of the lines (not the originals, bestie, copies 🫢). in SCALAR context you get a reference to an array of lines.
  • $obj->printStructure( [$fh|undef],[$indent] ) β€” prints the structure of a message to the specified $fh, or to the selected filehandle if you didn't say. and when you explicitly pass undef as the handle? the output comes back as a string instead. iconic behaviour honestly. ✨

the message's subject and the types of all composing parts get displayed. slay.

$indent is the initial indentation string β€” it gets added in front of each line. heads up: $indent must contain at least one white-space. fr fr. ⚠️

Β» example:

my $msg = ...;
$msg->printStructure(\*OUTPUT);

$msg->printStructure;

my $struct = $msg->printStructure(undef);

# Possible output for one message:
multipart/mixed: forwarded message from Pietje Puk (1550 bytes)
   text/plain (164 bytes)
   message/rfc822 (1043 bytes)
      multipart/alternative: A multipart alternative (942 bytes)
         text/plain (148 bytes, deleted)
         text/html (358 bytes)
  • $obj->string() β€” returns the whole message as a string. that's it. that's the method. periodt. πŸ’…

🌟 Flags

ngl bestie, this heading is here and there is nothing under it. it's giving mystery. it's giving main character energy with no dialogue. πŸ™ˆ but we keep it, because we keep everything.

πŸ” 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.


and that's the whole page, bestie β€” perl v5.42.0, dated 2026-02-05, straight from Mail::M...t::Text(3). ate and left no crumbs. πŸŽ€πŸ’…πŸ¦‹βœ¨

πŸ“¦ where this page comes from