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.008
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

METHODS

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

AUTHORS

122       ·   Ricardo SIGNES <rjbs@cpan.org>
123
124       ·   Simon Cozens <simon@cpan.org>
125
126       ·   Casey West <casey@geeknest.com>
127
129       This software is copyright (c) 2004 by Simon Cozens.
130
131       This is free software; you can redistribute it and/or modify it under
132       the same terms as the Perl 5 programming language system itself.
133
134
135
136perl v5.28.1                      2014-12-27                Email::Abstract(3)
Impressum