4 .\" Copyright (C) 2000 Thomas Roessler <roessler@does-not-exist.org>
6 .\" This document is in the public domain and may be distributed and
7 .\" changed arbitrarily.
9 .TH mbox 5 "February 19th, 2002" Unix "User Manuals"
12 mbox \- Format for mail message storage.
15 This document describes the format traditionally used by Unix hosts
16 to store mail messages locally.
18 files typically reside in the system's mail spool, under various
19 names in users' Mail directories, and under the name
21 in users' home directories.
25 is a text file containing an arbitrary number of e-mail messages.
26 Each message consists of a postmark, followed by an e-mail message
27 formatted according to \fBRFC822\fP, \fBRFC2822\fP. The file format
28 is line-oriented. Lines are separated by line feed characters (ASCII 10).
30 A postmark line consists of the four characters "From", followed by
31 a space character, followed by the message's envelope sender
32 address, followed by whitespace, and followed by a time stamp. This
33 line is often called From_ line.
35 The sender address is expected to be
37 as defined in \fBRFC2822\fP 3.4.1. The date is expected to be
39 as defined in \fBRFC2822\fP 3.3.
40 For compatibility reasons with legacy software, two-digit years
41 greater than or equal to 70 should be interpreted as the years
42 1970+, while two-digit years less than 70 should be interpreted as
43 the years 2000-2069. Software reading files in this format should
44 also be prepared to accept non-numeric timezone information such as
45 "CET DST" for Central European Time, daylight saving time.
49 >From example@example.com Fri Jun 23 02:56:55 2000
51 In order to avoid misinterpretation of lines in message bodies
52 which begin with the four characters "From", followed by a space
53 character, the mail delivery agent must quote any occurrence
54 of "From " at the start of a body line.
56 There are two different quoting schemes, the first (\fBMBOXO\fP) only
57 quotes plain "From " lines in the body by prepending a '>' to the
58 line; the second (\fBMBOXRD\fP) also quotes already quoted "From "
59 lines by prepending a '>' (i.e. ">From ", ">>From ", ...). The later
60 has the advantage that lines like
62 >From the command line you can use the '-p' option
64 aren't dequoted wrongly as a \fBMBOXRD\fP-MDA would turn the line
67 >>From the command line you can use the '-p' option
69 before storing it. Besides \fBMBOXO\fP and \fBMBOXRD\fP there is also
70 \fBMBOXCL\fP which is \fBMBOXO\fP with a "Content-Length:"-field with the
71 number of bytes in the message body; some MUAs (like
73 do automatically transform \fBMBOXO\fP mailboxes into \fBMBOXCL\fP ones when
74 ever they write them back as \fBMBOXCL\fP can be read by any \fBMBOXO\fP-MUA
77 If the modification-time (usually determined via
81 file is greater than the access-time the file has new mail. Many MUAs
82 place a Status: header in each message to indicate which messages have
88 files are frequently accessed by multiple programs in parallel,
90 files should generally not be accessed without locking.
92 Three different locking mechanisms (and combinations thereof) are in
96 locking is mostly used on recent, POSIX-compliant systems. Use of
97 this locking method is, in particular, advisable if
99 files are accessed through the Network File System (NFS), since it
100 seems the only way to reliably invalidate NFS clients' caches.
103 locking is mostly used on BSD-based systems.
105 Dotlocking is used on all kinds of systems. In order to lock an
107 file named \fIfolder\fR, an application first creates a temporary file
108 with a unique name in the directory in which the
109 \fIfolder\fR resides. The application then tries to use the
111 system call to create a hard link named \fIfolder.lock\fR
112 to the temporary file. The success of the
114 system call should be additionally verified using
116 calls. If the link has succeeded, the mail folder is considered
117 dotlocked. The temporary file can then safely be unlinked.
119 In order to release the lock, an application just unlinks the
120 \fIfolder.lock\fR file.
122 If multiple methods are combined, implementors should make sure to
123 use the non-blocking variants of the
127 system calls in order to avoid deadlocks.
129 If multiple methods are combined, an
131 file must not be considered to have been successfully locked before
132 all individual locks were obtained. When one of the individual
133 locking methods fails, an application should release all locks it
134 acquired successfully, and restart the entire locking procedure from
135 the beginning, after a suitable delay.
137 The locking mechanism used on a particular system is a matter of
138 local policy, and should be consistently used by all applications
139 installed on the system which access
141 files. Failure to do so may result in loss of e-mail data, and in
147 .IR /var/spool/mail/$LOGNAME
149 \fB$LOGNAME\fP's incoming mail folder.
154 user's archived mail messages, in his \fB$HOME\fP directory.
159 A directory in user's \fB$HOME\fP directory which is commonly used to hold
178 Thomas Roessler <roessler@does-not-exist.org>, Urs Janssen <urs@tin.org>
183 format occurred in Version 6 AT&T Unix.
185 A variant of this format was documented in \fBRFC976\fP.