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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

METHODS

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

PERL EMAIL PROJECT

119       This module is maintained by the Perl Email Project
120
121       <http://emailproject.perl.org/wiki/Email::Abstract>
122

AUTHOR

124       Casey West, <casey@geeknest.com>
125
126       Simon Cozens, <simon@cpan.org>
127
128       Ricardo SIGNES, <rjbs@cpan.org>
129
131       Copyright 2004 by Simon Cozens
132
133       This library is free software; you can redistribute it and/or modify it
134       under the same terms as Perl itself.
135
136
137
138perl v5.12.1                      2010-06-12                Email::Abstract(3)
Impressum