We'll end this chapter on electronic mail by looking at a few related tools and utilities. You should be aware of the vacation program (included with the sendmail package). It is a utility for automatically sending a predefined reply to all arriving mail while a user is away from email access. To use it, the user creates a file named .vacation.msg in his home directory and creates a .forward file containing an entry like the following: \username, "|/usr/bin/vacation username" This sends each mail message to the user's usual mailbox and pipes it to the vacation program, giving the username as its argument. The slash is needed before the username to create a terminal mail destination and avoid an infinite loop. Finally, the user activates the service with the following command: $ vacation -I To disable vacation, simply move or remove the .forward file.
Next, you might find useful these commands that notify users that they have received new mail: biff, xbiff, and coolmail (a prettier xbiff written by Byron C.Darrah and Randall K. Sharpe; I found it on the Internet at http://www.redhat.com/swr/src/coolmail-1.3-9.src_dl.html, but it builds easily on other systems). The oldest of these, biff, requires the comsat network service, which is managed by inetd. These days, however, it is often disabled by default in /etc/inetd.conf because the graphical utilities have usually replaced biff. To enable the comsat service, uncomment the corresponding line in inetd.conf and kill -HUP the inetd process. Postfix also sends comsat-based messages directly, and this feature is enabled by default. To disable the comsat client code in the Postfix delivery agent, include the following parameter in /etc/postfix/main.cf: biff = no HP-UX, FreeBSD, and Solaris all offer a neat utility called from. This program displays the header lines from all mail messages in your mailbox, as in this example: $ from From uunet!modusmedia.com!palm Thu Mar 1 23:04:39 2001 From uunet!ccsilver.com!sales Fri Mar 2 20:16:38 2001 From uunet!suse.de!isupport Fri Mar 2 17:16:39 2001 Finally, grepmail is a utility for searching mail folders; it was written by David Coppit and is available free of charge at http://grepmail.sourceforge.net). It searches the headers and/or message text for a specified regular expression and displays matching messages. It has many options; Table 9-13 lists the most useful.
Here are a couple of examples of using grepmail: $ grepmail -R -i -l hilton ~/Mail Mail/conf/acs_w01 $ grepmail -i hilton ~/Mail/conf/acs_w01 | grep -i telephone Telephone: 619-231-4040 The first command searches for the string "hilton" (in any mix of cases) in all the mail files in the user's mail directory tree, specifying that only the filename for matching files be displayed. The second command searches the file found by the first command for the same string, this time displaying the entire matching message. In this case, the output of grepmail is piped to grep to search for the string "telephone". The resulting command returns one matching line. Of course, the two grepmail command could also be combined, but I have separated them to illustrate several command options. |