NAME
Mail::Folder::Emaul - An Emaul folder interface for Mail::Folder.
WARNING: This code is in alpha release. Expect the interface to change.
SYNOPSYS
use Mail::Folder::Emaul;
DESCRIPTION
This module provides an interface to the emaul folder mechanism. It is currently intended to be used as an example of hooking a folder interface into Mail::Folder.
The folder structure of Emaul is styled after mh. It uses directories for folders and numerically-named files for the individual mail messages. The current message for a particular folder is stored in a file .current_msg
in the folder directory.
Folder locking is accomplished through the use of a .lock file in the folder directory.
If a Timeout
option is specified when the object is created, that value will be used to determine the timeout for attempting to aquire a folder lock. The default is 10 seconds.
METHODS
open($folder_name)
Populates the Mail::Folder
object with information about the folder.
Call the superclass
open
method.Make sure it is a valid mbox folder.
Check to see it it is readonly
Lock the folder if it is not readonly. (This is dubious)
For every message file in the
$folder_name
directory, add the message_number to the list of messages in the object.Load the contents of
$folder_dir/.current_msg
into$self->{Current}
.Set
current_message
.Load message labels.
Unlock the folder if it is not readonly.
sync
Flushes any pending changes out to the original folder.
Call the superclass
sync
method.Return
-1
if the folder is readonly.Return
-1
if the folder cannot be locked.Scan the folder directory for message files that were not present the last time the folder was either
open
ed orsync
ed and absorb them.For every pending delete, unlink that file in the folder directory
Clear out the 'pending delete' list.
Update the
.current_msg
file and the.msg_labels
file if theNotMUA
option is not set.Return the number of new messages found.
pack
Calls the superclass pack
method.
Return 0
if the folder is readonly.
Return 0
if the folder cannot be locked.
Renames the message files in the folder so that there are no gaps in the numbering sequence. It will tweak current_message
accordingly.
Old deleted message files (ones that start with ,
) are also renamed as necessary.
It will abandon the operation and return 0
if a rename
fails, otherwise it returns 1
.
Please note that pack
acts on the real folder.
get_message($msg_number)
Calls the superclass get_message
method.
Retrieves the given mail message file into a Mail::Internet object reference and returns the reference.
It will coerce the From_
field into a Mail-From
field, add the 'seen
' label to the message, remove the Content-Length
field if present, and cache the header.
Returns undef
on failure.
get_message_file($msg_number)
Calls the superclass get_message_file
method.
Retrieves the given mail message file and returns the name of the file.
Returns undef
on failure.
get_header($msg_number)
Calls the superclass get_header
method.
If the particular header has never been retrieved then get_header
loads the header of the given mail message into a member of $self->{Messages}{$msg_number}
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.
The Content-Length
field is deleted from the header object it returns.
append_message($mref)
Calls the superclass append_message
method.
Returns 0
if it cannot lock the folder.
Appends the contents of the mail message contained $mref
to the the folder.
It also caches the header.
Please note that, contrary to other documentation for Mail::Folder, the Emaul append_message
method actually updates the real folder, rather than queueing it up for a subsequent sync. The dup
and refile
methods are also affected. This will be fixed soon.
update_message($msg_number, $mref)
Calls the superclass update_message
method.
It returns 0
if it cannot lock the folder.
Replaces the message pointed to by $msg_number
with the contents of the Mail::Internet
object reference $mref
.
Please note that, contrary to other documentation for Mail::Folder, the Emaul update_message
method actually updates the real folder, rather than queueing it up for a subsequent sync. This will be fixed soon.
is_valid_folder_format($foldername)
Returns 0
if the folder is not a directory or looks like a maildir folder. The current logic allows it to handle MH directories, but watch out; you should probably set the NotMUA
option so the interface doesn't create it's own little folder droppings like .msg_labels
and such.
create($foldername)
Returns 0
if the folder already exists.
Creates a new folder named $foldername
with mode 0700
and then returns 1
.
AUTHOR
Kevin Johnson <kjj@pobox.com>
COPYRIGHT
Copyright (c) 1996-1997 Kevin Johnson <kjj@pobox.com>.
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.