Standards, Environments, and Macros mbox(5) NNNNAAAAMMMMEEEE mbox - file containing mail messages IIIINNNNTTTTRRRROOOODDDDUUUUCCCCTTTTIIIIOOOONNNN The most common format for storage of mail messages is _m_b_o_x format. An _m_b_o_x is a single file containing zero or more mail messages. MMMMEEEESSSSSSSSAAAAGGGGEEEE FFFFOOOORRRRMMMMAAAATTTT A message encoded in _m_b_o_x format begins with a FFFFrrrroooommmm____ line, continues with a series of non-FFFFrrrroooommmm____ lines, and ends with a blank line. A FFFFrrrroooommmm____ line means any line that begins with the characters F, r, o, m, space: From god@heaven.af.mil Sat Jan 3 01:05:34 1996 Return-Path: Delivered-To: djb@silverton.berkeley.edu Date: 3 Jan 1996 01:05:34 -0000 From: God To: djb@silverton.berkeley.edu (D. J. Bernstein) How's that mail system project coming along? The final line is a completely blank line (no spaces or tabs). Notice that blank lines may also appear elsewhere in the message. The FFFFrrrroooommmm____ line always looks like FFFFrrrroooommmm _e_n_v_s_e_n_d_e_r _d_a_t_e _m_o_r_e_i_n_f_o. _e_n_v_s_e_n_d_e_r is one word, without spaces or tabs; it is usually the envelope sender of the message. _d_a_t_e is the delivery date of the message. It always contains exactly 24 characters in aaaassssccccttttiiiimmmmeeee format. _m_o_r_e_i_n_f_o is optional; it may contain arbitrary information. Between the FFFFrrrroooommmm____ line and the blank line is a message in RFC 822 format, as described in qqqqmmmmaaaaiiiillll----hhhheeeeaaaaddddeeeerrrr((((5555)))), subject to >>>>FFFFrrrroooommmm qqqquuuuoooottttiiiinnnngggg as described below. HHHHOOOOWWWW AAAA MMMMEEEESSSSSSSSAAAAGGGGEEEE IIIISSSS DDDDEEEELLLLIIIIVVVVEEEERRRREEEEDDDD Here is how a program appends a message to an _m_b_o_x file. It first creates a FFFFrrrroooommmm____ line given the message's envelope sender and the current date. If the envelope sender is empty (i.e., if this is a bounce message), the program uses MMMMAAAAIIIILLLLEEEERRRR----DDDDAAAAEEEEMMMMOOOONNNN instead. If the envelope sender contains spaces, tabs, or newlines, the program replaces them with hyphens. The program then copies the message, applying >>>>FFFFrrrroooommmm qqqquuuuoooottttiiiinnnngggg to each line. >>>>FFFFrrrroooommmm qqqquuuuoooottttiiiinnnngggg ensures that the resulting lines are not FFFFrrrroooommmm____ lines: the program prepends a >>>> to any SunOS 5.11 Last change: 1 Standards, Environments, and Macros mbox(5) FFFFrrrroooommmm____ line, >>>>FFFFrrrroooommmm____ line, >>>>>>>>FFFFrrrroooommmm____ line, >>>>>>>>>>>>FFFFrrrroooommmm____ line, etc. Finally the program appends a blank line to the message. If the last line of the message was a partial line, it writes two newlines; otherwise it writes one. HHHHOOOOWWWW AAAA MMMMEEEESSSSSSSSAAAAGGGGEEEE IIIISSSS RRRREEEEAAAADDDD A reader scans through an _m_b_o_x file looking for FFFFrrrroooommmm____ lines. Any FFFFrrrroooommmm____ line marks the beginning of a message. The reader should not attempt to take advantage of the fact that every FFFFrrrroooommmm____ line (past the beginning of the file) is preceded by a blank line. Once the reader finds a message, it extracts a (possibly corrupted) envelope sender and delivery date out of the FFFFrrrroooommmm____ line. It then reads until the next FFFFrrrroooommmm____ line or end of file, whichever comes first. It strips off the final blank line and deletes the quoting of >>>>FFFFrrrroooommmm____ lines and >>>>>>>>FFFFrrrroooommmm____ lines and so on. The result is an RFC 822 message. CCCCOOOOMMMMMMMMOOOONNNN MMMMBBBBOOOOXXXX VVVVAAAARRRRIIIIAAAANNNNTTTTSSSS There are many variants of _m_b_o_x format. The variant described above is _m_b_o_x_r_d format, popularized by Rahul Dhesi in June 1995. The original _m_b_o_x_o format quotes only FFFFrrrroooommmm____ lines, not >>>>FFFFrrrroooommmm____ lines. As a result it is impossible to tell whether From: djb@silverton.berkeley.edu (D. J. Bernstein) To: god@heaven.af.mil >From now through August I'll be doing beta testing. Thanks for your interest. was quoted in the original message. An _m_b_o_x_r_d reader will always strip off the quoting. _m_b_o_x_c_l format is like _m_b_o_x_o format, but includes a Content- Length field with the number of bytes in the message. _m_b_o_x_c_l_2 format is like _m_b_o_x_c_l but has no >>>>FFFFrrrroooommmm quoting. These formats are used by SVR4 mailers. _m_b_o_x_c_l_2 cannot be read safely by _m_b_o_x_r_d readers. UUUUNNNNSSSSPPPPEEEECCCCIIIIFFFFIIIIEEEEDDDD DDDDEEEETTTTAAAAIIIILLLLSSSS There are many locking mechanisms for _m_b_o_x files. qqqqmmmmaaaaiiiillll---- llllooooccccaaaallll always uses fffflllloooocccckkkk on systems that have it, otherwise lllloooocccckkkkffff. The delivery date in a FFFFrrrroooommmm____ line does not specify a time zone. qqqqmmmmaaaaiiiillll----llllooooccccaaaallll always creates the delivery date in GMT so that _m_b_o_x files can be safely transported from one time zone to another. SunOS 5.11 Last change: 2 Standards, Environments, and Macros mbox(5) If the mtime on a nonempty _m_b_o_x file is greater than the atime, the file has new mail. If the mtime is smaller than the atime, the new mail has been read. If the atime equals the mtime, there is no way to tell whether the file has new mail, since qqqqmmmmaaaaiiiillll----llllooooccccaaaallll takes much less than a second to run. One solution is for a mail reader to artificially set the atime to the mtime plus 1. Then the file has new mail if and only if the atime is less than or equal to the mtime. Some mail readers place SSSSttttaaaattttuuuussss fields in each message to indicate which messages have been read. SSSSEEEEEEEE AAAALLLLSSSSOOOO maildir(5), qmail-header(5), qmail-local(8) SunOS 5.11 Last change: 3