Path: utzoo!attcan!uunet!mcsun!ukc!kl-cs!jonathan From: jonathan@cs.keele.ac.uk (Jonathan Knight) Newsgroups: comp.mail.misc Subject: Re: Checking for new mail Message-ID: <736@kl-cs.UUCP> Date: 24 Aug 89 22:58:52 GMT References: <1117@ispi.UUCP> Organization: University of Keele, England Lines: 39 From article <1117@ispi.UUCP>, by jbayer@ispi.UUCP (Jonathan Bayer): There are several techniques for finding out if new mail has arrived. Firstly, you can place a filter somewhere so that it gets run whenever new mail arrives. This method has been mentioned earlier for use with sendmail. All you have to do is create a file called .forward with the line like this: "| /fs/cs/jonathan/inboundmail" and then write a short shell script called /fs/cs/jonathan/inboundmail like this: #! /bin/sh /bin/mail -d jonathan echo "New mail has just been delivered" > /dev/ttyk5 This will have the desired effect if you were me and you always used /dev/ttyk5 to log in, anyway, the idea is there. Another method is to check the users mailbox periodically to see if the access times have changed. This is used by the shell's that say "You have new mail". All they do is remember when the last modification time was, and then check it every now and again until it changes. Various programs will run in the background and check this every minute, "newmail" which is part of the elm system springs to mind. A third method is to deduce when new mail has arrived by looking at the access and modification times of the mailbox. I have written a program called cmail which will report whether new mail has arrived in a users mailbox. From studying the effects of elm, mail, mailx, sendmail and /bin/mail I developed an algorithm to do this. I have posted it to comp.sources.unix some weeks ago so I suppose it will appear soon. Does this answer the original question? -- ______ JANET :jonathan@uk.ac.keele.cs Jonathan Knight, / BITNET:jonathan%cs.kl.ac.uk@ukacrl Department of Computer Science / _ __ other :jonathan@cs.keele.ac.uk University of Keele, Keele, (_/ (_) / / UUCP :...!ukc!kl-cs!jonathan Staffordshire. ST5 5BG. U.K.