Initial import of mutt-ng.
[apps/madmutt.git] / doc / mbox.man
1 '\" t
2 .\" -*-nroff-*-
3 .\"
4 .\"
5 .\"     Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
6 .\" 
7 .\"     This document is in the public domain and may be distributed and
8 .\"     changed arbitrarily.
9 .\"
10 .TH mbox 5 "August 2000" Unix "User Manuals"
11 .SH NAME
12 .PP
13 mbox \- Format for mail message storage.
14 .SH DESCRIPTION
15 .PP
16 This document describes the format traditionally used by Unix hosts
17 to store mail messages locally.  
18 .B mbox
19 files typically reside in the system's mail spool, under various
20 names in users'
21 .B Mail
22 directories, and under the name
23 .B mbox
24 in users' home directories.
25 .PP
26 An 
27 .B mbox
28 is a text file containing an arbitrary number of e-mail messages.
29 Each message consists of a postmark, followed by an e-mail message
30 formatted according to RFC 822.  The file format is line-oriented.
31 Lines are separated by line feed characters (ASCII 10).
32 .PP
33 A postmark line consists of the four characters "From", followed by
34 a space character, followed by the message's envelope sender
35 address, followed by whitespace, and followed by a time stamp. The
36 sender address is expected to be an
37 .B addrspec
38 as defined in appendix D of RFC 822.
39 .PP
40 The date is expected to be formatted according to the following
41 syntax (represented in the augmented Backus-Naur formalism used by
42 RFC 822):
43 .PP
44 .TS
45 lll.
46 mbox-date        =      weekday month day time [ timezone ] year
47 weekday  =      "Mon" / "Tue" / "Wed" / "Thu" / "Fri" 
48                 / "Sat" / "Sun"
49 month    =      "Jan" / "Feb" / "Mar" / "Apr" / "May"
50                 / "Jun" / "Jul" / "Aug" / "Sep" 
51                 / "Oct" / "Nov" / "Dec"
52 day      =      1*2DIGIT
53 time     =      1*2DIGIT ":" 1*2DIGIT [ ":" 1*2DIGIT ]
54 timezone         =      ( "+" / "-" ) 4DIGIT
55 year     =      ( 4DIGIT / 2DIGIT )
56 .TE
57 .PP
58 For compatibility reasons with legacy software, two-digit years
59 greater than or equal to 70 should be interpreted as the years
60 1970+, while two-digit years less than 70 should be interpreted as
61 the years 2000-2069.
62 .PP
63 Software reading files in this format should also be prepared to
64 accept non-numeric timezone information such as "CET DST" for
65 Central European Time, dailight saving time.
66 .PP
67 Example:
68 .IP "" 1
69 From roessler@does-not-exist.org Fri Jun 23 02:56:55 2000
70 .PP
71 In order to avoid mis-interpretation of lines in message bodies
72 which begin with the four characters "From", followed by a space
73 character, the character ">" is commonly prepended in front of such
74 lines.
75 .SH
76 LOCKING
77 .PP
78 Since 
79 .B mbox
80 files are frequently accessed by multiple programs in parallel, 
81 .B mbox
82 files should generally not be accessed without locking.
83 .PP
84 Three different locking mechanisms (and combinations thereof) are in
85 general use:
86 .IP "\(bu"
87 .BR fcntl (2) 
88 locking is mostly used on recent, POSIX-compliant systems.  Use of
89 this locking method is, in particular, advisable if 
90 .B mbox
91 files are accessed through the Network File System (NFS), since it
92 seems the only way to reliably invalidate NFS clients' caches.
93 .IP "\(bu"
94 .BR flock (2)
95 locking is mostly used on BSD-based systems.
96 .IP "\(bu"
97 Dotlocking is used on all kinds of systems.  In order to lock an
98 .B mbox
99 file named
100 .IR folder ,
101 an application first creates a temporary file with a unique
102 name in the directory in which the 
103 .I folder
104 resides.  The application then tries to use the
105 .BR link (2)
106 system call to create a hard link named
107 .IB folder .lock
108 to the temporary file.  The success of the
109 .BR link (2)
110 system call should be additionally verified using
111 .BR stat (2)
112 calls.  If the link has succeeded, the mail folder is considered
113 dotlocked.  The temporary file can then safely be unlinked.
114 .IP ""
115 In order to release the lock, an application just unlinks the
116 .IB folder .lock
117 file.
118 .PP
119 If multiple methods are combined, implementors should make sure to
120 use the non-blocking variants of the
121 .BR fcntl (2)
122 and 
123 .BR flock (2)
124 sytem calls in order to avoid deadlocks.
125 .PP
126 If multiple methods are combined, an
127 .B mbox
128 file must not be considered to have been successfully locked before
129 all individual locks were obtained.  When one of the individual
130 locking methods fails, an application should release all locks it
131 acquired successfully, and restart the entire locking procedure from
132 the beginning, after a suitable delay.
133 .PP
134 The locking mechanism used on a particular system is a matter of
135 local policy, and should be consistently used by all applications
136 installed on the system which access 
137 .B mbox
138 files. Failure to do so may result in loss of e-mail data, and in
139 corrupted
140 .B mbox
141 files.
142 .SH
143 FILES
144 .IP "/var/spool/mail/\fIuser\fP"
145 .IR user 's
146 incoming mail folder.
147 .IP "~\fIuser\fP/mbox"
148 .IR user 's
149 archived mail messages, in his home directory.
150 .IP "~\fIuser\fP/Mail/"
151 A directory in
152 .IR user 's
153 home directory which is commonly used to hold 
154 .B mbox
155 format folders.
156 .SH
157 SEE ALSO
158 .PP
159 .BR elm (1),
160 .BR fcntl (2), 
161 .BR flock (2), 
162 .BR link (2),
163 .BR local (8), 
164 .BR mail (1), 
165 .BR maildir (5), 
166 .BR mail.local (8), 
167 .BR mutt (1),
168 .BR mutt_dotlock (1), 
169 .BR pine (1),
170 .BR procmail (1),
171 .BR sendmail (8)
172 .PP
173 D. Crocker, Standard for the format of ARPA Internet text messages,
174 RFC 822
175 .PP
176 M. R. Horton, UUCP mail interchange format standard, RFC 976
177 .SH
178 AUTHOR
179 .PP
180 The present document was written by Thomas Roessler
181 <roessler@does-not-exist.org>. 
182 .SH
183 HISTORY
184 .PP
185 The
186 .B mbox
187 format occured in Version 6 AT&T Unix.
188 .PP
189 A variant of this format was documented in RFC 976.