1Mail::Message::Body::CoUnssetrruCcotn(t3r)ibuted Perl DoMcauimle:n:tMaetsisoange::Body::Construct(3)
2
3
4

NAME

6       Mail::Message::Body::Construct - adds functionality to
7       Mail::Message::Body
8

DESCRIPTION

10       This package adds complex functionality to the Mail::Message::Body
11       class.  This functions less often used, so many programs will not
12       compile this package.
13

METHODS

15   Constructing a body
16       $obj->attach(MESSAGES, OPTIONS)
17           Make a multipart containing this body and the specified MESSAGES.
18           The options are passed to the constructor of the multi-part body.
19           If you need more control, create the multi-part body yourself.  At
20           least take a look at Mail::Message::Body::Multipart.
21
22           The message-parts will be coerced into a Mail::Message::Part, so
23           you may attach Mail::Internet or MIME::Entity objects if you want
24           --see Mail::Message::coerce().  A new body with attached messages
25           is returned.
26
27           example:
28
29            my $pgpkey = Mail::Message::Body::File->new(file => 'a.pgp');
30            my $msg    = Mail::Message->buildFromBody(
31               $message->decoded->attach($pgpkey));
32
33            # The last message of the $multi multiparted body becomes a coerced $entity.
34            my $entity  = MIME::Entity->new;
35            my $multi   = $msg->body->attach($entity);
36
37            # Now create a new message
38            my $msg     = Mail::Message->new(head => ..., body => $multi);
39
40       $obj->concatenate(COMPONENTS)
41           Concatenate a list of elements into one new body.
42
43           Specify a list of text COMPONENTS.  Each component can be a message
44           (Mail::Message, the body of the message is used), a plain body
45           (Mail::Message::Body), "undef" (which will be skipped), a scalar
46           (which is split into lines), or an array of scalars (each providing
47           one line).
48
49           example:
50
51            # all arguments are Mail::Message::Body's.
52            my $sum = $body->concatenate($preamble, $body, $epilogue, "-- \n" , $sig);
53
54       $obj->foreachLine(CODE)
55           Create a new body by performing an action on each of its lines.  If
56           none of the lines change, the current body will be returned,
57           otherwise a new body is created of the same type as the current.
58
59           The CODE refers to a subroutine which is called, where $_ contains
60           body's original line.  DO NOT CHANGE $_!!!  The result of the
61           routine is taken as new line.  When the routine returns "undef",
62           the line will be skipped.
63
64           example:
65
66            my $content  = $msg->decoded;
67            my $reply    = $content->foreachLine( sub { '> '.$_ } );
68            my $rev      = $content->foreachLine( sub {reverse} );
69
70            sub filled() { length $_ > 1 ? $_ : undef }
71            my $nonempty = $content->foreachLine( \&filled );
72
73            my $wrong    = $content->foreachLine( sub {s/a/A/} );  # WRONG!!!
74            my $right    = $content->foreachLine(
75                   sub {(my $x=$_) =~ s/a/A/; $x} );
76
77       $obj->stripSignature(OPTIONS)
78           Strip the signature from the body.  The body must already be
79           decoded otherwise the wrong lines may get stripped.  Returned is
80           the stripped version body, and in list context also the signature,
81           encapsulated in its own body object.  The signature separator is
82           the first line of the returned signature body.
83
84           The signature is added by the sender to tell about him- or herself.
85           It is superfluous in some situations, for instance if you want to
86           create a reply to the person's message you do not need to include
87           that signature.
88
89           If the body had no signature, the original body object is returned,
90           and "undef" for the signature body.
91
92            -Option     --Default
93             max_lines    10
94             pattern      qr/^--\s?$/
95             result_type  <same as current>
96
97           max_lines => INTEGER|undef
98             The maximum number of lines which can be the length of a
99             signature.  Specify "undef" to remove the limit.
100
101           pattern => REGEX|STRING|CODE
102             Which pattern defines the line which indicates the separator
103             between the message and the signature.  In case of a STRING, this
104             is matched to the beginning of the line, and REGEX is a full
105             regular expression.
106
107             In case of CODE, each line (from last to front) is passed to the
108             specified subroutine as first argument.  The subroutine must
109             return TRUE when the separator is found.
110
111           result_type => CLASS
112             The type of body to be created for the stripped body (and maybe
113             also to contain the stripped signature)
114
115           example:
116
117            my $start = $message->decoded;
118            my $start = $body->decoded;
119
120            my $stripped = $start->stripSignature;
121
122            my ($stripped, $sign) = $start->stripSignature
123                (max_lines => 5, pattern => '-*-*-');
124

SEE ALSO

126       This module is part of Mail-Box distribution version 2.097, built on
127       January 26, 2011. Website: http://perl.overmeer.net/mailbox/
128

LICENSE

130       Copyrights 2001-2011 by Mark Overmeer. For other contributors see
131       ChangeLog.
132
133       This program is free software; you can redistribute it and/or modify it
134       under the same terms as Perl itself.  See
135       http://www.perl.com/perl/misc/Artistic.html
136
137
138
139perl v5.12.3                      2011-01-26 Mail::Message::Body::Construct(3)
Impressum