.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .\" ======================================================================== .\" .IX Title "Email::Abstract 3" .TH Email::Abstract 3 2024-05-04 "perl v5.38.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::Abstract \- unified interface to mail representations .SH VERSION .IX Header "VERSION" version 3.010 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 5 \& my $message = Mail::Message\->read($rfc822) \& || Email::Simple\->new($rfc822) \& || Mail::Internet\->new([split /\en/, $rfc822]) \& || ... \& || $rfc822; \& \& my $email = Email::Abstract\->new($message); \& \& my $subject = $email\->get_header("Subject"); \& $email\->set_header(Subject => "My new subject"); \& \& my $body = $email\->get_body; \& \& $rfc822 = $email\->as_string; \& \& my $mail_message = $email\->cast("Mail::Message"); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" \&\f(CW\*(C`Email::Abstract\*(C'\fR provides module writers with the ability to write simple, representation-independent mail handling code. For instance, in the cases of \f(CW\*(C`Mail::Thread\*(C'\fR or \f(CW\*(C`Mail::ListDetector\*(C'\fR, a key part of the code involves reading the headers from a mail object. Where previously one would either have to specify the mail class required, or to build a new object from scratch, \f(CW\*(C`Email::Abstract\*(C'\fR can be used to perform certain simple operations on an object regardless of its underlying representation. .PP \&\f(CW\*(C`Email::Abstract\*(C'\fR currently supports \f(CW\*(C`Mail::Internet\*(C'\fR, \f(CW\*(C`MIME::Entity\*(C'\fR, \&\f(CW\*(C`Mail::Message\*(C'\fR, \f(CW\*(C`Email::Simple\*(C'\fR, \f(CW\*(C`Email::MIME\*(C'\fR, and \f(CW\*(C`Courriel\*(C'\fR. Other representations are encouraged to create their own \f(CW\*(C`Email::Abstract::*\*(C'\fR class by copying \f(CW\*(C`Email::Abstract::EmailSimple\*(C'\fR. All modules installed under the \&\f(CW\*(C`Email::Abstract\*(C'\fR hierarchy will be automatically picked up and used. .SH "PERL VERSION" .IX Header "PERL VERSION" This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years. .PP Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. .SH METHODS .IX Header "METHODS" All of these methods may be called either as object methods or as class methods. When called as class methods, the email object (of any class supported by Email::Abstract) must be prepended to the list of arguments, like so: .PP .Vb 1 \& my $return = Email::Abstract\->method($message, @args); .Ve .PP This is provided primarily for backwards compatibility. .SS new .IX Subsection "new" .Vb 1 \& my $email = Email::Abstract\->new($message); .Ve .PP Given a message, either as a string or as an object for which an adapter is installed, this method will return a Email::Abstract object wrapping the message. .PP If the message is given as a string, it will be used to construct an object, which will then be wrapped. .SS get_header .IX Subsection "get_header" .Vb 1 \& my $header = $email\->get_header($header_name); \& \& my @headers = $email\->get_header($header_name); .Ve .PP This returns the values for the given header. In scalar context, it returns the first value. .SS set_header .IX Subsection "set_header" .Vb 1 \& $email\->set_header($header => @values); .Ve .PP This sets the \f(CW$header\fR header to the given one or more values. .SS get_body .IX Subsection "get_body" .Vb 1 \& my $body = $email\->get_body; .Ve .PP This returns the body as a string. .SS set_body .IX Subsection "set_body" .Vb 1 \& $email\->set_body($string); .Ve .PP This changes the body of the email to the given string. .PP \&\fBWARNING!\fR You probably don't want to call this method, despite what you may think. Email message bodies are complicated, and rely on things like content type, encoding, and various MIME requirements. If you call \f(CW\*(C`set_body\*(C'\fR on a message more complicated than a single-part seven-bit plain-text message, you are likely to break something. If you need to do this sort of thing, you should probably use a specific message class from end to end. .PP This method is left in place for backwards compatibility. .SS as_string .IX Subsection "as_string" .Vb 1 \& my $string = $email\->as_string; .Ve .PP This returns the whole email as a decoded string. .SS cast .IX Subsection "cast" .Vb 1 \& my $mime_entity = $email\->cast(\*(AqMIME::Entity\*(Aq); .Ve .PP This method will convert a message from one message class to another. It will throw an exception if no adapter for the target class is known, or if the adapter does not provide a \f(CW\*(C`construct\*(C'\fR method. .SS object .IX Subsection "object" .Vb 1 \& my $message = $email\->object; .Ve .PP This method returns the message object wrapped by Email::Abstract. If called as a class method, it returns false. .PP Note that, because strings are converted to message objects before wrapping, this method will return an object when the Email::Abstract was constructed from a string. .SH AUTHORS .IX Header "AUTHORS" .IP \(bu 4 Ricardo SIGNES .IP \(bu 4 Simon Cozens .IP \(bu 4 Casey West .SH CONTRIBUTORS .IX Header "CONTRIBUTORS" .IP \(bu 4 Dave Rolsky .IP \(bu 4 Ricardo Signes .IP \(bu 4 William Yardley .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2004 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.