1 package Email::Archive;
3 use Email::Archive::Storage::DBI;
9 does => 'Email::Archive::Storage',
12 retrieve => 'retrieve',
13 connect => 'storage_connect',
16 default => sub { Email::Archive::Storage::DBI->new }
26 Email::Archive - write emails to a database, fetch them
30 I only uploaded this to get it out there and kick myself into making it more
31 useful. As you can see it's not documented or tested yet. I put this together
32 mostly in one evening in a coffeeshop. It shows in some ways. caveat programmer.
36 Email::Archive provides an interface to store emails.
38 The default storage is Email::Archive::Storage::DBI that uses DBI.
39 All dokumented examples assume you use this default. For information
40 on how to use different engines see those modules documentation.
42 my $email_archive = Email::Archive->new;
43 $email_archive->connect($dsn);
44 $email_archive->store($msg);
46 $email_archive->retrieve($msg_id);
47 $email_archive->search({ from_addr => $from });
53 Defaults to Email::Archive::Storage::DBI->new.
55 my $e = Email::Archive->new;
59 my $storage = Email::Archive::Storage::DBI->new;
60 my $e = Email::Archive->new(
64 This usage will be necessary if a storage different form
65 Email::Archive::Storage::DBI is used.
71 Takes a DBI connection string as parameter.
73 $email_archive->connect('dbi:SQLite:dbname=emails');
75 For more information see DBI documentation.
77 If the database schema does not exist it will be deployed automatically by
82 $email_archive->store($msg);
84 Where $msg could be anything feedable to Email::Abstract. That is a raw
85 email, an Email::MIME object or even an Email::Abstract object.
87 The message will be stored in the messages table of the connected database.
91 $email_archive->search($attributes);
93 Search the database for emails where $attributes is a hashref containing
94 the fields to search and the values filter.
96 $attributes = { from_addr => $addr };
98 Will return the first found result as Email::MIME object.
100 $email_archive->search({ message_id => $some_id });
102 Is exactly the same as retrieval by Message-ID.
106 $email_archive->retrieve($msg_id);
108 Retrieve emails by Message-ID. Is a shortcut for
110 $email_archive->search({ message_id => $some_id });
114 This library may be used under the same terms as Perl itself.
116 =head1 AUTHOR AND COPYRIGHT
118 Copyright (c) 2010, 2011 Chris Nehren C<apeiron@cpan.org>.