E-mail files, part I: Listing the Senders

Due Monday 1/15/01, by 5:00PM. Submit your .cpp file via HSP .

Where your e-mail lives

The e-mail that is sent to your Math/CS account (youraccount@mathcs.carleton.edu) is stored in the file /var/spool/mail/youraccount (here, "youraccount" would be "jondich" for me, "mtie" for Mike Tie, and whatever your account name is for you). When you first use an e-mail reading program, however, that program may (or may not) move your incoming messages from /var/spool/mail/youraccount to someplace else.

For example, if you use kmail to read your Math/CS e-mail, your incoming messages get moved to a file called ~/Mail/inbox.

If you want to look at your e-mail in its raw form, including all the technical details associated with each message, you first need to make a copy of your inbox. You will do this by executing a "cp" (copy) command in a terminal window. Here's how:

Once you have made a copy of your inbox in the file tempMailbox, you can take a look at how your e-mail appears in its raw form. Open tempMailbox using NEdit. Alternatively, you can type the command "more tempMailbox" in a terminal window. (The UNIX command "more" prints the contents of a file, one screen at a time. Hit the space bar to move forward a page, and hit b to move backward a page.)

If you use more or NEdit to look at tempMailbox, you will see that every message is preceded by a big mess of information about who sent the e-mail, when it arrived, which computers handled it along the way, etc. All this information is called the e-mail's "header." The header for a message always begins with a line that starts with the word "From" followed by a space character. Your e-mail program (kMail, mail, Mulberry, Outlook Express, etc.) recognizes when one message ends and the next message begins by looking for lines that begin with "From ".

The assignment

For this assignment, you will write a program that searches through the tempMailbox file and prints:

To get started, use the program countlines.cpp. To run this program, compile it ("g++ -Wall -o countlines countlines.cpp") and then type "countlines < tempMailbox" at the UNIX prompt.

We will discuss this assignment in class on 1/10/01. Have fun, start early, and keep in touch.



Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057, (507) 646-4364, jondich@carleton.edu