=encoding utf8

=head1 NAME

Mail::Message::Construct::Text - capture a Mail::Message as text

=head1 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;

=head1 DESCRIPTION

Complex functionality on L<Mail::Message|Mail::Message> objects is implemented in
different files which are autoloaded.  This file implements the
functionality related to creating message replies.

=head1 METHODS

=head2 The whole message as text

=over 4

=item $obj-E<gt>B<file>()

Returns the message as file-handle.

=item $obj-E<gt>B<lines>()

Returns the whole message as set of lines.  In LIST context, copies of the
lines are returned.  In SCALAR context, a reference to an array of lines
is returned.

=item $obj-E<gt>B<printStructure>( [$fh|undef],[$indent] )

Print the structure of a message to the specified C<$fh> or the
selected filehandle.  When explicitly C<undef> is specified as handle,
then the output will be returned as string.

The message's subject and the types of all composing parts are
displayed.

C<$indent> specifies the initial indentation string: it is added in front
of each line. The C<$indent> must contain at least one white-space.

» 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)

=item $obj-E<gt>B<string>()

Returns the whole message as string.

=back

=head2 Flags

=head1 SEE ALSO

This module is part of Mail-Message version 4.05,
built on April 10, 2026. Website: F<http://perl.overmeer.net/mailbox/>

=head1 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.

