NAME

Mail::Folder::Mbox - A Unix mbox interface for Mail::Folder.

WARNING: This code is in alpha release. Expect the interface to change.

SYNOPSYS

use Mail::Folder::Mbox;

DESCRIPTION

This module provides an interface to unix mbox folders.

The mbox folder format is the standard monolithic folder structure prevalent on Unix. A single folder is contained within a single file. Each message starts with a line matching /^From /.

The folder architecture doesn't provide any persistantly stored current message variable, so the current message in this folder interface defaults to 1 and is not retained between opens of a folder.

Mbox needs the following module packages:

TimeDate
File-Tools
File-BasicFLock

METHODS

init

Initializes various items specific to Mbox.

  • Determines an appropriate temporary directory.

  • Bumps a sequence number used for unique temporary filenames.

  • Initializes $self->{WorkingFile} to the name of a file that will be used to hold the temporary working of the folder.

  • Initializes $self->{MsgFilePrefix} to a string that will be used to create temporary filenames when extracting messages from the folder.

open($folder_name)

  • Call the superclass open method.

  • Lock the folder.

  • Copy the folder to a temporary location as a working copy.

  • Unlock the folder.

  • For every message in the folder, add the message_number to the object's list of messages.

close

Deletes the working copy of the folder and calls the superclass close method.

sync

  • Call the superclass sync method

  • Lock the folder

  • Append new messages to the working copy that have been appended to the folder since the last time the folder was either opened or synced.

  • Create a new copy of the folder and populate it with the messages in the working copy that aren't flagged for deletion.

  • Move the original folder to a temp location

  • Move the new folder into place

  • Delete the old original folder

  • Unlock the folder

pack

Calls the superclass pack method. This is essentially a no-op since mbox folders don't need to be packed.

get_message($msg_number)

  • Call the superclass get_message method.

  • Create a temporary file with the contents of the given mail message.

  • Absorb the temporary file into a Mail::Internet object reference.

  • Delete the temporary file.

  • Return the Mail::Internet object reference.

get_header($msg_number)

If the particular header has never been retrieved then get_header loads (in a manner similar to get_message) the header of the given mail message into $self->{Messages}{$msg_number}{Header} and returns the object reference.

If the header for the given mail message has already been retrieved in a prior call to get_header, then the cached entry is returned.

It also calls the superclass get_header method.

append_message($message_ref)

  • Call the superclass append_message method.

  • Lock the folder.

  • If a 'From ' line isn't present in $message_ref then synthesize one.

  • Append the contents of $message_ref to the folder.

  • Adds a record of the new message in the internal data structures of $self.

  • Unlock the folder.

update_message($msg_number, $message_ref)

  • Call the superclass update_message method.

  • Writes a new copy of the working folder file replacing the given message with the contents of the given Mail::Internet message reference. It will synthesize a 'From ' line if one isn't present in $message_ref.

create($foldername)

Creates a new folder named $foldername. Returns 0 if the folder already exists, otherwise returns of the folder creation was successful.

AUTHOR

Kevin Johnson <kjj@primenet.com>

COPYRIGHT

Copyright (c) 1996 Kevin Johnson <kjj@primenet.com>.

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.