1mbox(5) User Manuals mbox(5)
2
3
4
6 mbox - Format for mail message storage.
7
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 of‐
22 ten 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 output by asctime(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 neomutt(1)) do automatically transform
57 MBOXO mailboxes into MBOXCL ones when ever they write them back as
58 MBOXCL can 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
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 If multiple methods are combined, implementors should make sure to use
81 the non-blocking variants of the fcntl(2) and flock(2) system calls in
82 order to avoid deadlocks.
83
84 If multiple methods are combined, an mbox file must not be considered
85 to have been successfully locked before all individual locks were ob‐
86 tained. When one of the individual locking methods fails, an applica‐
87 tion should release all locks it acquired successfully, and restart the
88 entire locking procedure from the beginning, after a suitable delay.
89
90 The locking mechanism used on a particular system is a matter of local
91 policy, and should be consistently used by all applications installed
92 on the system which access mbox files. Failure to do so may result in
93 loss of e-mail data, and in corrupted mbox files.
94
96 /var/spool/mail/$LOGNAME
97 $LOGNAME's incoming mail folder.
98
99 $HOME/mbox
100 user's archived mail messages, in his $HOME directory.
101
102 $HOME/Mail/
103 A directory in user's $HOME directory which is commonly used to
104 hold mbox format folders.
105
107 neomutt(1), fcntl(2), flock(2), link(2), stat(2), asctime(3),
108 maildir(5), mmdf(5), RFC822, RFC976, RFC2822
109
111 Thomas Roessler <roessler@does-not-exist.org>, Urs Janssen
112 <urs@tin.org>
113
115 The mbox format occurred in Version 6 AT&T Unix.
116 A variant of this format was documented in RFC976.
117
118
119
120Unix February 19th, 2002 mbox(5)