Mail::Box::MH - handle MH folders Mail::Box::MH is a Mail::Box::Dir is a Mail::Box is a Mail::Reporter use Mail::Box::MH; my $folder = new Mail::Box::MH folder => $ENV{MAIL}, ...; This documentation describes how MH mailboxes work, and what you can do with the MH folder object "Mail::Box::MH". Please read "Mail::Box-Overview" and "Mail::Box" first. The internal organization and details are found at the bottom of this manual-page. Methods prefixed with an abbreviation are described in Mail::Box (MB), Mail::Reporter (MR), Mail::Box::Dir (MBD). The general methods for "Mail::Box::MH" objects: MB addMessage MESSAGE MB message INDEX [,MESSAGE] MB addMessages MESSAGE [, MESS... MB messageId MESSAGE-ID [,MESS... MB close OPTIONS MB messageIds MB copyTo FOLDER, OPTIONS MB messages ['ALL',RANGE,'ACTI... MB create FOLDERNAME [, OPTIONS] MB modified [BOOLEAN] MB current [NUMBER|MESSAGE|MES... MB name MB delete new OPTIONS MBD directory MB openSubFolder NAME [,OPTIONS] MR errors MR report [LEVEL] MB find MESSAGE-ID MR reportAll [LEVEL] MB listSubFolders OPTIONS MR trace [LEVEL] MB locker MR warnings MR log [LEVEL [,STRINGS]] MB writable The extra methods for extension writers: MR AUTOLOAD MR notImplemented MB DESTROY MB openRelatedFolder OPTIONS MB appendMessages OPTIONS MB organization MB clone OPTIONS MB read OPTIONS MB coerce MESSAGE MBD readMessageFilenames DIRECTORY MB determineBodyType MESSAGE, ... MB readMessages OPTIONS MBD folderToDirectory FOLDERNAM... MB scanForMessages MESSAGE, ME... MB folderdir [DIR] MB sort PREPARE, COMPARE, LIST MB foundIn [FOLDERNAME], OPTIONS MB storeMessage MESSAGE highestMessageNumber MB timespan2seconds TIME MR inGlobalDestruction MB toBeThreaded MESSAGES index MB toBeUnthreaded MESSAGES labels MB update OPTIONS MB lineSeparator [STRING|'CR'|... MB updateMessages OPTIONS MR logPriority LEVEL MB write OPTIONS MR logSettings writeMessages [OPTIONS] Create a new folder. The are many options which are taken from other objects. For some, different options are set. For MH-specific options see below, but first the full list. OPTION DEFINED BY DEFAULT access Mail::Box 'r' create Mail::Box 0 folder Mail::Box $ENV{MAIL} folderdir Mail::Box <no default> head_wrap Mail::Box 72 index_filename Mail::Box::MH foldername.'/.index' keep_dups Mail::Box 0 keep_index Mail::Box::MH 0 labels_filename Mail::Box::MH foldername.'/.mh_sequence' extract Mail::Box 10kB lock_type Mail::Box 'DOTLOCK' lock_file Mail::Box foldername.'/.lock' lock_timeout Mail::Box 3600 (1 hour) lock_wait Mail::Box 10 (seconds) log Mail::Reporter 'WARNINGS' remove_when_empty Mail::Box 1 save_on_exit Mail::Box 1 trace Mail::Reporter 'WARNINGS' trusted Mail::Box <depends on folder location> Only useful to write extension to "Mail::Box::MH". Common users of folders you will not specify these: OPTION DEFINED BY DEFAULT body_type Mail::Box::Dir <see Mail::Box::Dir> body_delayed_type Mail::Box 'Mail::Message::Body::Delayed' coerce_options Mail::Box [] field_type Mail::Box undef head_type Mail::Box 'Mail::Message::Head::Complete' head_delayed_type Mail::Box 'Mail::Message::Head::Delayed' index Mail::Box::MH undef index_type Mail::Box::MH 'Mail::Box::MH::Index' labels Mail::Box::MH undef labels_type Mail::Box::MH 'Mail::Box::MH::Labels' locker Mail::Box undef multipart_type Mail::Box 'Mail::Message::Body::Multipart' manager Mail::Box undef message_type Mail::Box 'Mail::Box::MH::Message' realhead_type Mail::Box 'Mail::Message::Head' MH specific options: Keep an index file of the specified mailbox, one file per directory. Using an index file will speed up things considerably, because it avoids reading all the message files the moment that you open the folder. When you open a folder, you can use the index file to retrieve information such as the subject of each message, instead of having to read possibly thousands of messages. The FILENAME which is used in each directory to store the headers of all mails. The filename shall not contain a directory path. (e.g. Do not use "/usr/people/jan/.index", nor "subdir/.index", but say ".index".) You may specify an OBJECT of a type which extends "Mail::Box::MH::Index" (at least implements the "get()" method), as alternative for an index file reader as created by "Mail::Box::MH". In MH-folders, messages can be labeled, for instance based on the sender or whether it is read or not. This status is kept in a file which is usually called ".mh_sequences", but that name can be overruled with this flag. You may specify an OBJECT of a type which extends "Mail::Box::MH::Labels" (at least implements the "get()" method), as alternative for labels file reader as created by "Mail::Box::MH". Returns the highest number which is used in the folder to store a file. This method may be called when the folder is read (then this number can be derived without file-system access), but also when the folder is not read (yet). Create a index reader/writer object. Create a label reader/writer object. Write all messages to the folder-file. OPTION DEFINED BY DEFAULT force Mail::Box <true> head_wrap Mail::Box 72 keep_deleted Mail::Box <false> renumber Mail::Box::MH <true> save_deleted Mail::Box <false> MH specific options: Permit renumbering of message. Bij default this is true, but for some unknown reason, you may be thinking that messages should not be renumbered.

How MH-folders work
MH-type folders use a directory to store the messages of one folder. Each message is stored in a separate file. This seems useful, because changes in a folder change only a few of these small files, in contrast with file-based folders where changes in a folder cause rewrites of huge folder files. However, MH-based folders perform very bad if you need header information of all messages. For instance, if you want to have full knowledge about all message-threads (see "Mail::Box::Thread::Manager") in the folder, it requires to read all header lines in all message files. And usually, reading your messages in threads is desired. So, each message is written in a separate file. The filenames are numbers, which count from 1. Next to these message files, a directory may contain a file named ".mh_sequences", storing labels which relate to the messages. Furthermore, a folder-directory may contain sub-directories, which are seen as sub-folders.

Labels
User actions on a message are flagged with a label. When the folder is opened, these flags are read from the ".mh_sequences" file. When the folder is closed that file gets updated. "Status" and "X-Status" lines in the message headers -as used by Mbox folders- are only looked at when new messages are added to the folder. These lines are only updated when a MH message has to be written to a folder for some reason.

This implementation
This implementation supports the ".mh-sequences" file and sub-folders. Next to this, considerable effort it made to avoid reading each message-file. This should boost performance of the "Mail::Box" module over other Perl-modules which are able to read folders. Folder-types which store their messages each in one file, together in one directory, are bad for performance. Consider that you want to know the subjects of all messages, while browser through a folder with your mail-reading client. This would cause all message-files to be read. "Mail::Box::MH" has two ways to try improve performance. You can use an index-file, and use on delay-loading. The combination performs even better. Both are explained in the next sections.

An index-file
If you specify "keep_index" as option to the folder creation method "new()", then all header-lines of all messages from the folder which have been read once, will also be written into one dedicated index-file (one file per folder). The default filename is ".index" However, index-files are not supported by any other reader which supports MH (as far as I know). If you read the folders with such I client, it will not cause unrecoverable conflicts with this index-file, but at most be bad for performance. If you do not (want to) use an index-file, then delay-loading may save your day. Mail::Box-Overview For support and additional documentation, see http://perl.overmeer.net/mailbox/ Mark Overmeer (mailbox@overmeer.net). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This code is beta, version 2.018. Copyright (c) 2001-2002 Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.