Thread View: comp.mail.misc
3 messages
3 total messages
Started by Eric A. Litman
Fri, 10 Apr 1992 01:05
Delimiter of a standard mail spool file.
Author: Eric A. Litman
Date: Fri, 10 Apr 1992 01:05
Date: Fri, 10 Apr 1992 01:05
11 lines
890 bytes
890 bytes
Could somebody please tell me what the standard delimiter of a mail spool file is? I would like to write a script that tells me how many messages I have total, the number new, and the number unread (as does Mail upon startup). I have written one that does this, but it chokes on forwarded messages when I grep for Message-Id: (I gave up on From: ). Thanks in advance. -Eric P.S. If somebody has already written something to do this (preferrable in C, that would be nice, too :-)
Re: Delimiter of a standard mail spool file.
Author: Eric W. Ziegast
Date: Fri, 10 Apr 1992 05:20
Date: Fri, 10 Apr 1992 05:20
18 lines
1060 bytes
1060 bytes
> Could somebody please tell me what the standard delimiter of a mail
> spool file is?
"\n\nFrom" where "From" is the beginning of the message.
At the beginning of the spool, there are no leading returns.
Basically, if the last line you read was a blank line and your
current line starts with "From":
!strncmp(buffer ,"From ", strlen("From "))
you're at the beginning of a message. Usually, just a leading
"From " is enough since a good mailer will escape other instances
of "From " as ">From ".
--
Eric Ziegast
PS: Code above stolen from MH.
Re: Delimiter of a standard mail spool file.
Author: John Stanley
Date: Fri, 10 Apr 1992 18:14
Date: Fri, 10 Apr 1992 18:14
59 lines
1800 bytes
1800 bytes
In article <1992Apr10.010511.11691@wam.umd.edu> elitman@wam.umd.edu (Eric A. Litman) writes:
>Could somebody please tell me what the standard delimiter of a mail
>spool file is?
/^From /
>P.S. If somebody has already written something to do this (preferrable in
>C, that would be nice, too :-)
Uggg. You probably put iron rimmed wagon wheels on your car, too.
Perl follows:
#!/usr/local/bin/perl
# scan a mail file for mail
# I am tired of mail's format and speed (lack of).
$mail = "/usr/spool/mail/@ENV{'USER'}";
if( $#ARGV == 0 ) { $mail = shift; }
$count = 1;
open( MAIL, $mail ) || die "No mail for you.\n";
while( 1 ) {
while( <MAIL> ) {
if( eof ) { exit 0; }
do {
$pathfrom = $1;
$status = $from = $subject = "";
while( <MAIL> ) {
chop;
$from = $' if /^From: /;
$subject = $' if /^Subject: /;
$status = $' if /^Status: /;
last if /^$/;
}
$_ = $from;
$from = $1 if /(<\S+>)/;
$from = "<$1>" if /([\w-\.]+)\s+\(/;
$status = "N" if $status eq "";
$line = sprintf ("%2s %2d: %s From: %s (%s)",
$status, $count, $subject, $from, $pathfrom);
print substr($line, 0, 75);
print "\n";
$count++;
} if /^From (\S+)/;
}
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads