[comp.unix.questions] Unix mail files

pg@cxa.daresbury.ac.uk (Paul Griffiths) (05/26/90)

Hi,
   Is there anyone out there who can tell me how individual messages
in a mailbox (ie /usr/spool/mail/$USER) are seperated from each other.

   The only distinguishable feature I can see is that each message begins
with a line specifying who the message came from, ie

	From Info-unix-requests@uk.ac.nsfnet-relay

   Note that the "From" has NO `:' following it. Am I on the right track ???

   Any help much appreciated.

P.Griffiths. Daresbury Laboratory Graphics Group

JANET:       P.Griffiths@uk.ac.daresbury
Internet:    P.Griffiths%daresbury.ac.uk
EARN/BITNET: P.Griffiths%daresbury.ac.uk@UKACRL
UUCP:        P.Griffiths%daresbury.ac.uk@ukc.uucp

brnstnd@stealth.acf.nyu.edu (05/28/90)

In article <23447@adm.BRL.MIL> pg@cxa.daresbury.ac.uk (Paul Griffiths) writes:
>    Is there anyone out there who can tell me how individual messages
> in a mailbox (ie /usr/spool/mail/$USER) are seperated from each other.
>    The only distinguishable feature I can see is that each message begins
> with a line specifying who the message came from, ie
> 	From Info-unix-requests@uk.ac.nsfnet-relay
>    Note that the "From" has NO `:' following it. Am I on the right track ???

Yep, exactly right. You'll also note that if a line in the text of a
message starts with From and a space, the mailer adds a > to the line;
that way mailreaders won't think that it starts a new message.

To be precise, the separator is "\n\nFrom ".

There are other popular conventions for mail. The easiest to work with
has every message in a separate file; unfortunately, this also wastes
the most space.

---Dan

shwake@raysnec.UUCP (Ray Shwake) (05/29/90)

In article <1163:May2719:09:5690@stealth.acf.nyu.edu> brnstnd@stealth.acf.nyu.edu (Dan Bernstein) writes:

>Yep, exactly right. You'll also note that if a line in the text of a
>message starts with From and a space, the mailer adds a > to the line;
>that way mailreaders won't think that it starts a new message.
>To be precise, the separator is "\n\nFrom ".

The > prefix on lines beginning with From is also intended to cut down on
mail forgeries. Also, while "\n\nFrom " is present BETWEEN messages, the
mailer will often simply look at each line and, if it begins with "From "
judge it to be the start of the next message. You can confirm this by
eliminating the blank line between messages and see if your mailer still
separates your messages.

>There are other popular conventions for mail. The easiest to work with
>has every message in a separate file; unfortunately, this also wastes
>the most space.

This is an arguable position. Separating messages certainly does waste
more space, but makes for a more complex directory structure by requiring
(for efficiency sake) a separate directory for each subject collection,
and makes movement between messages horribly inefficient.

volpe@underdog.crd.ge.com (Christopher R Volpe) (06/02/90)

In article <1163:May2719:09:5690@stealth.acf.nyu.edu> brnstnd@stealth.acf.nyu.edu (Dan Bernstein) writes:
>
>Yep, exactly right. You'll also note that if a line in the text of a
>message starts with From and a space, the mailer adds a > to the line;
>that way mailreaders won't think that it starts a new message.
>
>To be precise, the separator is "\n\nFrom ".

The SunOS mail program that I use doesn't seem to use that as
a separator. I sent a message to myself containing "From me@here" in
the body of the message after two carriage returns, and indeed the ">"
was automatically inserted, but I directly edited my spool file 
and removed the ">". When I invoked "mail" to read it, It didn't
confuse the line in the text with the start of a new message,
even though the ">" was no longer there. Could there be some
control characters inserted somewhere?

Chris Volpe
G.E. Corporate Research and Development
VOLPECR@CRD.GE.COM

rbottin@atl.calstate.edu (Richard John Botting) (06/03/90)

In article <1163:May2719:09:5690@stealth.acf.nyu.edu> brnstnd@stealth.acf.nyu.ed
u (Dan Bernstein) writes:
>
>Yep, exactly right. You'll also note that if a line in the text of a
>message starts with From and a space, the mailer adds a > to the line;
>that way mailreaders won't think that it starts a new message.
>
>To be precise, the separator is "\n\nFrom ".
Christopher R Volpe <volpe@underdog.crd.ge.com> adds
>The SunOS mail program that I use doesn't seem to use that as
>a separator. [...]
>Could there be some control characters inserted somewhere?

I would place small bet on 4 CTRL/A's
because this is what about 50% of our mail system does at silicon.???.csusb.edu.
The other half  doesn't put in these characters
(Please don't ask me why - I assume insanity on the part of the programmers)
(whio would doubtless prefer to reamin anonymous)

The fun starts when a third process parses mail...this appears to use the
FIRST line to determine what the seperator between the messages is.

In consequence we often find 6 or 7 or messages all masquerading as a
single one...

I wrote a script to clean my mail out, then some others tried it as well.
As of tonight it went into service from root - as a crontab...It reads:
: clean dumb sentinels from mail files
cd /usr/spool/mail
for mbox in *
do echo $mbox
ed - $mbox <<++++ 2>/dev/null
g//s///
w
q
++++
done

By the way - g//s/// is not what it appears to be you'll have to insert
4 CTRL/A's    ^here
:-)
Dr. Richard J Botting (The Aging Hacker)
Computer Science Dept
CalStateUniversity, San Bernardino.
rbottin@atl.calstate.edu
paaaaar@calstate.bitnet