blob: 20771a07d8e23ab369527b6706f7c55b781d37f1 [file] [log] [blame]
Guido van Rossumec758ea1991-06-04 20:36:54 +00001#! /usr/local/python
2
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.
6
7import posix
8
9# Open mailbox file. Exits with exception when this fails.
10
11mail = open(posix.environ['MAIL'], 'r')
12
13while 1:
14 line = mail.readline()
15 if not line: break # EOF
16 if line[:5] = 'From ':
17 # Start of message found
18 print line[:-1],
19 while 1:
20 line = mail.readline()
21 if not line: break # EOF
22 if line = '\n': break # Blank line ends headers
23 if line[:8] = 'Subject:':
24 print `line[9:-1]`,
25 print