SUMMARY I propose a way of recording and alerting me of new mail. THE PROBLEM I read my mail typically under Linux using Pine, but sometimes over IMAP using other mail readers. I've wanted a better way of managing new mail as it arrives during the day. The "new" mail flag within Pine are for those messages whose body has not yet been read, although the sender and subject may be known. (I treat these as "to-do" messages in my inbox that I have not yet handled.) What I'm talking about is managing even "newer" mail, that is, mail that has just just arrived, where I don't yet know the sender or the subject. For example, if I step away from my desk for a few hours, I can't use the "from" command under Linux to see what has arrived since I left, because this lists all messages flagged as "new" in Pine, and there are too many of those. THE BASICS First, I create a file called .NoMail that contains this: From MAILER-DAEMON Tue Jan 14 12:15:21 2003 Date: Tue, 14 Jan 2003 12:15:21 -0500 (EST) From: Mail System Internal Data Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA X-IMAP: 1042564519 0000000001 Status: RO This text is part of the internal format of your mail folder, and is not a real message. It is created automatically by the mail system software. If deleted, important folder data will be lost, and it will be re-created with the data reset to initial values. This will keep IMAP happy. Then I create a file called .NM that is a copy of this file. The .NM file will contain headers of new mail as it arrives. To do so, I have a recipe in my .procmailrc files that says this: :0 hc: $HOME/.NM This copies mail headers onto the end of the file .NM for any mail messages that make it to there in the procmail script. (Some messages are deemed less urgent and get moved by .procmailrc to somewhere else before this recipe, so that I don't see them arriving, although I will still read them eventually.) Then I alias "nfrom" (= "new from") to this command from -f $HOME/.NM | tail +2 to list the headers of the mail that has just arrived. I also alias "pine" to /bin/cp $HOME/.NoMail $HOME/.NM; /usr/bin/pine so that every time I start "pine", the latest messages I have received are no longer considered to be new as far as "nfrom" is concerned. They will still be flagged as "new" (= to be dealt with) within Pine, of course. THE ICING To complete the picture, I have a utility that runs on a PC or Mac (under Linux or OS X), to repeatedly check for new mail, display how many messages "nfrom" will see, and play a sound when there is a new arrival. The utility consists of two scripts, a bash script called "sounder" to play the sound on the PC or Mac, and a tcl/wish script called "nbiff-local" that runs on the mail server and does all the checking. I run them using SSH to connect to the mail server, piping the output of "nbiff-local" to the "sounder" script: ssh -Y -f '~/bin/nbiff-local' | ~/bin/sounder Here is "sounder": #!/bin/bash # Repeatedly play a system sound when the next input is "mail". while [ 1 ] do read p [ "foo$p" == "foomail" ] && $1 done Here is any utility that can play a given sound file. Here is the "nbiff-local" utility: #!/usr/bin/X11/wish wm withdraw . # config set account "mymail" set interval 30000 set windowloc "-20+100" # run set msgs 0 set t [toplevel .test -bg black] wm overrideredirect $t 1 wm geometry $t $windowloc label $t.name -text $account -font "5x7" -fg white -bg black pack $t.name -padx 0 -pady 0 label $t.msg -textvariable msgs -font "12x24" -fg SpringGreen -bg black pack $t.msg -padx 3 -pady 3 # loop forever, running nfrom to get the number of new mail messages while {1} { set new [exec from -f $HOME/.NM | tail +2 | wc -l] if {$new > $msgs} {puts "mail"} set msgs $new update after $interval } This puts up a small window under X11 with the number of new messages, and outputs the string "mail" each time that number goes up (a new message has arrived). Since the output is piped to "sounder", this string is read as input, which then causes the soundfile to be played.