1Mail::Message::ConstrucUts:e:rReCaodn(t3r)ibuted Perl DoMcauimle:n:tMaetsisoange::Construct::Read(3)
2
3
4
6 Mail::Message::Construct::Read - read a Mail::Message from a file han‐
7 dle
8
10 my $msg1 = Mail::Message->read(\*STDIN);
11 my $msg2 = Mail::Message->read(\@lines);
12
14 When complex methods are called on a "Mail::Message" object, this pack‐
15 age is autoloaded to support the reading of messages directly from any
16 file handle.
17
19 Constructing a message
20
21 Mail::Message->read(FILEHANDLE⎪SCALAR⎪REF-SCALAR⎪ARRAY-OF-LINES,
22 OPTIONS)
23
24 Read a message from a FILEHANDLE, SCALAR, a reference to a SCALAR,
25 or a reference to an array of LINES. Most OPTIONS are passed to
26 the new() of the message which is created, but a few extra are
27 defined.
28
29 Please have a look at build() and buildFromBody() before thinking
30 about this "read" method. Use this "read" only when you have a
31 file-handle like STDIN to parse from, or some external source of
32 message lines. When you already have a separate set of head and
33 body lines, then "read" is certainly not your best choice.
34
35 Some people use this method in a procmail script: the message
36 arrives at stdin, so we only have a filehandle. In this case, you
37 are stuck with this method. The message is preceeded by a line
38 which can be used as message separator in mbox folders. See the
39 example how to handle that one.
40
41 This method will remove "Status" and "X-Status" fields when they
42 appear in the source, to avoid the risk that these fields acciden‐
43 tally interfere with your internal administration, which may have
44 security implications.
45
46 Option --Default
47 body_type undef
48 strip_status_fields <true>
49
50 . body_type CLASS
51
52 Force a body type (any specific implementation of a Mail::Mes‐
53 sage::Body) to be used to store the message content. When the
54 body is a multipart or nested, this will be overruled.
55
56 . strip_status_fields BOOLEAN
57
58 Remove the "Status" and "X-Status" fields from the message
59 after reading, to lower the risk that received messages from
60 external sources interfere with your internal administration.
61 If you want fields not to be stripped (you would like to dis‐
62 able the stripping) you probably process folders yourself,
63 which is a Bad Thing!
64
65 Example:
66
67 my $msg1 = Mail::Message->read(\*STDIN);
68 my $msg2 = Mail::Message->read(\@lines, log => 'PROGRESS');
69 $folder->addMessages($msg1, $msg2);
70
71 my $msg3 = Mail::Message->read(<<MSG);
72 Subject: hello world
73 To: you@example.com
74 # warning: empty line required !!!
75 Hi, greetings!
76 MSG
77
78 # promail example
79 my $fromline = <STDIN>;
80 my $msg = Mail::Message->read(\*STDIN);
81 my $coerced = $mboxfolder->addMessage($msg);
82 $coerced->fromLine($fromline);
83
85 This module is part of Mail-Box distribution version 2.070, built on
86 March 25, 2007. Website: http://perl.overmeer.net/mailbox/
87
89 Copyrights 2001-2007 by Mark Overmeer.For other contributors see
90 ChangeLog.
91
92 This program is free software; you can redistribute it and/or modify it
93 under the same terms as Perl itself. See
94 http://www.perl.com/perl/misc/Artistic.html
95
96
97
98perl v5.8.8 2007-03-25 Mail::Message::Construct::Read(3)