Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  SYMPA::SPOOL (3)

.ds Aq ’


Sympa::Spool - Base class of spool classes



  package Sympa::Spool::FOO;
  use base qw(Sympa::Spool);
  sub _directories {
      return {
          directory     => /path/to/spool,
          bad_directory => /path/to/spool/bad,
  use constant _generator      => Sympa::Message;
  use constant _marshal_format => %s@%s.%ld.%ld,%d;
  use constant _marshal_keys   => [qw(localpart domainpart date PID RAND)];
  use constant _marshal_regexp =>


This module is the base class for spool subclasses of Sympa.

    Public methods

new ( [ options... ] ) Constructor. Creates new instance of the class.
next ( [ no_lock => 1 ] ) Instance method. Gets next message to process, order is controled by name of spool file and so on. Message will be locked to prevent multiple proccessing of a single message.

no_lock => 1 Won’t lock messages.


Two-elements list of message instance and filehandle locking a message. If parsing message fails, list of undef and filehandle. If no more message found, empty array.

If no_lock is set, true scalar value will be returned in place of filehandle.

quarantine ( $handle ) Instance method. Quarantines a message. On filesystem spool, message will be moved into {bad_directory} of the spool using rename().

$handle Filehandle, Sympa::LockedFile instance, locking message.


True value if message could be quarantined. Otherwise false value.

If $handle was not a filehandle, this method will die.

remove ( $handle ) Instance method. Removes a message.

$handle Filehandle, Sympa::LockedFile instance, locking message.


True value if message could be removed. Otherwise false value.

If $handle was not a filehandle, this method will die.

size ( ) Instance method. Gets the number of messages the spool contains.




Number of messages.

Note: This method returns the number of messages _load() returns, not applying _filter().

store ( $message, [ original => $original ] ) Instance method. Stores the message into spool.

$message Message to be stored.
original => $original If true value is specified and $message was decrypted, Stores original encrypted form.


If storing succeeded, marshalled metadata (file name) of the message. Otherwise undef.


Instance of Sympa::Spool may have following properties.
Directories Directories _directories() method returns: {directory}, {bad_directory} and so on.

    Low level functions

build_glob_pattern ( $marshal_format, $marshal_keys, [ key => value, ... ] ) Function. Builds a glob pattern from parameters and returns it. If built pattern is empty or contains only punctuations, i.e. [^0-9A-Za-z\x80-\xFF], will return undef.
split_listname ( $robot, $localpart ) Function. Split local part of e-mail to list name and type. Returns an array (name, type). Note that the list with returned name may or may not exist.

If local part looks like listmaster or sympa address, name is undef and type is either listmaster or sympa. Otherwise, type is either editor, owner, return_path, subscribe, unsubscribe, UNKNOWN or undef.

Note: For -request and -owner suffix, this function returns owner and return_path types, respectively.

store_spool ( $spool_dir, $message, $marshal_format, $marshal_keys, [ key => value, ... ] ) Function. Store $message into directory $spool_dir as a file with name as marshalled metadata using $marshal_format and $marshal_keys.
unmarshal_metadata ( $spool_dir, $marshalled, $marshal_regexp, $marshal_keys ) Function. Unmarshals metadata. Returns hashref with keys in arrayref $marshal_keys and values with substrings captured by regexp $marshal_regexp. If $marshalled did not match against $marshal_regexp, returns undef.

The keys localpart and domainpart are special. Following keys are derived from them: context, listname, listtype, priority.

marshal_metadata ( $message, $marshal_format, $marshal_keys ) Function. Marshals metadata. Returns formatted string by sprintf() using $marshal_format and metadatas indexed by keys in arrayref $marshal_keys.

If key is uppercase, it means auto-generated value: AUTHKEY, DATE, PID, RAND, TIME. Otherwise it means metadata or property of $message.

sprintf() is executed under C locale: Full stop (.) is always used for decimal point in floating point number.

    Methods subclass should implement

_create ( ) Instance method, overridable. Creates spool. By default, creates directories returned by _directories().
_directories ( [ options, ... ] ) Class or instance method, mandatory for filesystem spool. Returns hashref with directory paths related to the spool as values. It must have keys at least directory and (if you wish to implement quarantine() method) bad_directory.
_filter ( $metadata ) Instance method, overridable. If it returned false value, processing of $metadata by next() will be skipped. By default, always returns true value.

This method may modify unmarshalled metadata _and_ deserialized messages include it.

_filter_pre ( $metadata ) Instance method, overridable. If it returned false value, processing of $metadata by store() will be skipped. By default, always returns true value.

This method may modify marshalled metadata _but_ stored messages are not affected.

_generator ( ) Class or instance method, mandatory. Returns name of the class to serialize and deserialize messages in the spool. If spool subclass is the collection (see _is_collection), generator class must implement new(). Otherwise, generator class must implement dup(), new() and to_string().
_glob_pattern ( ) Instance method. If implemented and returns non-empty string, glob() is used to search entries in the spool. Otherwise readdir() is used for filesystem spool to get all entries.
_init ( $state ) Instance method. Additional processing when _load() returns no contents ($state is 1) or when the spool class is instantiated ($state is 0).
_is_collection ( ) Instance method, overridable. If the class is collection of spool class, returns true value. By default returns false value.

Collection class does not have store() method. Its content is the set of spool instances.

_load ( ) Instance method, overridable. Loads sorted content of spool. Returns arrayref of marshalled metadatas. By default, returns content of {directory} directory sorted by file name.
_marshal_format ( )
_marshal_keys ( )
_marshal_regexp ( ) Instance methods, mandatory for filesystem spool. _marshal_format() and _marshal_keys() are used to marshal metadata. _marshal_keys() and _marshal_regexp() are used to unmarshal metadata. See also marshal_metadata() and unmarshal_metadata().
_store_key ( ) Instance method. If implemented and returns non-empty string, store() returns an item in metadata specified by this method. By default store() returns marshalled metadata (file name on filesystem spool).

    Marshaling and unmarshaling metadata

Spool class gives generator class the metadata to instantiate it. On spool based on filesystem, it is typically encoded into file names. For example a file name in incoming spool (Sympa::Spool::Incoming)

encodes the metadata

  localpart  => listname-owner,
  listname   => listname,
  listtype   => return_path,
  domainpart =>,
  date       => 143599229,

Metadata always includes information of context: List, Robot or Site. For example:

- Message in incoming spool bound for <>:

  context    => Sympa::List <>,

- Command message in incoming spool bound for <>:

  context    =>,

- Message sent from Sympa to super-listmaster(s):

  context    => *

Context is determined when the generator class is instantiated, and generally never changed through lifetime of instance. Thus, constructor of generator class should take context object as an argument.


Following site configuration parameters in sympa.conf will be referred.
sympa_priority Used to extract metadata from marshalled data (file name).
umask The umask to make directories of spool.


Sympa::Message, especially Serialization.


Sympa::Spool appeared on Sympa 6.2. It as the base class appeared on Sympa 6.2.6.

build_glob_pattern(), size(), _glob_pattern() and _store_key() were introduced on Sympa 6.2.8. _filter_pre() was introduced on Sympa 6.2.10.

Search for    or go to Top of page |  Section 3 |  Main Index

6.2.14 SYMPA::SPOOL (3Sympa) 2016-01-06

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.