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         $email->set_body("Hello\nTest message\n");
22
23         $rfc822 = $email->as_string;
24
25         my $mail_message = $email->cast("Mail::Message");
26

DESCRIPTION

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

METHODS

45       All of these methods may be called either as object methods or as class
46       methods.  When called as class methods, the email object (of any class
47       supported by Email::Abstract) must be prepended to the list of argu‐
48       ments.
49
50       new
51
52         my $email = Email::Abstract->new($message);
53
54       Given a message, either as a string or as an object for which an
55       adapter is installed, this method will return a Email::Abstract object
56       wrapping the message.
57
58       If the message is given as a string, it will be used to construct an
59       object, which will then be wrapped.
60
61       get_header
62
63         my $header  = $email->get_header($header_name);
64         my $header  = Email::Abstract->get_header($message, $header_name);
65
66         my @headers = $email->get_header($header_name);
67         my @headers = Email::Abstract->get_header($message, $header_name);
68
69       This returns the value or list of values of the given header.
70
71       set_header
72
73         $email->set_header($header => @lines);
74         Email::Abstract->set_header($message, $header => @lines);
75
76       This sets the $header header to the given one or more values.
77
78       get_body
79
80         my $body = $email->get_body;
81
82         my $body = Email::Abstract->get_body($message);
83
84       This returns the body as a string.
85
86       set_body
87
88         $email->set_body($string);
89
90         Email::Abstract->set_body($message, $string);
91
92       This changes the body of the email to the given string.
93
94       as_string
95
96         my $string = $email->as_string;
97
98         my $string = Email::Abstract->as_string($message);
99
100       This returns the whole email as a string.
101
102       cast
103
104         my $mime_entity = $email->cast('MIME::Entity');
105         my $mime_entity = Email::Abstract->cast($message, '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
113         my $message = $email->object;
114
115       This method returns the message object wrapped by Email::Abstract.  If
116       called as a class method, it returns false.
117
118       Note that, because strings are converted to message objects before
119       wrapping, this method will return an object when the Email::Abstract
120       was constructed from a string.
121

PERL EMAIL PROJECT

123       This module is maintained by the Perl Email Project
124
125       <http://emailproject.perl.org/wiki/Email::Abstract>
126

AUTHOR

128       Casey West, <casey@geeknest.com>
129
130       Simon Cozens, <simon@cpan.org>
131
132       Ricardo SIGNES, <rjbs@cpan.org>
133
135       Copyright 2004 by Simon Cozens
136
137       This library is free software; you can redistribute it and/or modify it
138       under the same terms as Perl itself.
139
140
141
142perl v5.8.8                       2006-08-14                Email::Abstract(3)
Impressum