Email::Archive::Storage::MongoDB - write emails to MongoDB
Email::Archive::Storage::MongoDB is a storage engine for Email::Archive to store emails in a MongoDB database.
Construction and connecting to the database is slightly different from the default. The other methods should work like documented in Email::Archive.
my $storage = Email::Archive::Storage::MongoDB->new( host => $hostname, # defaults to localhost port => $port, # defaults to 27017 database => $db_name, collection => $collection_name, ); my $mongo_archive = Email::Archive->new( storage => $storage, );
Or my $mongo_archive = Email::Archive->new( storage => Email::Archive::Storage::MongoDB->new; );
The alternate construction needs a connection string passed to connect.
The database host to connect to. Default is localhost.
The port on the database host to connect to. Defaults to MongoDBs default port 27017.
A valid MongoDB database name. If the database does not exist it will be created.
A MongoDB collection name. If the collection does not exist it will be created automatically.
If the storage was constructed passing all the needed arguments just connect.
$mongo_archive->connect;
Alternative connection needs to have a connection string of the format host:port:database:collection and will override previously configured values.
$mongo_archive->connect("$host:$port:$dbname:$collname");
$email_archive->store($msg);
Where $msg could be anything feedable to Email::Abstract. That is a raw email, an Email::MIME object or even an Email::Abstract object.
The message will be stored in the messages table of the connected database.
$email_archive->search($attributes);
Search the database for emails where $attributes is a hashref containing the fields to search and the values filter.
$attributes = { from_addr => $addr };
Will return the first found result as Email::MIME object.
$email_archive->search({ message_id => $some_id });
Is exactly the same as retrieval by Message-ID.
$email_archive->retrieve($msg_id);
Retrieve emails by Message-ID. Is a shortcut for
This library may be used under the same terms as Perl itself.
Copyright (c) 2010, 2011 Chris Nehren apeiron@cpan.org.
apeiron@cpan.org
To install Email::Archive, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Email::Archive
CPAN shell
perl -MCPAN -e shell install Email::Archive
For more information on module installation, please visit the detailed CPAN module installation guide.