Mail::Message::Body::Construct
adds functionality to Mail::Message::Body
- Provided by: libmail-message-perl (Version: 4.03-1)
- Report a bug
adds functionality to Mail::Message::Body
This package adds complex functionality to the Mail::Message::Body class. This functions less often used, so many programs will not compile this package.
The message-parts will be coerced into a Mail::Message::Part, so you may attach Mail::Internet or MIME::Entity objects if you want --see Mail::Message::coerce(). A new body with attached messages is returned.
» example:
my $pgpkey = Mail::Message::Body::File->new(file => 'a.pgp');
my $msg = Mail::Message->buildFromBody($message->decoded->attach($pgpkey));
# The last message of the $multi multiparted body becomes a coerced $entity.
my $entity = MIME::Entity->new;
my $multi = $msg->body->attach($entity);
# Now create a new message
my $msg = Mail::Message->new(head => ..., body => $multi);
Specify a list of text @components. Each component can be
» example:
# all arguments are Mail::Message::Body's. my $sum = $body->concatenate($preamble, $body, $epilogue, "-- \n" , $sig);
The "CODE" refers to a subroutine which is called, where $_ contains body's original line. DO NOT CHANGE $_!!! The result of the routine is taken as new line. When the routine returns "undef", the line will be skipped.
» example:
my $content = $msg->decoded;
my $reply = $content->foreachLine( sub { '> '.$_ } );
my $rev = $content->foreachLine( sub { reverse } );
sub filled() { length $_ > 1 ? $_ : undef }
my $nonempty = $content->foreachLine( \&filled );
my $WRONG = $content->foreachLine( sub { s/a/A/ } );
my $right = $content->foreachLine( sub { s/a/A/r });
The signature is added by the sender to tell about him- or herself. It is superfluous in some situations, for instance if you want to create a reply to the person's message you do not need to include that signature.
If the body had no signature, the original body object is returned, and "undef" for the signature body.
-Option --Default
max_lines 10
pattern qr/^--\s?$/
result_type <same as current>
In case of CODE, each line (from last to front) is passed to the specified subroutine as first argument. The subroutine must return TRUE when the separator is found.
» example:
my $start = $message->decoded;
my $start = $body->decoded;
my $stripped = $start->stripSignature;
my ($stripped, $sign) = $start->stripSignature
(max_lines => 5, pattern => '-*-*-');
This module is part of Mail-Message version 4.03, built on January 26, 2026. Website: http://perl.overmeer.net/CPAN/
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.