1Mail::Box::File(3)    User Contributed Perl Documentation   Mail::Box::File(3)
2
3
4

NAME

6       Mail::Box::File - handle file-based folders
7

INHERITANCE

9        Mail::Box::File
10          is a Mail::Box
11          is a Mail::Reporter
12
13        Mail::Box::File is extended by
14          Mail::Box::Dbx
15          Mail::Box::Mbox
16

SYNOPSIS

DESCRIPTION

19       "Mail::Box::File" is the base-class for all file-based folders: folders
20       which bundle multiple messages into one single file.  Usually, these
21       messages are separated by a special line which indicates the start of
22       the next one.
23

OVERLOADED

25       overload: ""
26
27           See "OVERLOADED" in Mail::Box
28
29       overload: @{}
30
31           See "OVERLOADED" in Mail::Box
32
33       overload: cmp
34
35           See "OVERLOADED" in Mail::Box
36

METHODS

38       Constructors
39
40       Mail::Box::File->new(OPTIONS)
41
42        Option           --Defined in     --Default
43        access             Mail::Box        'r'
44        body_delayed_type  Mail::Box        Mail::Message::Body::Delayed
45        body_type                           <see description>
46        coerce_options     Mail::Box        []
47        create             Mail::Box        <false>
48        extract            Mail::Box        10240
49        field_type         Mail::Box        undef
50        fix_headers        Mail::Box        <false>
51        folder             Mail::Box        $ENV{MAIL}
52        folderdir          Mail::Box        $ENV{HOME}.'/Mail'
53        head_delayed_type  Mail::Box        Mail::Message::Head::Delayed
54        head_type          Mail::Box        Mail::Message::Head::Complete
55        keep_dups          Mail::Box        <false>
56        lock_extension                      '.lock'
57        lock_file          Mail::Box        <foldername><lock-extension>
58        lock_timeout       Mail::Box        1 hour
59        lock_type          Mail::Box        Mail::Box::Locker::DotLock
60        lock_wait          Mail::Box        10 seconds
61        locker             Mail::Box        undef
62        log                Mail::Reporter   'WARNINGS'
63        manager            Mail::Box        undef
64        message_type       Mail::Box        Mail::Box::File::Message
65        multipart_type     Mail::Box        Mail::Message::Body::Multipart
66        remove_when_empty  Mail::Box        <true>
67        save_on_exit       Mail::Box        <true>
68        trace              Mail::Reporter   'WARNINGS'
69        trusted            Mail::Box        <depends on folder location>
70        write_policy                        undef
71
72           . access MODE
73
74           . body_delayed_type CLASS
75
76           . body_type CLASS⎪CODE
77
78               The default "body_type" option for "File" folders, which will
79               cause messages larger than 10kB to be stored in files and
80               smaller files in memory, is implemented like this:
81
82                sub determine_body_type($$)
83                {   my $head = shift;
84                    my $size = shift ⎪⎪ 0;
85                    'Mail::Message::Body::'
86                       . ($size > 10000 ? 'File' : 'Lines');
87                }
88
89           . coerce_options ARRAY
90
91           . create BOOLEAN
92
93           . extract INTEGER ⎪ CODE ⎪ METHOD ⎪ 'LAZY'⎪'ALWAYS'
94
95           . field_type CLASS
96
97           . fix_headers BOOLEAN
98
99           . folder FOLDERNAME
100
101           . folderdir DIRECTORY
102
103           . head_delayed_type CLASS
104
105           . head_type CLASS
106
107           . keep_dups BOOLEAN
108
109           . lock_extension FILENAME⎪STRING
110
111               When the dotlock locking mechanism is used, the lock is created
112               with a hardlink to the folder file.  For "Mail::Box::File" type
113               of folders, this file is by default named as the folder-file
114               itself followed by ".lock".  For example: the "Mail/inbox"
115               folder file will have a hardlink made as "Mail/inbox.lock".
116
117               You may specify an absolute filename, a relative (to the
118               folder's directory) filename, or an extension (preceded by a
119               dot).  So valid examples are:
120
121                .lock        # appended to the folder's filename
122                my_own_lockfile.test   # full filename, same dir
123                /etc/passwd            # somewhere else
124
125               When the program runs with less priviledges (as normal user),
126               often the default inbox folder can not be locked with the lock‐
127               file name which is produced by default.
128
129           . lock_file FILENAME
130
131           . lock_timeout SECONDS
132
133           . lock_type CLASS⎪STRING⎪ARRAY
134
135           . lock_wait SECONDS
136
137           . locker OBJECT
138
139           . log LEVEL
140
141           . manager MANAGER
142
143           . message_type CLASS
144
145           . multipart_type CLASS
146
147           . remove_when_empty BOOLEAN
148
149           . save_on_exit BOOLEAN
150
151           . trace LEVEL
152
153           . trusted BOOLEAN
154
155           . write_policy 'REPLACE'⎪'INPLACE'⎪undef
156
157               Sets the default write policy, as default for a later call to
158               write(policy).  With "undef", the best policy is autodetected.
159
160       The folder
161
162       $obj->addMessage(MESSAGE, OPTIONS)
163
164           See "The folder" in Mail::Box
165
166       $obj->addMessages(MESSAGE [, MESSAGE, ...])
167
168           See "The folder" in Mail::Box
169
170       Mail::Box::File->appendMessages(OPTIONS)
171
172           Appending messages to a file based folder which is not opened is a
173           little risky.  In practice, this is often done without locking the
174           folder.  So, an other application may write to the folder at the
175           same time... :(  Hopefully, all goes fast enough that the chance on
176           collition is small.
177
178           All OPTIONS of Mail::Box::Mbox::new() can be supplied.
179
180            Option   --Defined in     --Default
181            folder     Mail::Box        <required>
182            lock_type                   NONE
183            message    Mail::Box        undef
184            messages   Mail::Box        undef
185            share      Mail::Box        <false>
186
187           . folder FOLDERNAME
188
189           . lock_type ...
190
191               See Mail::Box::new(lock_type) for possible values.
192
193           . message MESSAGE
194
195           . messages ARRAY-OF-MESSAGES
196
197           . share BOOLEAN
198
199       $obj->close(OPTIONS)
200
201           See "The folder" in Mail::Box
202
203       $obj->copyTo(FOLDER, OPTIONS)
204
205           See "The folder" in Mail::Box
206
207       $obj->delete(OPTIONS)
208
209           See "The folder" in Mail::Box
210
211       $obj->filename
212
213           Returns the filename for this folder, which may be an absolute or
214           relative path to the file.
215
216           Example:
217
218            print $folder->filename;
219
220       $obj->folderdir([DIRECTORY])
221
222           See "The folder" in Mail::Box
223
224       $obj->name
225
226           See "The folder" in Mail::Box
227
228       $obj->organization
229
230           See "The folder" in Mail::Box
231
232       $obj->size
233
234           See "The folder" in Mail::Box
235
236       $obj->type
237
238           See "The folder" in Mail::Box
239
240       $obj->update(OPTIONS)
241
242           See "The folder" in Mail::Box
243
244       $obj->url
245
246           See "The folder" in Mail::Box
247
248       Folder flags
249
250       $obj->access
251
252           See "Folder flags" in Mail::Box
253
254       $obj->isModified
255
256           See "Folder flags" in Mail::Box
257
258       $obj->modified([BOOLEAN])
259
260           See "Folder flags" in Mail::Box
261
262       $obj->writable
263
264           See "Folder flags" in Mail::Box
265
266       The messages
267
268       $obj->current([NUMBER⎪MESSAGE⎪MESSAGE-ID])
269
270           See "The messages" in Mail::Box
271
272       $obj->find(MESSAGE-ID)
273
274           See "The messages" in Mail::Box
275
276       $obj->findFirstLabeled(LABEL, [BOOLEAN, [ARRAY-OF-MSGS]])
277
278           See "The messages" in Mail::Box
279
280       $obj->message(INDEX [,MESSAGE])
281
282           See "The messages" in Mail::Box
283
284       $obj->messageId(MESSAGE-ID [,MESSAGE])
285
286           See "The messages" in Mail::Box
287
288       $obj->messageIds
289
290           See "The messages" in Mail::Box
291
292       $obj->messages(['ALL',RANGE,'ACTIVE','DELETED',LABEL,!LABEL,FILTER])
293
294           See "The messages" in Mail::Box
295
296       $obj->nrMessages(OPTIONS)
297
298           See "The messages" in Mail::Box
299
300       $obj->scanForMessages(MESSAGE, MESSAGE-IDS, TIMESPAN, WINDOW)
301
302           See "The messages" in Mail::Box
303
304       Sub-folders
305
306       $obj->listSubFolders(OPTIONS)
307
308       Mail::Box::File->listSubFolders(OPTIONS)
309
310           See "Sub-folders" in Mail::Box
311
312       $obj->nameOfSubFolder(SUBNAME, [PARENTNAME])
313
314       Mail::Box::File->nameOfSubFolder(SUBNAME, [PARENTNAME])
315
316           See "Sub-folders" in Mail::Box
317
318       $obj->openRelatedFolder(OPTIONS)
319
320           See "Sub-folders" in Mail::Box
321
322       $obj->openSubFolder(SUBNAME, OPTIONS)
323
324           See "Sub-folders" in Mail::Box
325
326       $obj->topFolderWithMessages
327
328       Mail::Box::File->topFolderWithMessages
329
330           See "Sub-folders" in Mail::Box
331
332       Internals
333
334       $obj->coerce(MESSAGE, OPTIONS)
335
336           See "Internals" in Mail::Box
337
338       $obj->create(FOLDERNAME, OPTIONS)
339
340       Mail::Box::File->create(FOLDERNAME, OPTIONS)
341
342        Option   --Defined in--Default
343        folderdir  Mail::Box   undef
344
345           . folderdir DIRECTORY
346
347       $obj->determineBodyType(MESSAGE, HEAD)
348
349           See "Internals" in Mail::Box
350
351       $obj->folderToFilename(FOLDERNAME, FOLDERDIR, [SUBEXT])
352
353       Mail::Box::File->folderToFilename(FOLDERNAME, FOLDERDIR, [SUBEXT])
354
355           Translate a folder name into a filename, using the FOLDERDIR value
356           to replace a leading "=".  SUBEXT is only used for MBOX folders.
357
358       Mail::Box::File->foundIn([FOLDERNAME], OPTIONS)
359
360           See "Internals" in Mail::Box
361
362       $obj->lineSeparator([STRING⎪'CR'⎪'LF'⎪'CRLF'])
363
364           See "Internals" in Mail::Box
365
366       $obj->locker
367
368           See "Internals" in Mail::Box
369
370       $obj->messageCreateOptions([TYPE, CONFIG])
371
372           Returns a key-value list of options to be used each time a new mes‐
373           sage is read from a file.  The list is preceeded by the TYPE of
374           message which has to be created.
375
376           This data is used by readMessages() and updateMessages().  With
377           TYPE and CONFIG, a new configuration is set.
378
379       $obj->moveAwaySubFolder(DIRECTORY, EXTENSION)
380
381           The DIRECTORY is renamed by appending the EXTENSION, which defaults
382           to ".d", to make place for a folder file on that specific location.
383           "false" is returned if this failed.
384
385       $obj->parser
386
387           Create a parser for this mailbox.  The parser stays alive as long
388           as the folder is open.
389
390       $obj->read(OPTIONS)
391
392           See "Internals" in Mail::Box
393
394       $obj->readMessages(OPTIONS)
395
396           See "Internals" in Mail::Box
397
398       $obj->storeMessage(MESSAGE)
399
400           See "Internals" in Mail::Box
401
402       $obj->toBeThreaded(MESSAGES)
403
404           See "Internals" in Mail::Box
405
406       $obj->toBeUnthreaded(MESSAGES)
407
408           See "Internals" in Mail::Box
409
410       $obj->updateMessages(OPTIONS)
411
412           For file based folders, the file handle stays open until the folder
413           is closed.  Update is therefore rather simple: move to the end of
414           the last known message, and continue reading...
415
416       $obj->write(OPTIONS)
417
418        Option      --Defined in     --Default
419        force         Mail::Box        <false>
420        policy                         undef
421        save_deleted  Mail::Box        <false>
422
423           . force BOOLEAN
424
425           . policy 'REPLACE'⎪'INPLACE'⎪undef
426
427               In what way will the mail folder be updated.  If not specified
428               during the write, the value of the new(write_policy) at folder
429               creation is taken.
430
431               Valid values:
432
433               * "REPLACE"
434                   First a new folder is written in the same directory as the
435                   folder which has to be updated, and then a call to move
436                   will throw away the old immediately replacing it by the
437                   new.
438
439                   Writing in "REPLACE" module is slightly optimized: messages
440                   which are not modified are copied from file to file, byte
441                   by byte.  This is much faster than printing the data which
442                   is will be done for modified messages.
443
444               * "INPLACE"
445                   The original folder file will be opened read/write.  All
446                   message which where not changed will be left untouched,
447                   until the first deleted or modified message is detected.
448                   All further messages are printed again.
449
450               * "undef"
451                   As default, or when "undef" is explicitly specified, first
452                   "REPLACE" mode is tried.  Only when that fails, an
453                   "INPLACE" update is performed.
454
455               "INPLACE" will be much faster than "REPLACE" when applied on
456               large folders, however requires the "truncate" function to be
457               implemented on your operating system (at least available for
458               recent versions of Linux, Solaris, Tru64, HPUX).  It is also
459               dangerous: when the program is interrupted during the update
460               process, the folder is corrupted.  Data may be lost.
461
462               However, in some cases it is not possible to write the folder
463               with "REPLACE".  For instance, the usual incoming mail folder
464               on UNIX is stored in a directory where a user can not write.
465               Of course, the "root" and "mail" users can, but if you want to
466               use this Perl module with permission of a normal user, you can
467               only get it to work in "INPLACE" mode.  Be warned that in this
468               case folder locking via a lockfile is not possible as well.
469
470           . save_deleted BOOLEAN
471
472       $obj->writeMessages(OPTIONS)
473
474           See "Internals" in Mail::Box
475
476       File based folders
477
478       File based folders maintain a folder (a set of messages) in one single
479       file.  The advantage is that your folder has only one single name,
480       which speeds-up access to all messages at once.
481
482       The disadvantage over directory based folder (see Mail::Box::Dir) is
483       that you have to construct some means to keep all message apart, for
484       instance by adding a message separator, and this will cause problems.
485       Where access to all messages at once is faster in file based folders,
486       access to a single message is (much) slower, because the whole folder
487       must be read.
488
489       File based folders
490
491       File based folders maintain a folder (a set of messages) in one single
492       file.  The advantage is that your folder has only one single name,
493       which speeds-up access to all messages at once.
494
495       The disadvantage over directory based folder (see Mail::Box::Dir) is
496       that you have to construct some means to keep all message apart, for
497       instance by adding a message separator, and this will cause problems.
498       Where access to all messages at once is faster in file based folders,
499       access to a single message is (much) slower, because the whole folder
500       must be read.
501
502       Other methods
503
504       $obj->timespan2seconds(TIME)
505
506       Mail::Box::File->timespan2seconds(TIME)
507
508           See "Other methods" in Mail::Box
509
510       Error handling
511
512       $obj->AUTOLOAD
513
514           See "Error handling" in Mail::Reporter
515
516       $obj->addReport(OBJECT)
517
518           See "Error handling" in Mail::Reporter
519
520       $obj->defaultTrace([LEVEL]⎪[LOGLEVEL, TRACELEVEL]⎪[LEVEL, CALLBACK])
521
522       Mail::Box::File->defaultTrace([LEVEL]⎪[LOGLEVEL, TRACELEVEL]⎪[LEVEL,
523       CALLBACK])
524
525           See "Error handling" in Mail::Reporter
526
527       $obj->errors
528
529           See "Error handling" in Mail::Reporter
530
531       $obj->log([LEVEL [,STRINGS]])
532
533       Mail::Box::File->log([LEVEL [,STRINGS]])
534
535           See "Error handling" in Mail::Reporter
536
537       $obj->logPriority(LEVEL)
538
539       Mail::Box::File->logPriority(LEVEL)
540
541           See "Error handling" in Mail::Reporter
542
543       $obj->logSettings
544
545           See "Error handling" in Mail::Reporter
546
547       $obj->notImplemented
548
549           See "Error handling" in Mail::Reporter
550
551       $obj->report([LEVEL])
552
553           See "Error handling" in Mail::Reporter
554
555       $obj->reportAll([LEVEL])
556
557           See "Error handling" in Mail::Reporter
558
559       $obj->trace([LEVEL])
560
561           See "Error handling" in Mail::Reporter
562
563       $obj->warnings
564
565           See "Error handling" in Mail::Reporter
566
567       Cleanup
568
569       $obj->DESTROY
570
571           See "Cleanup" in Mail::Box
572
573       $obj->inGlobalDestruction
574
575           See "Cleanup" in Mail::Reporter
576

DETAILS

DIAGNOSTICS

579       Error: Cannot append messages to folder file $filename: $!
580
581       Appending messages to a not-opened file-organized folder may fail when
582       the operating system does not allow write access to the file at hand.
583
584       Error: Cannot create directory $dir for folder $name.
585
586       While creating a file-organized folder, at most one level of directo‐
587       ries is created above it.  Apparently, more levels of directories are
588       needed, or the operating system does not allow you to create the direc‐
589       tory.
590
591       Error: Cannot create folder file $name: $!
592
593       The file-organized folder file cannot be created for the indicated rea‐
594       son.  In common cases, the operating system does not grant you write
595       access to the directory where the folder file should be stored.
596
597       Error: Cannot get a lock on $type folder $self.
598
599       A lock is required to get access to the folder.  If no locking is
600       needed, specify the NONE lock type.
601
602       Error: Cannot move away sub-folder $dir
603
604       Warning: Cannot remove folder $name file $filename: $!
605
606       Writing an empty folder will usually cause that folder to be removed,
607       which fails for the indicated reason.  new(remove_when_empty)
608
609       Warning: Cannot remove folder $name file $filename: $!
610
611       Writing an empty folder will usually cause that folder to be removed,
612       which fails for the indicated reason.  new(remove_when_empty) controls
613       whether the empty folder will removed; setting it to false (0) may be
614       needed to avoid this message.
615
616       Error: Cannot replace $filename by $tempname, to update folder $name:
617       $!
618
619       The replace policy wrote a new folder file to update the existing, but
620       was unable to give the final touch: replacing the old version of the
621       folder file for the indicated reason.
622
623       Warning: Changes not written to read-only folder $self.
624
625       You have opened the folder read-only --which is the default set by
626       new(access)--, made modifications, and now want to close it.  Set
627       close(force) if you want to overrule the access mode, or close the
628       folder with close(write) set to "NEVER".
629
630       Error: Copying failed for one message.
631
632       For some reason, for instance disc full, removed by external process,
633       or read-protection, it is impossible to copy one of the messages.
634       Copying will proceed for the other messages.
635
636       Error: Destination folder $name is not writable.
637
638       The folder where the messages are copied to is not opened with write
639       access (see new(access)).  This has no relation with write permission
640       to the folder which is controled by your operating system.
641
642       Warning: Different messages with id $msgid
643
644       The message id is discovered more than once within the same folder, but
645       the content of the message seems to be different.  This should not be
646       possible: each message must be unique.
647
648       Error: File too short to get write message $nr ($size, $need)
649
650       Mail::Box is lazy: it tries to leave messages in the folders until they
651       are used, which saves time and memory usage.  When this message
652       appears, something is terribly wrong: some lazy message are needed for
653       updating the folder, but they cannot be retreived from the original
654       file anymore.  In this case, messages can be lost.
655
656       This message does appear regularly on Windows systems when using the
657       'replace' write policy.  Please help to find the cause, probably some‐
658       thing to do with Windows incorrectly handling multiple filehandles open
659       in the same file.
660
661       Warning: Folder $name file $filename is write-protected.
662
663       The folder is opened writable or for appending via new(access), but the
664       operating system does not permit writing to the file.  The folder will
665       be opened read-only.
666
667       Error: Folder $name not deleted: not writable.
668
669       The folder must be opened with write access via new(access), otherwise
670       removing it will be refused.  So, you may have write-access according
671       to the operating system, but that will not automatically mean that this
672       "delete" method permits you to.  The reverse remark is valid as well.
673
674       Error: Invalid timespan '$timespan' specified.
675
676       The string does not follow the strict rules of the time span syntax
677       which is permitted as parameter.
678
679       Warning: Message-id '$msgid' does not contain a domain.
680
681       According to the RFCs, message-ids need to contain a unique random
682       part, then an "@", and then a domain name.  This is made to avoid the
683       creation of two messages with the same id.  The warning emerges when
684       the "@" is missing from the string.
685
686       Error: Package $package does not implement $method.
687
688       Fatal error: the specific package (or one of its superclasses) does not
689       implement this method where it should. This message means that some
690       other related classes do implement this method however the class at
691       hand does not.  Probably you should investigate this and probably
692       inform the author of the package.
693
694       Error: Unable to create subfolder $name of $folder.
695
696       The copy includes the subfolders, but for some reason it was not possi‐
697       ble to copy one of these.  Copying will proceed for all other sub-fold‐
698       ers.
699
700       Error: Unable to update folder $self.
701
702       When a folder is to be written, both replace and inplace write policies
703       are tried,  If both fail, the whole update fails.  You may see other,
704       related, error messages to indicate the real problem.
705

SEE ALSO

707       This module is part of Mail-Box distribution version 2.070, built on
708       March 25, 2007. Website: http://perl.overmeer.net/mailbox/
709

LICENSE

711       Copyrights 2001-2007 by Mark Overmeer.For other contributors see
712       ChangeLog.
713
714       This program is free software; you can redistribute it and/or modify it
715       under the same terms as Perl itself.  See
716       http://www.perl.com/perl/misc/Artistic.html
717
718
719
720perl v5.8.8                       2007-03-25                Mail::Box::File(3)
Impressum