.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "Mail::Message::Construct::Read 3" .TH Mail::Message::Construct::Read 3 2026-04-11 "perl v5.42.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Mail::Message::Construct::Read \- read a Mail::Message from a file handle .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& my $msg1 = Mail::Message\->read(\e*STDIN); \& my $msg2 = Mail::Message\->read(\e@lines); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" When complex methods are called on a \f(CW\*(C`Mail::Message\*(C'\fR object, this package is autoloaded to support the reading of messages directly from any file handle. .SH METHODS .IX Header "METHODS" .SS "Constructing a message" .IX Subsection "Constructing a message" .ie n .IP "$class\->\fBread\fR($fh|$text|\e$text|\e@lines, %options)" 4 .el .IP "\f(CW$class\fR\->\fBread\fR($fh|$text|\e$text|\e@lines, \f(CW%options\fR)" 4 .IX Item "$class->read($fh|$text|$text|@lines, %options)" Read a message from a \f(CW$fh\fR, \f(CW$text\fR string, reference to a text string, or an ARRAY of \f(CW@lines\fR. Most \f(CW%options\fR are passed to the \fBnew()\fR of the message which is created, but a few extra are defined. .Sp Please have a look at \fBbuild()\fR and \fBbuildFromBody()\fR before thinking about this \f(CW\*(C`read\*(C'\fR method. Use this \f(CW\*(C`read\*(C'\fR only when you have a file\-handle like STDIN to parse from, or some external source of message lines. When you already have a separate set of head and body lines, then \f(CW\*(C`read\*(C'\fR is certainly \fBnot\fR your best choice. .Sp Some people use this method in a procmail script: the message arrives at stdin, so we only have a filehandle. In this case, you are stuck with this method. The message is preceded by a line which can be used as message separator in mbox folders. See the example how to handle that one. .Sp This method will remove \f(CW\*(C`Status\*(C'\fR and \f(CW\*(C`X\-Status\*(C'\fR fields when they appear in the source, to avoid the risk that these fields accidentally interfere with your internal administration, which may have security implications. .Sp .Vb 6 \& \-Option \-\-Default \& body_type undef \& parser_class undef \& seekable false \& strip_status_fields true \& trusted true .Ve .RS 4 .ie n .IP "body_type => $type" 2 .el .IP "body_type => \f(CW$type\fR" 2 .IX Item "body_type => $type" Force a body \f(CW$type\fR (any specific extension of the Mail::Message::Body class) to be used to store the message content. Multipart and nested message parts pick their own type. .ie n .IP "parser_class => $type" 2 .el .IP "parser_class => \f(CW$type\fR" 2 .IX Item "parser_class => $type" Enforce a certain parser \f(CW$type\fR to be used, which must be an extension of the Mail::Box::Parser class otherwise taken. .IP "seekable => BOOLEAN" 2 .IX Item "seekable => BOOLEAN" Indicate that a seekable file\-handle has been passed. In this case, we can use the Mail::Box::Parser::Perl parser which reads messages directly from the input stream. .IP "strip_status_fields => BOOLEAN" 2 .IX Item "strip_status_fields => BOOLEAN" Remove the \f(CW\*(C`Status\*(C'\fR and \f(CW\*(C`X\-Status\*(C'\fR fields from the message after reading, to lower the risk that received messages from external sources interfere with your internal administration. If you want fields not to be stripped (you would like to disable the stripping) you probably process folders yourself, which is a Bad Thing! .IP "trusted => BOOLEAN" 2 .IX Item "trusted => BOOLEAN" .RE .RS 4 .Sp ยป example: .Sp .Vb 3 \& my $msg1 = Mail::Message\->read(\e*STDIN); \& my $msg2 = Mail::Message\->read(\e@lines); \& $folder\->addMessages($msg1, $msg2); \& \& my $msg3 = Mail::Message\->read(<; \& my $msg = Mail::Message\->read(\e*STDIN); \& my $coerced = $mboxfolder\->addMessage($msg); \& $coerced\->fromLine($fromline); .Ve .RE .SH DIAGNOSTICS .IX Header "DIAGNOSTICS" .ie n .IP "Error: cannot read message from a $source." 4 .el .IP "Error: cannot read message from a \f(CW$source\fR." 4 .IX Item "Error: cannot read message from a $source." Cast by \f(CWread()\fR .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of Mail\-Message version 4.05, built on April 10, 2026. Website: \fIhttp://perl.overmeer.net/mailbox/\fR .SH LICENSE .IX Header "LICENSE" For contributors see file ChangeLog. .PP This software is copyright (c) 2001\-2026 by Mark Overmeer. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.