TOC |
|
The personal.tcl mailbot implements a highly-specialized filter for personal messages. It MUST not be used by people who receive mailing list traffic in their personal mailboxes.
TOC |
TOC |
Create a configuration file and add this line to your ".forward" file:
"| LIB/mbot1.0/personal.tcl -config FILE -user USER"
where "LIB" is where the Tcl library lives, "FILE" is the name of your configuration file, and "USER" is your username.
This package requires:
(c) 1999 Marshall T. Rose
Hold harmless the author, and any lawful use is allowed.
TOC |
The mailbot's philosophy is simple:
Do NOT use the personal.tcl mailbot if you receive mailing list traffic in your personal mailbox. When sending mail to a mailing list, either:
Guest lists are an effective mechanism for cutting back on excessive mail.
Here are the fine points:
The rejection notice should be written carefully to minimize an extreme negative reaction on the part of the uninvited. Of course, by allowing a passphrase, this provides something of a CQ test for the uninvited -- if someone can't pass the test...
TOC |
The mailbot supports the following command line arguments:
Note that if "-user" is given, then the working directory is set to userName's home directory before configFile is sourced, and the umask is set defensively.
- -config configFile:
- specifies the name of the configuration file to use;
- -debug boolean:
- enables debug output;
- -file messageFile:
- specifies the name of the file containing the message;
- -originator orginatorAddress:
- specifies the email-address of the originator of the message; and,
- -user userName:
- specifies the user-identity of the recipient.
The default values are:
personal.tcl -config .personal-config.tcl \ -debug 0 \ -file - \ -originator "derived from message"
Given the default values, only "-user" need be specified. The reason is that if a message is being delivered to multiple local recipients, and if any of the ".forward" files are identical in content, then sendmail may not deliver the message to all of the local recipients.
A few other (sendmail related) tips:
The mailbot begins by parsing its arguments, sourcing configFile, and then examining the incoming message:
There are two kinds of information that may be defined in configFile: configuration options and configurable procedures.
Here's a simple example of a configFile for a user named "example":
set options(dataDirectory) .personal set options(defaultMaildrop) /var/mail/example set options(logFile) [file join .personal personal.log] set options(noticeFile) [file join .personal notice.txt]
configFile must define dataDirectory and defaultMaildrop. All other configuration options are optional.
The directory where the mailbot keeps its databases. The subdirectories are:
If you want to remove someone from a guest list, simply go to that directory and delete the corresponding file.
- badaddrs:
- the directory of rejected email-addresses
- inaddrs:
- the directory of originator email-addresses
- msgids:
- the directory of Message-IDs
- outaddrs:
- the permanent-guest list
- phrases:
- the directory of at-most-once passphrases
- tmpaddrs:
- the temporary-guest list
The filename where messages are saved for later viewing by your user agent.
The filename where messages are saved for audit purposes.
The filename where your outgoing messages are saved for audit purposes.
A list used by friendP giving the domain names where your friends live.
The filename where the mailbot logs its actions.
Your preferred email-address with commentary text, e.g.,
Marshall Rose <mrose@dbc.mtview.ca.us>
The filename containing the textual notice sent when a message is rejected. Note that all occurrances of "%passPhrase%" within this file are replaced with an at-most-once passphrase allowing the originator to bypass the mailbot's filtering. Similarly, any occurrences of "%subject%" are replaced by the "Subject" of the incoming message.
The email-addresses where a textual synopsis of the incoming message is sent.
The email-addresses where a copy of the incoming message is resent.
All of these procedures are defined in personal.tcl. You may override any of them in configFile.
proc adminP {local domain}
Returns "1" if the email-address is an automated administrative process.
proc friendP {local domain}
Returns "1" if the email-address is from a friendly domain or sub-domain.
proc ownerP {local domain}
Returns "1" if the email-address refers to the user (as determined by looking at myMailbox, pdaMailboxes, and remoteMailboxes.
proc saveMessage {inF {outF ""}}
Saves a copy of the message contained in the file inF. If the destination file, outF, isn't specified, it defaults to the defaultMaildrop.
proc findPhrase {subject}
Returns "1" if a previously-allocated passphrase is present in the subject. If so, the passphrase is forgotten.
proc makePhrase {}
Returns an at-most-once passphrase for use with a rejection notice.
proc pruneDir {dir type}
Removes old entries from one of the mailbot's databases. The second parameter is one of "addr", "msgid", or "phrase".
proc tclLog {message}
Writes a message to the logFile.
TOC |
TOC |
Marshall T. Rose | |
Dover Beach Consulting, Inc. | |
POB 960 | |
Denver, CO 80201-0960 | |
US | |
Phone: | +1 303 382 1260 |
Fax: | +1 303 382 1264 |
EMail: | mrose@dbc.mtview.ca.us |
TOC |
If impersonalMail returns a non-empty string then the message is processed differently than the algorithm given in Actions. Specifically:
Regardless, if an entry was present for the folder, then processing terminates.
- "ignore":
- the message is silently ignored;
- "bounce":
- the message is noisily bounced; or,
- otherwise:
- the message is resent to the address.
If "impersonal" mail is received, then foldersFile and foldersDirectory must exist.
The directory where the mailbot keeps private folders.
This file contains one line for each private folder.
The email-addresses where an announcement is sent when a new private folder is created.
The file consulted by the mailbot to determine how to process "impersonal" messages. Each line of the file consists of a folder name and value, seperated by a colon (":"). There are three reserved values: "bounce", "ignore", and "store".
All of these procedures are defined in personal.tcl. You may override any of them in configFile.
proc impersonalMail {}
If the message is deemed "impersonal", return the name of a corresponding private folder; otherwise, return the empty-string.
Many mail systems have a mechanism of passing additional information when performing final delivery using a program. With modern versions of sendmail, for example, if mail is sent to a local user named "user+detail", then, in the absense of an alias for either "user+detail" or "user+*", then the message is delivered to "user". The trick is to get sendmail to pass the "detail" part to the mailbot.
At present, sendmail passes this information only if procmail is your local mailer. Here's how I do it:
*** _alias.c Tue Dec 29 10:42:25 1998 --- alias.c Sat Sep 18 21:51:35 1999 *************** *** 813,818 **** --- 813,821 ---- define('z', user->q_home, e); define('u', user->q_user, e); define('h', user->q_host, e); + + setuserenv("SUFFIX", user->q_host); + if (ForwardPath == NULL) ForwardPath = newstr("\201z/.forward");
This makes available an environment variable called "SUFFIX" which has the "details" part. The drawback in this approach is that this information is lost if the message is re-queued for delivery (what's really needed is an addition to the .forward syntax to allow macros such as $h to be passed).
The corresponding impersonalMail procedure is defined as:
proc impersonalMail {} { global env return $env(SUFFIX) }
TOC |
Here is the ".forward" file for the user "hewes":
"|/usr/pkg/lib/mbot1.0/personal.tcl -config .personal/config.tcl -user hewes"
(Of course, it's all on one line.)
Here is the user's ".personal/config.tcl" file:
array set options [list \ dataDirectory .personal \ defaultMaildrop /var/mail/hewes \ auditInFile [file join .personal INCOMING] \ auditOutFile [file join .personal OUTGOING] \ friendlyDomains [list tcp.int dbc.mtview.ca.us] \ logFile [file join .personal personal.log] \ myMailbox "Arlington Hewes <hewes@example.com>" \ noticeFile [file join .personal notice.txt] \ pdaMailboxes hewes.pager@example.com \ foldersDirectory [file join .personal folders] \ foldersFile [file join .personal .mailboxlist] \ mappingFile [file join .personal mapping] \ announceMailboxes hewes+sys.announce@example.com \ ] proc impersonalMail {} { global env return $env(SUFFIX) }
Note that because remoteMailboxes isn't defined, personal messages are ultimately stored in the user's defaultMaildrop.
TOC |
The original version of this mailbot was written by the author in 1994, implemented using the safe-tcl package (Borenstein and Rose, circa 1993).