If you've been involved with the Internet for more than a few days, you've already realized that e-mail is the common currency, the most popular, most personal, and simultaneously most invasive of network communications. It's the only medium on the Net where everything you receive is directed to you, not to a group you're reading or a site you're maintaining. That's a great thing, but there's a price to pay. That price becomes more visible as you receive more and more electronic mail: it takes a lot of time to manage your electronic correspondence!
This isn't really news; your mailbox at home is also an open market, a free-for-all target for hundreds of bulk-mail companies, catalog salesfolk, credit card vendors, and goodness knows what else. Wouldn't it be great if you could hire someone to help you with your correspondence? A lackey who sent notes to all junk correspondents asking that you be removed from their mailing lists, who automatically responded to all requests for information without your having to get involved?
That's difficult to accomplish in the real world (I suppose that if you have sufficient funds, you can always hire someone to do this for you). With computer-based correspondence, the good news is that you can choose from a variety of programs that can do just thisand they're all free. Even better, if you're a burgeoning commercial vendor who wants to distribute information to your customers or clients without having to directly check your mail each day, these programs are just the trick. They easily answer requests for technical notes, pricing sheets, information files, and even source code and bug fixesday or night, weekday or weekend.
This chapter considers two different e-mail auto-responders, as they're called. Embot offers a new, simple way to automate responding to electronic mail; Filter offers a smart programming environment for specifying any of a wide number of possible actions based on simple rules. Both of these programs require that your e-mail be received on a UNIX-based system, but don't despair: almost all low-cost Internet access accounts available are on just that type of system, whether a PC running UNIX or Linux, a Sun Microsystems machine running Solaris, or some other variant.
For less than $20 a month (and a bit of work), you can set up an automatic document-distribution system that can be accessed by over twenty million people, including everyone on CompuServe, GEnie, Prodigy, America Online, and eWorld. A definite bargain, I think.
The first of the robots described in this chapter is also the simplest: Embot. Embot scans through all your electronic mail as it arrives and automatically answers any messages that appear to be addressed to it rather than to you. It places any other mail in your usual incoming mailbox. You don't even know it's running unless you ask it for a status check. Although this is basically how all the programs described in this chapter work, the more complex programs require you to define a set of rules that define user requests, actions, and results. A typical rule might be "any message that has the subject send catalog should be answered with a copy of the file CATALOG."
The goal of Embot was to create a mail robot that didn't require any type of rule set to work intelligently and transparently. As a result, Embot simply looks for messages (or message subjects) that contain a specific one-word or two-word request and answers it. The one-word requests are help or info (which are synonymous with send help and send info); any file at all can be requested with the first word send or get. Rather than force the user to build an index of available files and information (which is one of the purposes of rule sets), Embot creates its own subdirectory and assumes it's okay to send copies of any file or files in that directory.
This means that once you set up Embot, it's simplicity itself to add new information to your database of available documents: simply save a copy of the file in the Embot directory. That's it. No updated rule sets, no index modifications, nothing. Immediately, Embot knows about the new file; requests that come in as quickly as two seconds after your addition can result in that file being sent in response. Updating files is similarly easy: simply replace the old version of the file with the newer one; anyone requesting the file automatically receives the most recent copy. This suggests how easy it is to offer daily price quotes, for example, or even hourly stock results through electronic mail.
You can most easily get a copy of Embot by asking the master copy of the program to send you a copy of itself. Simply send an e-mail message to embot@northcoast.com. You can specify help in the subject line or in the message body, but Embot is smart enough to send you back a friendly greeting and an explanation of how to work with iteven if your message is completely blank. Here's what you most likely receive in response to your query (probably within five minutes or less):
Subject: Some tips on using the Embot program
Hi! I'm Embot, and I've been set up to look through e-mail messages as they arrive here and try to extract and respond to requests for files and other such miscellaneous tasks. I'm really quite easy to work with - or so my Dad says - and all you have to remember is that if you send any requests that I don't understand, I'll drop them in the mailbox of my owner so he or she can respond by hand. That's a lot slower, however, since humans don't think as quickly as us computers do, but that's another subject entirely. Anyway, to get files, handouts, and other information directly, all you need to do is know the name of the file and send a request to me like:
send thefilename
This can appear in the subject of the message or in the body of the message. If you want a bunch of files, send me a single message with all your requests in the body of the message, and I'll send them back as a number of different e-mail messages. My owner won't even know!
To start out, send me a request to list all the available files. The easiest way to do this is to have 'list' as either the subject of the message or within the message body itself. I'll jump into action, build a list of all files and information I'm authorized to send, and mail that back to you, probably within five minutes of your request.
Once you have that, you can even reply to that message, prefacing the files you'd like with the word 'send'.
That's about it. Any messages I don't understand, like I said, will be dropped in the mailbox of my owner, and if you request 'help,' you'll get a copy of this message.
If you'd like a copy of the Embot program to help you filter your own electronic mail, I'd be delighted to help you out. You can get a copy by sending mail to me at embot@northcoast.com. Specify 'send embot' and you'll get a copy of my source code and installation instructions as fast as I can spell mitosis!
Thanks for working with me, and I look forward to hearing from you again in the near future.
Bye for now.
Embot
Installation is relatively simple, at least for those somewhat versed in UNIX commands, but if you're a complete neophyte, you may opt to have someone help you out. Rather than provide the nuts and bolts of installation here, we note that you should read the README file closely (indeed, we recommend that you upload it to your home computer, print it out, and read through it before you actually begin typing any commands).
Once you install the program and configure it, you should ask Embot to check its own configuration by using the embot check command. Here's a typical output listing:
% embot check
Checking your Embot configuration...
Account = embot, fullname = Embot
Home directory = /home/embot
Embot home directory (/home/embot/Embot) is okay.
You don't have an Embot generic reply file (/home/embot/Embot/.default-msg) so you won't be able to use the '-a' answer-all-mail option.
You don't have an Embot default help file (/home/embot/Embot/help) which is definitely ungood. Please check into it ASAP!
I can't find a .forward file for you: I can't filter your e-mail without my being added to this file or some equivalent.
Done checking your configuration.
Embot can detect and fix some common configuration problems, and once it is done, you have a directory called Embot that serves as your repository for any files or directories you want to make available.
The help file is automatically copied into your directory; before you go further, if you've turned on Embot by adding it to your .forward file, you can begin testing it and learning how it works. A .forward file, in case you aren't sure, is a short file you place in your UNIX system home directory that instructs the mail delivery program to forward your messages to a specified address or program (rather than just delivering them to your mailbox). For all mail filter programs, you must create a simple .forward file that lets the system know you want to have the program check your mail.
As a first step, send yourself an e-mail message with the subject help. You should get back the same message you received when you sent mail to the Embot master copy on northcoast.com. Next, ask Embot for a file that isn't available: send a message with the subject send unknown-file. The response looks like this:
You requested file 'unknown-file' but it isn't available. The list of possible files is as follows:
help
README
embot.shar
Please send your request again, specifying one or more of these files.
Thanks!
Embot
You should save any files you want to have Embot distribute in the Embot directory.
After a while, you may find that many people send requests that can't be understood by Embot. In particular, some people send messages like "please send catalog" or "send catalog, thank you," neither of which is understood by Embot and both of which, therefore, end up in your own mailbox, requiring you to answer them by hand. This can be quite tedious if you send out dozens or hundreds of files each day. Fortunately, Embot can take over all the e-mail sent to an account, responding with a helpful message when it receives messages it doesn't understand. The Embot master copy does exactly that: try sending a message with the subject hello to embot@northcoast.com. Here's its response:
Subject: I couldn't understand your e-mail
Hi! You've mailed a message to me, but I'm Embot, not a human, so I only understand certain specific requests and comments in my e-mail. To get files, handouts, catalogs, and other information directly, all you need to do is know the name of the file and send a request to me like:
send thefilename
This can appear in the subject of the message or in the body of the message. If you want a bunch of files, send me a single message with all your requests in the body of the message, and I'll send them back as a number of different e-mail messages.
To start out, send me a request to list all the available files. The easiest way to do this is to have 'list' as either the subject of the message or within the message body itself. I'll jump into action, build a list of all files and information I'm authorized to send, and mail that back to you, probably within five minutes of your request.
Once you have that, you can just reply to that message, prefacing the files you'd like with the word 'send'.
Thanks for working with me, and I look forward to hearing from you again in the near future.
Bye for now.
Embot
To turn this feature onand don't use it for your personal account or you'll never get any personal mail delivered to your mailbox!simply change the information in the .forward file to |embot -a. I highly recommend that you use a separate account and test it extensively before you publish its address for customer, client, or even use by your friends.
Embot keeps track of who requests which files from you, too. It's simple to learn what's been requested and by whom. To find out what files have been sent, for example, type embot stats; following is a sample list of the files accessed by Embot:
11 /home/embot/Embot/embot.shar
7 /home/embot/Embot/help
6 listing-of-files
7 /home/embot/Embot/info
If you're curious about who requested a specific file (for example, your product info file), type embot wanted info to learn more (info, in this case, is the name of the file you've been sending). Following is a sample list of the people who have accessed the info file:
carlson@odin.net
marv@netcom.com
root@ns1.two.com
taylor@netcom.com
untangl@the-wire.com
untangle@io.org
zcopley@cats.ucsc.edu
Note that you can easily build a simple mailing list based on these addresses as a way of offering further information to those people interested in your product line. (Beware of flooding their mailbox with advertisements, however; such conduct is poorly received in the Internet community, as Rosalind Resnick and I explain in The Internet Business Guide, published by Sams Publishing, 1994.)
Unsure about what commands and options Embot understands? Simply type embot help to have the program remind you what you can do:
% embot help
Welcome to Embot! I understand a variety of interactive commands,
all of which should be specified on the command line:
stats obtain statistics about embot usage, by requested file
users produce a list of people who have accessed your embot
wanted file see who has requested the specified file
check Quick checks to see if things are configured OK
clear clear your log files (your log file is 1645 bytes)
I also have a couple of different starting flags:
-a Respond to ALL mail sent:
Only use this if I have my own account
-v For testing, this produces a log of my actions.
Only for when I'm being used interactively!
Embot has a long memory: it can remember all requests from the very first day you install it, regardless of how many that represents. If you want to empty out its log file, type embot clean and Embot cleans up its database. If you want to retain a list of people who requested a file, however, make sure that you save a copy of the log file (once you clean the log file, the information is gone forever).
SUPPORTING FURTHER EMBOT DEVELOPMENT
Although Embot is a great solution for people seeking to simplify the distribution of files, technical reports, catalogs, source code, and other information through electronic mail, if you need more capabilities to tame your wild e-mailbox, you'll want to move up to Filter. Filter can send out not only files, catalogs, and other information, it can also delete mail from certain people, file mail from specific mailing lists into user-designated folders, and even forward specific messages to other peopleall without any intervention on your part.
The trick, however, is to get things set up correctly.
Filter is based on an artificial intelligence-inspired rule set of conditions that the program checks on receipt of each and every electronic mail message. The overall form for a rule is "if a certain condition is evaluated as true, then do the specified action." If no rules are matched, Filter delivers the message to your mailbox.
Filter is a piece of the Elm mail system, a popular screen-based electronic mail program. As a result, it is distributed (for free) as part of the Elm system and is most likely already installed on your Internet access provider's computer system (or even included with your UNIX system). The rules file for Filter lives in a file called filter-rules in a directory called .elm in your home directory. That is, if your home directory is /home/taylor, the Filter rules file is in /home/taylor/.elm/filter-rules.
There's a lot you can do with your Filter rule set. At its most fundamental, the language is simple to learn and work with; Filter helps by explaining what it doesn't understand if you make any mistakes while writing your rules.
Following is the filter-rules file I have in place to filter through the mail I receive at the account taylor@netcom.com:
#
# Filter rules so that people can request files without my
# having to mail them back one-by-one.
if (subject = "send mall" ) then
exec "send mall %r"
if (subject = "send tyu" ) then
exec "send tyu %r"
if (subject = "send gs" ) then
exec "send gs %r"
if (subject = "send addme" ) then
exec "send addme %r"
if (subject = "send toc" ) then
exec "send tyu-toc %r"
if (subject = "send inbiz" ) then
exec "send intbiz %r"
if (subject = "SUBSCRIBE imall-l" ) then
delete
Each rule is specified in the format if condition then action. Each rule is considered in order, from first to last, until one matches the message that has been received. If you send me a message from your account reader@mcp.com with send addme as the subject, for example, Filter compares that subject to send mall, send tyu, and so on until it gets to the comparison for send addme. The two subjects match, so Filter invokes the associated action: exec "send addme %r".
The exec command is shorthand for execute UNIX command; Filter automatically replaces the cryptic %r with the return address of the message. Therefore, the actual send program is invoked with the command send addme reader@mcp.com.
Given that information, it's a simple and succinct C shell script that actually sends the specified file to the specified e-mail address. Here's an example of the send script you can use in cooperation with Filter to automatically send back information to users who request specific files or data.
#!/bin/csh -f
# a simple SEND shell script
cd /home/taylor/Filter-Files # move into the file archive dir
if ( ! -f $1 ) then
echo "I'm sorry, but file $1 is not available. Here's what is:"
ls -CF | expand | sed 's/^/ /'
else
mail -s "File $1, as requested" $2 < $1
endif
exit 0
Without delving too far into shell script programming (a task that Teach Yourself C Shell Programming in 21 Days, published by Sams Publishing, 1994, fulfills admirably), I will quickly note that $1 is expanded to the first word of the command (the name of the requested file) and $2 is expanded to the return address to which the file should be sent. As occurs within the filter-rules file, the C shell script tests the items between brackets and executes the action if appropriate. For the first test, -f tests to see whether the specified file ($1) exists; the prefix (!) reverses the logic of the testin other words, the first test is really, "If the specified file does not exist, state that the file isn't available and list the alternatives." If the file is available, it's mailed to the user using the UNIX mail command.
Filter rules aren't as difficult to write as you may think. The language is succinct and should help you easily specify actions to help manage the tsunami of electronic mail you receive on a daily basis.
Recall that all rules are in the format if condition then action. There are four conditions that can be checked:
Condition |
Meaning or Interpretation |
|
from |
Checks the return address of the message |
|
subject |
Lists the subject of the message, if any |
|
to |
Identifies the person to whom the message is addressed |
|
lines |
Lists the number of lines in the message |
Expressions can test for equality (=), inequality (!=), or logical values. If you want to delete all messages from anyone at netcom, for example, you could use this rule:
if (from "@netcom.com") then delete
To reverse the logic of the rule, preface the rule with not:
if not subject = "test message"
To construct multiple conditions, add and between subconditions:
if (from="jane@edu" and lines > 30) then delete
Filter is quite flexible with the actual syntax of rules; if you prefer to have conditions in parenthesis, that's okay. If you prefer to think that subjects contain patterns rather than that subjects equal patterns (which is a more precise way to consider the matching strategy used), you are free to write rules like these:
if subject contains "send embot" then
forward "embot@northcoast.com"
Any condition must be followed by an action, which can be any of the following:
Action |
Meaning or Interpretation |
|
delete |
Deletes the message |
|
save folder |
Saves the message to the specified folder |
|
savecopy folder |
Same as save folder, but also delivers a copy to your mailbox |
|
execute command |
Feeds the message to the specified UNIX command |
|
forward address |
Forwards the message to the specified e-mail address |
|
leave |
Leaves the message in your mailbox (normal delivery of mail) |
That's the entire Filter rules language, with one addition not yet discussed. If you want to specify a default rule at the bottom of the rule set for delivery of all messages that are not otherwise matched, you can specify the special command always, which looks like this:
always
delete
In this example, any message not already matched by a previous rule is summarily deleted, which, frankly, is probably not a particularly great strategy for trimming your electronic mail (although it is no doubt quite effective).
Once you have written a set of rules that you think properly match your needs, you can ask the Filter program to double-check the syntax and notation. Simply type filter -r at the command line. The program scans and checks each rule, printing each to the screen as it goes. Here's an example:
% filter -r
Rule 1: if (subject = "send mall") then
Execute /u1/taylor/bin/send mall <return-address>
Rule 2: if (subject = "send tyu") then
Execute /u1/taylor/bin/send tyu <return-address>
Rule 3: if (subject = "send gs") then
Execute /u1/taylor/bin/send gs <return-address>
Rule 4: if (subject = "send addme") then
Execute /u1/taylor/bin/send addme <return-address>
Rule 5: if (subject = "send toc") then
Execute /u1/taylor/bin/send tyu-toc <return-address>
Rule 6: if (subject = "send inbiz") then
Execute /u1/taylor/bin/send intbiz <return-address>
If any problems are encountered, they are flagged, Here's how an error is flagged when I add a deliberate mistake to my rules file:
filter (04/03/95 12:26:32 taylor): Error on line 18 of rules - action "trash" unknown
Just as with the other mail processing programs, you must tell the UNIX system that you want Filter to check your electronic mail as it's delivered. You do this by creating a .forward file in your home directory that contains the following line: |filter. It's a good idea, however, to use the which command to identify the full name of the Filter program on your system (the which command returns something like /usr/bin/filter). Use that name in the .forward file. The resulting line in the .forward file is something that looks like this:
|/usr/bin/filter
Once the .forward file is in place, you're ready to roll. Filter starts checking and answering your mail without any fuss. One strategy for sending files with Embot, of course, is to tell everyone to use a specific subject line for their requests (in the section on Embot, earlier in this chapter, you can see how people send mail with subjects like send mall or send intbiz to get information without intervention).
Filter keeps track of its actions, whether they result in a message being sent to someone, a message being deleted, or even just dropped into your mailbox. You can learn what Filter has been doing by typing filter -s (which results in a succinct summary of actions) or filter -S (which offers the same summary followed by a detailed analysis of each actionthat can go on for hundreds of pages!). Here's an example of the latter, greatly abbreviated:
% filter -S
A Summary of Filter Activity
A total of 699 messages were filtered:
The default rule of putting mail into your mailbox
applied 441 times (63%)
Rule #1: (given to command "/u1/taylor/bin/send mall %r")
applied 113 times (16%)
Rule #2: (given to command "/u1/taylor/bin/send tyu %r")
applied 2 times (0%)
Rule #4: (given to command "/u1/taylor/bin/send mall %r")
applied 15 times (2%)
Rule #5: (given to command "/u1/taylor/bin/send addme %r")
applied 19 times (3%)
Rule #7: (given to command "/u1/taylor/bin/send promo %r")
applied 3 times (0%)
Rule #9: (given to command "/u1/taylor/bin/send tyu-toc %r")
applied 2 times (0%)
Rule #13: (given to command "/u1/taylor/bin/send intbiz %r")
applied 11 times (2%)
Explicit log of each action:
Mail from JWGuirl@aol.com about send mall
EXECUTED "/u1/taylor/bin/send mall JWGuirl@aol.com" by rule #1
Mail from HBeZee@aol.com about Description for inclusion in Mall
PUT in mailbox: the default action
Mail from HBeZee@aol.com about send intbiz
EXECUTED "/u1/taylor/bin/send intbiz HBeZee@aol.com" by rule #13
Mail from HBeZee@aol.com about send mall
EXECUTED "/u1/taylor/bin/send mall HBeZee@aol.com" by rule #1
Mail from P.Ket@topos.ruu.nl about Internet Mall
PUT in mailbox: the default action
Mail from kawabe@unisys.co.jp about send mall
EXECUTED "/u1/taylor/bin/send mall kawabe@unisys.co.jp" by rule #1
Mail from Mailer-Daemon about Returned mail: User unknown
PUT in mailbox: the default action
Mail from gwl1@gte.com
PUT in mailbox: the default action
Mail from lghecht@netcom.com about Advertising in the Internet Mall
PUT in mailbox: the default action
Mail from lhatzakis@hol.forthnet.gr about send mall
EXECUTED "/u1/taylor/bin/send mall lhatzakis@hol.forthnet.gr" by rule #1
Mail from taylor about New mail archive server for your FAQ
PUT in mailbox: the default action
Because Filter remembers every transaction, it's imperative that you occasionally clean out the log file it uses to track actions. You can do this easily when you request a summary: type filter -sc to produce a summary of actions and also clear the log file. If you issue the command a second time, Filter tells you it can't find a log file. No worries, though: the file is automatically re-created when the next message arrives for you.
Other programs can help you manage your electronic mail, including the baffling, but incredibly powerful, Procmail system for UNIX, and the many PC and Macintosh-based electronic mail front-end programs (most notably, the slick filtering system included with the full release of Eudora). For people who want to set up a simple and efficient e-mail robot that can help them promote their personal interests or business on the Internet, however, Embot and Filter can't be beat.
Nonetheless, the best way to manage the flood of electronic mail is to ask yourself the question "is this necessary?" for each message you receive. If you get unsolicited e-mail from someone selling something, for example, respond to them (and the postmaster at their site) with a brief note saying that you didn't seek the information and you don't want to receive any more messages from that party. If you're on a mailing list and it seems to be migrating from topics of interest to those that aren't of interest, sign off the list. If your customers send you mail with requests for catalogs or other automatically distributed files but are formatting the requests incorrectly, create a new account and set up Embot or some other program to answer all mail sent to that account so that you don't have to spend time with the inevitable "oops" messages you are otherwise forced to send on a daily basis.
The underlying goal is to ensure that each message you actually receive in your mailbox (after being checked and filtered by Embot, Filter, or some other program), is worth reading and considering. If you find that lots of your mail just wastes your time, you're a prime candidate for much of what I have discussed in this chapter.
Best of luck! Feel free to send me an electronic mail message with your experiences using either Embot or Filter, or with your own helpful tips for managing the flow of electronic mail. Just be careful of the subject, or my robot will respond instead!