.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Email::Simple 3pm" .TH Email::Simple 3pm "2018-06-22" "perl v5.26.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" Email::Simple \- simple parsing of RFC2822 message format and headers .SH "VERSION" .IX Header "VERSION" version 2.216 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Email::Simple; \& my $email = Email::Simple\->new($text); \& \& my $from_header = $email\->header("From"); \& my @received = $email\->header("Received"); \& \& $email\->header_set("From", \*(AqSimon Cozens \*(Aq); \& \& my $old_body = $email\->body; \& $email\->body_set("Hello world\enSimon"); \& \& print $email\->as_string; .Ve .PP \&...or, to create a message from scratch... .PP .Vb 8 \& my $email = Email::Simple\->create( \& header => [ \& From => \*(Aqcasey@geeknest.com\*(Aq, \& To => \*(Aqdrain@example.com\*(Aq, \& Subject => \*(AqMessage in a bottle\*(Aq, \& ], \& body => \*(Aq...\*(Aq, \& ); \& \& $email\->header_set( \*(AqX\-Content\-Container\*(Aq => \*(Aqbottle/glass\*(Aq ); \& \& print $email\->as_string; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The Email:: namespace was begun as a reaction against the increasing complexity and bugginess of Perl's existing email modules. \f(CW\*(C`Email::*\*(C'\fR modules are meant to be simple to use and to maintain, pared to the bone, fast, minimal in their external dependencies, and correct. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 1 \& my $email = Email::Simple\->new($message, \e%arg); .Ve .PP This method parses an email from a scalar containing an \s-1RFC2822\s0 formatted message and returns an object. \f(CW$message\fR may be a reference to a message string, in which case the string will be altered in place. This can result in significant memory savings. .PP If you want to create a message from scratch, you should use the \f(CW"create"\fR method. .PP Valid arguments are: .PP .Vb 2 \& header_class \- the class used to create new header objects \& The named module is not \*(Aqrequire\*(Aq\-ed by Email::Simple! .Ve .SS "create" .IX Subsection "create" .Vb 1 \& my $email = Email::Simple\->create(header => [ @headers ], body => \*(Aq...\*(Aq); .Ve .PP This method is a constructor that creates an Email::Simple object from a set of named parameters. The \f(CW\*(C`header\*(C'\fR parameter's value is a list reference containing a set of headers to be created. The \f(CW\*(C`body\*(C'\fR parameter's value is a scalar value holding the contents of the message body. Line endings in the body will normalized to \s-1CRLF.\s0 .PP If no \f(CW\*(C`Date\*(C'\fR header is specified, one will be provided for you based on the \&\f(CW\*(C`gmtime\*(C'\fR of the local machine. This is because the \f(CW\*(C`Date\*(C'\fR field is a required header and is a pain in the neck to create manually for every message. The \&\f(CW\*(C`From\*(C'\fR field is also a required header, but it is \fInot\fR provided for you. .SS "header_obj" .IX Subsection "header_obj" .Vb 1 \& my $header = $email\->header_obj; .Ve .PP This method returns the object representing the email's header. For the interface for this object, see Email::Simple::Header. .SS "header_obj_set" .IX Subsection "header_obj_set" .Vb 1 \& $email\->header_obj_set($new_header_obj); .Ve .PP This method substitutes the given new header object for the email's existing header object. .SS "header" .IX Subsection "header" .Vb 3 \& my @values = $email\->header($header_name); \& my $first = $email\->header($header_name); \& my $value = $email\->header($header_name, $index); .Ve .PP In list context, this returns every value for the named header. In scalar context, it returns the \fIfirst\fR value for the named header. If second parameter is specified then instead \fIfirst\fR value it returns value at position \f(CW$index\fR (negative \f(CW$index\fR is from the end). .SS "header_set" .IX Subsection "header_set" .Vb 1 \& $email\->header_set($field, $line1, $line2, ...); .Ve .PP Sets the header to contain the given data. If you pass multiple lines in, you get multiple headers, and order is retained. If no values are given to set, the header will be removed from to the message entirely. .SS "header_raw" .IX Subsection "header_raw" This is another name (and the preferred one) for \f(CW\*(C`header\*(C'\fR. .SS "header_raw_set" .IX Subsection "header_raw_set" This is another name (and the preferred one) for \f(CW\*(C`header_set\*(C'\fR. .SS "header_raw_prepend" .IX Subsection "header_raw_prepend" .Vb 1 \& $email\->header_raw_prepend($field => $value); .Ve .PP This method adds a new instance of the name field as the first field in the header. .SS "header_names" .IX Subsection "header_names" .Vb 1 \& my @header_names = $email\->header_names; .Ve .PP This method returns the list of header names currently in the email object. These names can be passed to the \f(CW\*(C`header\*(C'\fR method one-at-a-time to get header values. You are guaranteed to get a set of headers that are unique. You are not guaranteed to get the headers in any order at all. .PP For backwards compatibility, this method can also be called as \fBheaders\fR. .SS "header_pairs" .IX Subsection "header_pairs" .Vb 1 \& my @headers = $email\->header_pairs; .Ve .PP This method returns a list of pairs describing the contents of the header. Every other value, starting with and including zeroth, is a header name and the value following it is the header value. .SS "header_raw_pairs" .IX Subsection "header_raw_pairs" This is another name (and the preferred one) for \f(CW\*(C`header_pairs\*(C'\fR. .SS "body" .IX Subsection "body" Returns the body text of the mail. .SS "body_set" .IX Subsection "body_set" Sets the body text of the mail. .SS "as_string" .IX Subsection "as_string" Returns the mail as a string, reconstructing the headers. .SS "crlf" .IX Subsection "crlf" This method returns the type of newline used in the email. It is an accessor only. .SS "default_header_class" .IX Subsection "default_header_class" This returns the class used, by default, for header objects, and is provided for subclassing. The default default is Email::Simple::Header. .SH "CAVEATS" .IX Header "CAVEATS" Email::Simple handles only \s-1RFC2822\s0 formatted messages. This means you cannot expect it to cope well as the only parser between you and the outside world, say for example when writing a mail filter for invocation from a .forward file (for this we recommend you use Email::Filter anyway). .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Simon Cozens .IP "\(bu" 4 Casey West .IP "\(bu" 4 Ricardo \s-1SIGNES\s0 .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 Brian Cassidy .IP "\(bu" 4 Christian Walde .IP "\(bu" 4 Marc Bradshaw .IP "\(bu" 4 Michael Stevens .IP "\(bu" 4 Pali .IP "\(bu" 4 Ricardo \s-1SIGNES\s0 .IP "\(bu" 4 Ronald F. Guilmette .IP "\(bu" 4 William Yardley .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2003 by Simon Cozens. .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.