1Mail::Message::ConstrucUts:e:rReCaodn(t3r)ibuted Perl DoMcauimle:n:tMaetsisoange::Construct::Read(3)
2
3
4

NAME

6       Mail::Message::Construct::Read - read a Mail::Message from a file
7       handle
8

SYNOPSIS

10        my $msg1 = Mail::Message->read(\*STDIN);
11        my $msg2 = Mail::Message->read(\@lines);
12

DESCRIPTION

14       When complex methods are called on a "Mail::Message" object, this
15       package is autoloaded to support the reading of messages directly from
16       any file handle.
17

METHODS

19   Constructing a message
20       Mail::Message->read($fh|STRING|SCALAR|ARRAY, %options)
21           Read a message from a $fh, STRING, SCALAR, or a reference to an
22           ARRAY of lines.  Most %options are passed to the new() of the
23           message which is created, but a few extra are defined.
24
25           Please have a look at build() and buildFromBody() before thinking
26           about this "read" method.  Use this "read" only when you have a
27           file-handle like STDIN to parse from, or some external source of
28           message lines.  When you already have a separate set of head and
29           body lines, then "read" is certainly not your best choice.
30
31           Some people use this method in a procmail script: the message
32           arrives at stdin, so we only have a filehandle.  In this case, you
33           are stuck with this method.  The message is preceded by a line
34           which can be used as message separator in mbox folders.  See the
35           example how to handle that one.
36
37           This method will remove "Status" and "X-Status" fields when they
38           appear in the source, to avoid the risk that these fields
39           accidentally interfere with your internal administration, which may
40           have security implications.
41
42            -Option             --Default
43             body_type            undef
44             strip_status_fields  <true>
45
46           body_type => CLASS
47             Force a body type (any specific implementation of a
48             Mail::Message::Body) to be used to store the message content.
49             When the body is a multipart or nested, this will be overruled.
50
51           strip_status_fields => BOOLEAN
52             Remove the "Status" and "X-Status" fields from the message after
53             reading, to lower the risk that received messages from external
54             sources interfere with your internal administration.  If you want
55             fields not to be stripped (you would like to disable the
56             stripping) you probably process folders yourself, which is a Bad
57             Thing!
58
59           example:
60
61            my $msg1 = Mail::Message->read(\*STDIN);
62            my $msg2 = Mail::Message->read(\@lines, log => 'PROGRESS');
63            $folder->addMessages($msg1, $msg2);
64
65            my $msg3 = Mail::Message->read(<<MSG);
66            Subject: hello world
67            To: you@example.com
68                                 # warning: empty line required !!!
69            Hi, greetings!
70            MSG
71
72            # promail example
73            my $fromline = <STDIN>;
74            my $msg      = Mail::Message->read(\*STDIN);
75            my $coerced  = $mboxfolder->addMessage($msg);
76            $coerced->fromLine($fromline);
77

SEE ALSO

79       This module is part of Mail-Message distribution version 3.011, built
80       on July 27, 2021. Website: http://perl.overmeer.net/CPAN/
81

LICENSE

83       Copyrights 2001-2021 by [Mark Overmeer <markov@cpan.org>]. For other
84       contributors see ChangeLog.
85
86       This program is free software; you can redistribute it and/or modify it
87       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
88
89
90
91perl v5.34.0                      2021-07-27 Mail::Message::Construct::Read(3)
Impressum