The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sietima::MailStore::FS - filesystem-backed email store

VERSION

version 1.1.2

SYNOPSIS

  my $store = Sietima::MailStore::FS->new({ root => '/tmp/my-store' });

DESCRIPTION

This class implements the Sietima::MailStore interface, storing emails as files on disk.

ATTRIBUTES

root

Required, a Path::Tiny object that points to an existing directory. Coercible from a string.

It's a good idea for the directory to be readable and writable by the user who will run the mailing list, and also by all users who will run administrative commands (like those provided by Sietima::Role::SubscriberOnly::Moderate). A way to achieve that is to have a group dedicated to list owners, and set the directory group-writable and group-sticky, and owned by that group:

  # chgrp -R mailinglists /tmp/my-store
  # chmod -R g+rwXs /tmp/my-store

METHODS

store

  my $id = $store->store($email_mime_object,@tags);

Stores the given email message inside the store root, and associates it with the given tags.

Returns a unique identifier for the stored message. If you store twice the same message (or two messages that stringify identically), you'll get the same identifier.

retrieve_by_id

  my $email_mime_object = $store->retrieve_by_id($id);

Given an identifier returned by "store", this method returns the email message.

If the message has been deleted, or the identifier is not recognised, this method returns undef in scalar context, or an empty list in list context.

retrieve_ids_by_tags

  my @ids = $store->retrieve_ids_by_tags(@tags)->@*;

Given a list of tags, this method returns an arrayref containing the identifiers of all (and only) the messages that were stored associated with (at least) all those tags. The order of the returned identifiers is essentially random.

If there are no messages associated with the given tags, this method returns an empty arrayref.

retrieve_by_tags

  my @email_mime_objects = $store->retrieve_by_tags(@tags)->@*;

This method is similar to "retrieve_ids_by_tags", but it returns an arrayref of hashrefs like:

 $store->retrieve_by_tags('t1') ==> [
   { id => $id1, mail => $msg1 },
   { id => $id2, mail => $msg2 },
  ]

remove

  $store->remove($id);

This method removes the message corresponding to the given identifier from disk. Removing a non-existent message does nothing.

clear

  $store->clear();

This method removes all messages from disk. Clearing as empty store does nothing.

AUTHOR

Gianni Ceccarelli <dakkar@thenautilus.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Gianni Ceccarelli <dakkar@thenautilus.net>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.