3 # Print From and Subject of messages in $MAIL.
4 # Extension to multiple mailboxes and other bells & whistles are left
5 # as exercises for the reader.
9 # Open mailbox file. Exits with exception when this fails.
12 mailbox
= os
.environ
['MAIL']
13 except (AttributeError, KeyError):
14 sys
.stderr
.write('No environment variable $MAIL\n')
18 mail
= open(mailbox
, 'r')
20 sys
.stderr
.write('Cannot open mailbox file: ' + mailbox
+ '\n')
24 line
= mail
.readline()
25 if not line
: break # EOF
26 if line
[:5] == 'From ':
27 # Start of message found
30 line
= mail
.readline()
31 if not line
: break # EOF
32 if line
== '\n': break # Blank line ends headers
33 if line
[:8] == 'Subject:':