1Email::Abstract(3)    User Contributed Perl Documentation   Email::Abstract(3)
2
3
4

NAME

6       Email::Abstract - unified interface to mail representations
7

VERSION

9       version 3.009
10

SYNOPSIS

12         my $message = Mail::Message->read($rfc822)
13                    || Email::Simple->new($rfc822)
14                    || Mail::Internet->new([split /\n/, $rfc822])
15                    || ...
16                    || $rfc822;
17
18         my $email = Email::Abstract->new($message);
19
20         my $subject = $email->get_header("Subject");
21         $email->set_header(Subject => "My new subject");
22
23         my $body = $email->get_body;
24
25         $rfc822 = $email->as_string;
26
27         my $mail_message = $email->cast("Mail::Message");
28

DESCRIPTION

30       "Email::Abstract" provides module writers with the ability to write
31       simple, representation-independent mail handling code. For instance, in
32       the cases of "Mail::Thread" or "Mail::ListDetector", a key part of the
33       code involves reading the headers from a mail object. Where previously
34       one would either have to specify the mail class required, or to build a
35       new object from scratch, "Email::Abstract" can be used to perform
36       certain simple operations on an object regardless of its underlying
37       representation.
38
39       "Email::Abstract" currently supports "Mail::Internet", "MIME::Entity",
40       "Mail::Message", "Email::Simple", "Email::MIME", and "Courriel".  Other
41       representations are encouraged to create their own "Email::Abstract::*"
42       class by copying "Email::Abstract::EmailSimple".  All modules installed
43       under the "Email::Abstract" hierarchy will be automatically picked up
44       and used.
45

PERL VERSION SUPPORT

47       This module has a long-term perl support period.  That means it will
48       not require a version of perl released fewer than five years ago.
49
50       Although it may work on older versions of perl, no guarantee is made
51       that the minimum required version will not be increased.  The version
52       may be increased for any reason, and there is no promise that patches
53       will be accepted to lower the minimum required perl.
54

METHODS

56       All of these methods may be called either as object methods or as class
57       methods.  When called as class methods, the email object (of any class
58       supported by Email::Abstract) must be prepended to the list of
59       arguments, like so:
60
61         my $return = Email::Abstract->method($message, @args);
62
63       This is provided primarily for backwards compatibility.
64
65   new
66         my $email = Email::Abstract->new($message);
67
68       Given a message, either as a string or as an object for which an
69       adapter is installed, this method will return a Email::Abstract object
70       wrapping the message.
71
72       If the message is given as a string, it will be used to construct an
73       object, which will then be wrapped.
74
75   get_header
76         my $header  = $email->get_header($header_name);
77
78         my @headers = $email->get_header($header_name);
79
80       This returns the values for the given header.  In scalar context, it
81       returns the first value.
82
83   set_header
84         $email->set_header($header => @values);
85
86       This sets the $header header to the given one or more values.
87
88   get_body
89         my $body = $email->get_body;
90
91       This returns the body as a string.
92
93   set_body
94         $email->set_body($string);
95
96       This changes the body of the email to the given string.
97
98       WARNING!  You probably don't want to call this method, despite what you
99       may think.  Email message bodies are complicated, and rely on things
100       like content type, encoding, and various MIME requirements.  If you
101       call "set_body" on a message more complicated than a single-part seven-
102       bit plain-text message, you are likely to break something.  If you need
103       to do this sort of thing, you should probably use a specific message
104       class from end to end.
105
106       This method is left in place for backwards compatibility.
107
108   as_string
109         my $string = $email->as_string;
110
111       This returns the whole email as a decoded string.
112
113   cast
114         my $mime_entity = $email->cast('MIME::Entity');
115
116       This method will convert a message from one message class to another.
117       It will throw an exception if no adapter for the target class is known,
118       or if the adapter does not provide a "construct" method.
119
120   object
121         my $message = $email->object;
122
123       This method returns the message object wrapped by Email::Abstract.  If
124       called as a class method, it returns false.
125
126       Note that, because strings are converted to message objects before
127       wrapping, this method will return an object when the Email::Abstract
128       was constructed from a string.
129

AUTHORS

131       •   Ricardo SIGNES <rjbs@semiotic.systems>
132
133       •   Simon Cozens <simon@cpan.org>
134
135       •   Casey West <casey@geeknest.com>
136

CONTRIBUTORS

138       •   Dave Rolsky <autarch@urth.org>
139
140       •   Ricardo Signes <rjbs@cpan.org>
141
142       •   William Yardley <pep@veggiechinese.net>
143
145       This software is copyright (c) 2004 by Simon Cozens.
146
147       This is free software; you can redistribute it and/or modify it under
148       the same terms as the Perl 5 programming language system itself.
149
150
151
152perl v5.34.0                      2022-01-21                Email::Abstract(3)
Impressum