Sven Guckes ©1995-2003

Latest change: Mon Nov 10 10:10:10 CET 2003

New Mail Notification FAQ

"How do I know whether I have new email?"

Everyone who receives mail may want to know immediately whether new mail has arrived. So the questions about "mail notification" arises. The following text will give pointers to various programs.

And those who sent a mail usually want to know whether it has arrived or even read at the destination. This usually is not possible, unless there exists a program at the receiver's end that will send back information. Further below you will find some facts on feasibility.

Summary: You can use commands which look at the mail file's time or look into the file, use special startup flags of mailers, or simply have your shell check the file's last access time. I suggest to let your mailer check for new mail and only keep your mailer running if you really need to be notified all the times.


Manual checks

"ls"
Look at your mailbox with a simple "ls" command from your shell: "ls -la $MAIL" - If the size of the file "$MAIL" is zero then there is no mail for you.

"tail -f logfile"
Check the logfile of your mail filter.

"elm -z"
The option "z" means "start ELM only if the size of the mailbox is NOT zero". This is very handy if you don't want ELM to start if there is nothing in your mailbox. However, you have to take this literally; this starts ELM whenever there is something in the mailbox - even if all mails are only old or read.

"mutt -z" and "mutt -Z"
The option "z" means "start mutt only if the size of the mailbox is NOT zero". This starts mutt when there is at least one mail - whether new or old. That's why mutt has another option, 'Z', which starts mutt only if there is at least one *new* mail in the mailbox.

"nfrm"
This ELM utility tells you about the *new* mails in your mailbox. NOTE: New mail in your mailbox will still be new to "nfrm" as it does not know whether a running ELM has been used to read/reply/store a mail.


Automatic Checks

Mail User Agents aka "mailers"

elm
You could have ELM running all the time and let it check the mailbox at a periodic interval of -> "$timeout" seconds. The default is 600 seconds which means that ELM will check every ten minutes. If this too long for you then you can set it to, say, 120 seconds (two minutes). I do not recommend any less value as it could get annoying being notified every two minutes; it really slows you down at whatever you do. ELM does not give a "bell" when it updated the mailbox folder but it only redraws the screen. Some programs can monitor activity in windows (such as -> "screen") and therefore can tell you that *somethng* is happening in a window, but that's it. I wish ELM would only update the mailbox folder if there really is new mail. Oh, well, guess I have to wait for ELM4.0.

mutt
Define the inboxes with the "mailboxes" command:
        mailboxes ! +MUTT +VIM /tmp/foo
The '+' is the abbreviation for the path that holds the mail folders (as given by eg 'set folder_dir=~/Mail'). Now mutt will check these folders for changes whenever you use the command "change-folder" (default: 'c'). After that you can cycle through the list of all "changed folders" with the command "buffy-cycle" (default: 'space').
Note: Install mutt with "+BUFFY_SIZE" for proper use.

nfrm
You can put "nfrm" into the setup file of your login shell to tell you about new mails. However, I do not recommend this. Here's why:
This check is not very clever (it does not skip over attachments) and requires to read the *full* mailbox line by line. This can take quite a while for big mailboxes.
This check will then be done with *every* startup of your shell as a login shell. As some setups specify to run a shell as login shell for every startup of a terminal window (eg xterm), this can be quite annoying.

pine [010307]
Patch that adds a "new mail check" to pine:
http://www.math.washington.edu/%7Echappa/pine/info/incoming.html
This add two more setup variables: enable-check-incoming-folders and incoming-folders-to-check. The check is then performed when you type CTRL-H in the index menu.


New Mail Notification by Shells

Some shells have a built-in facility to check folders for new mail. They usually just check once in a while whether the timestamp of the files have changed. They do not look into the folder and look at the mails, though.

bash
variables: MAILPATH - colon separated list of folders.
 MAIL
 If this parameter is set to a filename and the MAILPATH variable is not set,
 bash informs the user of the arrival of mail in the specified file.

 MAILCHECK
 Specifies how often (in seconds) bash checks for mail. The default is 60
 seconds. When it is time to check for mail, the shell does so before
 prompting. If this variable is unset, the shell disables mail checking.

 MAILPATH
 A colon-separated list of pathnames to be checked for mail. The message to
 be printed may be speci­ fied by separating the pathname from the message
 with a `?'. $_ stands for the name of the current mailfile. Example:
  MAILPATH='/usr/spool/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'
 Bash supplies a default value for this variable, but the location of the user
 mail files that it uses is system dependent (e.g., /usr/spool/mail/$USER).

 MAIL_WARNING
 If set, and a file that bash is checking for mail has been
 accessed since the last time it was checked, the message
 ``The mail in mailfile has been read'' is printed.

ksh
variables: MAILPATH and MAILCHECK
Example:
 MAILPATH=$HOME/mail/bob?"You have mail from Bob.":\
          $HOME/mail/susan?"You have mail from Susan."

tcsh
Variables: periodic, tperiod.
This shell reports on new mail. Use these settings for a check period of three minutes and have the check performed with "nfrm":
set    tperiod=3
alias  periodic nfrm

zsh
This shell reports on new mail.
Variables: MAIL, MAILPATH, MAILCHECK, mailpath


New Mail Notification - Misc Programs

"biff"
"man biff" says: "biff - give notice of incoming mail messages"

"newmail,wnewmail(1L)"
"newmail" is distributed with ELM. "man newmail" says: "programs to asynchronously notify of new mail" Based on "biff". Has some more features, though. NOTE: This should only be called *once* on one host as it stays in memory. I do not know a way to terminate the program other than with a "kill".


TODO


Delivery Status Notification (DSN)

Delivery Status Notification describes a protocoll to give information to the sender of a mail about the status of the mail at the receiver's end.

TODO: Link

[960823] Updates will be done if someone tells me that he is actually reading this. ;-) Yes, I have some material about this, but I need to get other stuff done, too.


Check Programs - Source

Where to get the mail notification programs.
nfrm
...

xbuffy [..,010306]
"X-based multiple mailbox biff"
http://filewatcher.org/sec/xbuffy.html
ftp://ftp.x.org/contrib/utilities/xbuffy3.3.README
ftp://ftp.x.org/contrib/utilities/xbuffy3.3.tar.gz [1997-08-19 31K (32339 bytes)]
"Xbuffy .. displays how many unread mails you have in your different mailboxes. You can have different titles for the mailboxes, and define what shall happen when a new mail arrives. It can beep and invoke a shell command, for example. Xbuffy can also notify you by blinking a keyboard LED when new mail has arrived. If you press mouse button 1 on the title associated with a mail box, a list of From: and Subject: lines of the mails in the mail spool file is shown. When you press mouse button 2, an arbitrary command is executed. If you press mouse button 3, the LED blinking is stopped until another mail has arrived. Xbuffy can similarly watch newsgroups via NNTP."
Xbuffy was written by Bill Pemberton wfp5p@virginia.edu and was based on Xmultibiff by John Reardon. (Xmultibiff can be found at ftp.midnight.com.)


Links

ELM Pages
http://www.guckes.net/elm/ - closed.

MUTT Pages
www.guckes.net/mutt/

PINE Pages
www.guckes.net/pine/


Credits

List of people who helped with info...

Sven Guckes webpage-mail-notification-faq@guckes.net www.guckes.net/mail/notification.html