S. Zachariah Sprackett > Mail-Queue-DB > Mail::Queue::DB

Download:
Mail/Mail-Queue-DB-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Mail::Queue::DB - store outgoing email locally in a Berkely DB

SYNOPSIS ^

  use Mail::Queue::DB;
  my $d = new Mail::Queue:DB( db_file => '.database');

  print $d->count_queue() . " messages in the queue.\n";
  my $msg_id = $d->queue_mail($args, $msg);

  $z->dequeue_mail($msg_id);
  print $d->count_queue() . " messages in the queue.\n";

DESCRIPTION ^

Mail::Queue::DB allows one to create a local outgoing email store in Berkely DB format. This mail can then be flushed over SSH or some other connection to an appropriate mailhost. This module and the associated tools work well on systems like laptops that need to be able to send mail while offline. It was designed to be complementary to OfflineIMAP.

METHODS ^

new(db_file => $file)

Creates a new Mail::Queue::DB object. The argument db_file must be defined.

queue_mail($args, $msg)

Adds a new message to the queue. Args must contain the arguments required to pass to sendmail to actually send the email. Typically, these arguments will be something like: -oem -oi -- user@example.com

Msg contains the actual email message to be transmitted.

On success, the message id of the newly queued email will be returned. On failure, queue_mail() returns undef

queue_mail($id, $have_lock)

Deletes a message from the queue. Id must contain a valid message id. dequeue_mail() will attempt to attain a write lock on the database unless the boolean value have_lock is set.

On success, queue_mail() returns 0. On failure, it returns a negative value.

get_mail($id)

Fetches the message identified by Id from the queue. On success, it returns an array of Args, Msg. On failure it returns undef.

iterate_queue($callback, $locking)

For each message in the queue, run the passed callback function. Lock state specifies the lock to hold for the entire iteration run. It can be one of either read or write. If not specified, a read lock is assumed.

The passed in callback will receive arguments in the form callback( $id, $args, $msg )

count_queue( )

Returns an integer representing the number of emails currently in the queue.

AUTHOR ^

S. Zachariah Sprackett <zacs@cpan.org>

COPYRIGHT ^

(C) Copyright 2004, S. Zachariah Sprackett <zacs@cpan.org>

Distributed under the terms of the GPL version 2 or later.

SEE ALSO ^

mqdb-sendmail, mqdb-list, mqdb-rm, mqdb-flush

syntax highlighting: