TkMail v1.3 -- A Tk/Tcl interface to Mail by Paul Raines (raines@bohr.physics.upenn.edu) TkMail is an X windows interface to the unix Mail command built using Tk/Tcl. Reading, sending, and managing mail messages can almost all be done using only the mouse (except for the body of the message, of course). TkMail depends on the unix 'Mail' and 'sendmail' commands to do the real network mail work. It puts the X window interface on top and adds some additional features. Major Features: - listbox interface to messages for easy click and read - viewed messages are editable inside viewing widget so one can add or delete text for printing or piping selections - dynamic (at startup) menus for quick access to mail folders for reading, copying, and moving messages - button bar for quick composing, replying to, and forwarding of mail messages - built in 'biff' for detecting new mail - easy inclusion of files into message compositions with automatic uuencoding and compression, if desired - access alternate editor for compositions to send - spell check compositions using a X windows interface (must have the ispell program version 3.0.09) - filtering of headers to remove clutter (only on viewing) See the USER SETTINGS section below to get a real feel for what TkMail can do. This program is still very young so don't trust it without testing! Make a backup copy of your ~/mbox file and some of your folders and then test out the features on those files. INSTALLATION: (1) set the first line in the tkmail file to the location of your wish executable. (2) copy the files utils.tk, ispell.tk, and altedit.tk to the location of your choice and then edit the mf(utils), mf(spell), and mf(alteditlib) variables below to reflect that location (3) edit the other user setting in the tkmail file, particularly mf(cmd), mf(nopaging), mf(system), and mf(fdir). Also make sure you have the bitmaps in the locations given below. See BUGS below about mf(beep). Alternately, you set the variable mfp(globalset) at the top of the tkmail to a file that contains your site-wide settings. (4) Read the top of the ispell.tk file and follow the installation instruction there. COMPATIBILITY: I developed this app on SGI, Sun, and IBM workstations. This app depends on the following working: echo "h 1" | Mail -N -f folder This lists the headers of messages in folder to standard out. Make sure the mf(nopaging) variable is set right below or you will only get the a list of the first screenful of messages. On SUN, setting it to "set screen=100000" will do the trick echo "2" | Mail -N -f folder Displays message 2 on stdout. echo "d 3 4 8 9" | Mail -N -f folder Deletes messages 3,4,8, and 9 from folder. echo "s 4 5 9 24 file" | Mail -N -f folder Saves messages 4,5,9, and 24 from folder in file. echo "q" | Mail -N Prints a message like "Held 4 messages in /usr/mail/raines" if you have messages in your system box. cat file | sendmail -bm -t Mails file to users in To:, Cc:, and Bcc: fields. This bypasses the Mail command and therefore options such as 'record'. I have created the mf(record) user setting to account for this. It might be necessary to hack the mf_recordmsg procedure below to make it fit your mail folder format. I you find others that are bypassed and you want them included in TkMail, please mail me about it. I need to use sendmail for arbitrary header definition. You can change the name of the Mail command in the user settings below, but it must support the structure above. If you find that you have to make changes to the code to get it to work on your machine, please e-mail me and tell me what machine you are on and what changes you made. GENERAL USAGE: From your unix command line, type tkmail [-iconic] [folder] & If you do not specify a folder, your ~/mbox will be show. Most things in the menu should be self evident (yeah...that is what they always say). A few menu items are also on the button bar. All menu items can be accessed with the accelerator characters using the Alt key or Alt-Shift keys. Because of the hassle of dealing with the system inbox, I have the app incorporate new mail into the ~/mbox instead of treating it as just another folder. I hope to some day figure out a good way to not have to do this. When you get new mail, just click the 'Incorp' button and you will be taken to the ~/mbox folder at the first new message. The ~/mbox serves as the central place to dish out messages to your folders using the copy and move menu items. If you set mf(autoincorp) to '1', TkMail will automatically incorporate new mail if it is in the iconic state. If a ~/.tkmail or ~/tk/tkmail file exists, they are sourced so that the individual user can change the User Settings described below. The knowledgable Tk programmer can also do much more customization. One can define a procedure called mf_compose_hook in these files that will be evaluated each time a compose message window is created. See the included example.tkmail. The viewed message will always have the '>' character in front of it. The Delete, Copy, Move, Save, and Print commands operate on all selected messages. The Reply and Forward operate on only the currently viewed one. For efficiency and undo ability, deletes are not done immediately. Deletes are processed when changing folders or quitting. This means that if the something kills TkMail, any impending deletes are not done. ALIASES: TkMail parses your ~/.mailrc file on startup and creates an alias database. It understands lines beginning with 'a' or 'alias', it only does one sweep, so aliases refering to other aliases will not expand and will cause your mail to bounce. Normally, sendmail will not send the mail to any of the users listed if any one of them is not valid. MOUSE BINDINGS: Mouse bindings in the header list box are: B1 Click - view clicked message and make it the sole selection B1 Drag - select additional messages for later possible operations. B2 Click - unselect message clicked if not the viewed one. B3 Click - select message clicked with viewing. B3 Drag - select all messages dragged over. Mouse bindings in the message and compose window are normal Text bindings. B2 will insert the current selection and B3 will unselect it. See the 'text' man page. Using B3 on the Reply button will cause the message to be automatically included in the compose text. Using B3 on the Compose button will do the same but leave the To: field blank (for Forwarding with editing). KEY BINDINGS: Menu item can be accessed through keystrokes by using the Alt (Meta) key with the letter in brackets next to the item. If the letter is in uppercase, the Shift key is required. See the example.tkmail file to see how to set your own key settings. Set the mf(emacs) variable to '1' to get the typical emacs bindings for Control a,e,f,b,n,p,k,w,y. No arguments are supported and only a single kill buffer exists. Control-k only kills to the end of the line. Control-space sets the mark for the Control-w command. Control-Shift-S will pop up a window to enter a string for searching. Control-s will search again. Only the forward direction is supported. Control-Home goes to top of text, Control-End to the end. Home, End, PageUp, PageDown, and the arrow keys do their obvious operations. READER MENU: Folder: Open... Select new folder to view Quit Quit TkMail (processes deletions) Main Box View main mail box (usually ~/mbox) Incorporate Incorporate new mail from system box List of folders in folder directory to open Edit: Cut Cut selection into private buffer Copy Copy selection into private buffer Paste Paste private buffer at insert mark Save Sel Select file to current selection to Print Sel Select printer command to print selection to Eval TCL Sel Evaluate the current selection as Tcl Pipe UNIX Sel Pipe the current selection through a UNIX cmd and choose what to do with results Mesg: Next View next message in list Prev View previous message in list Delete Mark selected messages for deletion Undelete All Unmark messages mark for deletion Copy => Show folders to copy selected messages to Move => Show folders to move selected messages to Save Select file to save message to Print Select printer command to print message with Quick Decode Search mesg for encoding, and decode it Mail: Compose Popup window to compose new message Reply Popup window to reply to current message Forward Forward selected messages to a user Gripe Mail a gripe message to author Restore Last Restore last composition window List of addresses in mf(quicksend) Options: Reverse Order toggle mf(reverse) Format Headers toggle mf(format) Auto Incorp toggle mf(autoincorp) Save Last Send toggle mf(savesend) Parse From: toggle mf(getfrom) All Settings popup text window to edit all settings Help: if your reading this, you know what it does COMPOSE MENU: File: Insert File... Select a file to insert into composition - can encode, compress, and prefix Insert Mesg... Select messages to insert into composition Send Mail the composition Cancel Kill the window and don't send Edit: Cut Cut selection into private buffer Copy Copy selection into private buffer Paste Paste private buffer at insert mark Ispell Run tkispell on composition Show Cc/Bcc Toggle on/off the Cc/Bcc entries SETTINGS: Settings you will most likely want to customize in ~/.tkmail file: mf(mbox) - main mail box for messages to incorporate to ( this is usually ~/mbox ) mf(fdir) - directory containing mail folders ( hidden files will be ignored ) mf(reverse) - set to 1 so that most recent message at top mf(maxfold) - maximum number of folders displayed in menu mf(print) - UNIX commmand for printing (with %F subst for file) mf(tfont) - font for text widgets to use mf(tcolor) - color for tex widgets to use as background mf(fcolor) - color for tex widgets to use as foreground mf(headheight) - number of messages visible in top list at one time mf(geom) - initial geometry for main mail window mf(compgeom) - initial geometry of compose window mf(mailchk) - number of milliseconds between mail checks mf(prefix) - prefix for included messages mf(format) - format message header list in pretty way mf(record) - file to record outgoing messages in ( set to {} for none ) mf(beep) - alternate command to run when mail received ( set to {} for no beep ) mf(autoincorp) - whether to incorporate new mail automatically ( only when iconized ) mf(showcc) - whether to show Cc and Bcc entries in compose mf(savesend) - whether to save text of last compose window mf(mesgstate) - 'normal' or 'disabled' to allow mesg window editing mf(quicksend) - list of common addresses for composing mail ( can include aliases ) mf(getfrom) - whether to try to parse the From: field mf(emacs) - whether to put in emacs bindings ( see key bindings above ) mf(headers) - text to automatically put at top of all compositions mf(signature) - file to include at end of compostions mf(encoder) - program to use for encoding inserted files mf(compress) - program to use for compressing inserted files mf(hdrstrip) - header fields to strip out of messages ( use this cautiously as it can delete body ) mf(altedit) - command to run alternate editor for compositions ( must be an X-window command ) mf(pipedir) - directory to run piped UNIX commands All widget configuration options can be accessed through your .Xdefaults file in the normal Tk way. See the 'options' and individual widget man pages for more info. A few examples are: tkmail*Button.foreground: blue tkmail*Entry.font: fixed tkmail*Scrollbar.background: grey42 Settings that were most likely set to the proper defaults during installation include: mfp(globalset) - locations of site-wide settings file mf(utils) - location of utils.tk mf(spell) - location of ispell.tk mf(alteditlib) - location of altedit.tk mf(cmd) - BSD style mail command mf(deliver) - mail delivery command mf(system) - system mail box where mail is received mf(nopaging) - mail setting to prevent screen paging mf(tmp) - temporary file directory to use mf(fdownbmp) - bitmap to use to signal no mail mf(fupbmp) - bitmap to use to signal mail mf(writebmp) - bitmap to use for compose window The site adminstrator only has to modify the mfp(globalset) variable at the top of the tkmail source file and can put the rest of the settings in the pointed to file. An example line in the .tkmail file is shown below (note that you must use $env(HOME) instead of ~ for your home directory): set mf(fdir) $env(HOME)/Mail IMPLEMENTATION: The header list box is not a Tk Listbox but a text widget I hacked up so it could support non-contiguous selection. However, because it is a text widet, there is no horizontal scrolling. Every operation on a folder is a separate system call to the Mail command. It would be much more efficient to use one open pipeline command, but in standard Tcl, if one does a gets when there is nothing to get, the app hangs. As I see it, I have three choices which I list below in the order of my preference. (1) Require having one of the several extensions to wish that solve this problem. (2) Leave it like it is now (3) Write my own Mail command. The main change would be the speed with which a message is displayed. I would appreciate your opinions on this matter. When reading the stdout from the Mail command: Any ending lines that doesn't begin with a space in the header are interpreted as Mail information and discarded. All lines at the bottom of a message until the first blank (moving up from the end) are interpreted as Mail information. BUGS: The bell doesn't work when the shell TkMail was run from is killed. This is because the normal way of sounding the bell in Tcl is writing a '\007' to standard out. So until Tk supports a bell command, you must either make sure not to quit the shell TkMail was run from, or get one of the many patches to Tk that implement a bell. I have created the user setting of mf(beep) to put an alternate bell command if you have one. I am sure there are plenty of other bugs in this, so mail me about them (raines@bohr.physics.upenn.edu) TODO: more command line options than iconic, folder save dynamic user setting procedure MIME ( a long way off ) incoming mail filtering parse .mailrc to merge more Mail and TkMail options use autoload or toolbox for utils.tk and ispell.tk handle unshar similar to uudecode subdir structure for folders compressed folder support better emacs bindings