1mbox(5)                          User Manuals                          mbox(5)
2
3
4

NAME

6       mbox - Format for mail message storage.
7

DESCRIPTION

9       This  document describes the format traditionally used by Unix hosts to
10       store mail messages locally.  mbox files typically reside in  the  sys‐
11       tem's  mail  spool, under various names in users' Mail directories, and
12       under the name mbox in users' home directories.
13
14       An mbox is a text file containing an arbitrary number  of  e-mail  mes‐
15       sages.  Each message consists of a postmark, followed by an e-mail mes‐
16       sage formatted according to RFC822, RFC2822. The file format  is  line-
17       oriented. Lines are separated by line feed characters (ASCII 10).
18
19       A  postmark  line consists of the four characters "From", followed by a
20       space character, followed by the  message's  envelope  sender  address,
21       followed  by  whitespace,  and  followed  by a time stamp. This line is
22       often called From_ line.
23
24       The sender address is expected to be addr-spec as  defined  in  RFC2822
25       3.4.1.  The date is expected to be date-time as defined in RFC2822 3.3.
26       For compatibility reasons with legacy software, two-digit years greater
27       than  or  equal  to  70 should be interpreted as the years 1970+, while
28       two-digit years less  than  70  should  be  interpreted  as  the  years
29       2000-2069.  Software  reading  files in this format should also be pre‐
30       pared to accept non-numeric timezone information such as "CET DST"  for
31       Central European Time, daylight saving time.
32
33       Example:
34
35        From example@example.com Fri Jun 23 02:56:55 2000
36
37       In  order  to  avoid misinterpretation of lines in message bodies which
38       begin with the four characters "From", followed by a  space  character,
39       the  mail  delivery  agent  must quote any occurrence of "From " at the
40       start of a body line.
41
42       There are two different quoting schemes, the first (MBOXO) only  quotes
43       plain  "From  "  lines in the body by prepending a '>' to the line; the
44       second (MBOXRD) also quotes already quoted "From " lines by  prepending
45       a '>' (i.e. ">From ", ">>From ", ...). The later has the advantage that
46       lines like
47
48        >From the command line you can use the '-p' option
49
50       aren't dequoted wrongly as a MBOXRD-MDA would turn the line into
51
52        >>From the command line you can use the '-p' option
53
54       before storing it. Besides MBOXO and MBOXRD there is also MBOXCL  which
55       is MBOXO with a "Content-Length:"-field with the number of bytes in the
56       message body; some MUAs (like mutt(1)) do automatically transform MBOXO
57       mailboxes into MBOXCL ones when ever they write them back as MBOXCL can
58       be read by any MBOXO-MUA without any problems.
59
60       If the modification-time (usually determined via stat(2)) of a nonempty
61       mbox  file  is greater than the access-time the file has new mail. Many
62       MUAs place a Status: header in each message to indicate which  messages
63       have already been read.
64

LOCKING

66       Since mbox files are frequently accessed by multiple programs in paral‐
67       lel, mbox files should generally not be accessed without locking.
68
69       Three different locking mechanisms (and combinations  thereof)  are  in
70       general use:
71
72       ·      fcntl(2)  locking is mostly used on recent, POSIX-compliant sys‐
73              tems. Use of this locking method is, in particular, advisable if
74              mbox  files  are accessed through the Network File System (NFS),
75              since it seems the only way to reliably invalidate NFS  clients'
76              caches.
77
78       ·      flock(2) locking is mostly used on BSD-based systems.
79
80       ·      Dotlocking  is used on all kinds of systems. In order to lock an
81              mbox file named folder, an application first creates a temporary
82              file  with  a  unique  name in the directory in which the folder
83              resides. The application then tries to use  the  link(2)  system
84              call  to  create  a hard link named folder.lock to the temporary
85              file. The success of the link(2) system call should be addition‐
86              ally  verified  using  stat(2) calls. If the link has succeeded,
87              the mail folder is considered dotlocked. The temporary file  can
88              then safely be unlinked.
89
90              In  order  to  release the lock, an application just unlinks the
91              folder.lock file.
92
93       If multiple methods are combined, implementors should make sure to  use
94       the  non-blocking variants of the fcntl(2) and flock(2) system calls in
95       order to avoid deadlocks.
96
97       If multiple methods are combined, an mbox file must not  be  considered
98       to  have  been  successfully  locked  before  all individual locks were
99       obtained. When one of the individual locking methods fails, an applica‐
100       tion should release all locks it acquired successfully, and restart the
101       entire locking procedure from the beginning, after a suitable delay.
102
103       The locking mechanism used on a particular system is a matter of  local
104       policy,  and  should be consistently used by all applications installed
105       on the system which access mbox files. Failure to do so may  result  in
106       loss of e-mail data, and in corrupted mbox files.
107

FILES

109       /var/spool/mail/$LOGNAME
110              $LOGNAME's incoming mail folder.
111
112       $HOME/mbox
113              user's archived mail messages, in his $HOME directory.
114
115       $HOME/Mail/
116              A  directory in user's $HOME directory which is commonly used to
117              hold mbox format folders.
118

SEE ALSO

120       mutt(1), fcntl(2), flock(2),  link(2),  stat(2),  maildir(5),  mmdf(5),
121       RFC822, RFC976, RFC2822
122

AUTHOR

124       Thomas     Roessler    <roessler@does-not-exist.org>,    Urs    Janssen
125       <urs@tin.org>
126

HISTORY

128       The mbox format occurred in Version 6 AT&T Unix.
129       A variant of this format was documented in RFC976.
130
131
132
133Unix                          February 19th, 2002                      mbox(5)
Impressum