Date: Sun, 20 Sep 1992 19:16:42 -0400 From: kkirksey@world.std.com (Ken B Kirksey) Subject: Eudora As An Offline Reader This archive contains a short Unix program and document explaining how to use Eudora as an offline UNIX mail reader. If you want to use Eudora, but don't have a TCP/IP connection to your mac or access to a slip server, this file is for you. The program (udora.c) and the document are both in the beta stage. I've gotten the program to compile on a SparcStation, but I'd like to know how it compiles on other unix boxes. Any feedback is welcome and appreciated. Ken #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh udora.c <<'END_OF_udora.c' X/******************************************************************************* X* udora.c by Ken Kirksey * X* Version 1.0b1 20 Sep 1992 * X* * X* This program takes the Out file generated by Eudora and automatically parses * X* out and mails each message in the file. Consult the Readme file that came * X* with this source file for complete details on it's use. * X* * X* Eudora )1990 by the University of Illinois Board of Trustees. * X* Eudora was written by Steve Dorner * X* * X* This program )1992 Ken Kirksey. It may be modified for your personal use * X* only. Do not distribute an modified versions of this program. * X*******************************************************************************/ X#include X#include X X#ifdef THINKC X#include X#endif X X/*=============================================================================+ X| Macros and Constants | X+=============================================================================*/ X#define MAIL_TEMP_FILE "udora.tmp" X#define SIG_FILE ".signature" X#define TRUE 1 X#define FALSE 0 X X/*=============================================================================+ X| Variables | X+=============================================================================*/ XFILE *infile, X *outfile, X *sigfile; X Xchar buffer1 [120], X *charPtr, X toAddress[120], X subject[180]; X Xint isSigfile; X X X/*=============================================================================+ X| MAIN | X+=============================================================================*/ Xmain (argc, argv) Xint argc; Xchar **argv; X{ X X#ifdef THINKC X argc = ccommand (&argv); X#endif X X /*-------------------------------------------------------------------------+ X | Report error if they didn't give a mail file name. | X +-------------------------------------------------------------------------*/ X if (argc < 2) X { X fprintf (stderr, "\n Useage: eudora "); X exit (-1); X } X X /*-------------------------------------------------------------------------+ X | Open input mail file. | X +-------------------------------------------------------------------------*/ X if ( (infile = fopen (argv[1], "r")) == NULL) X { X perror ("Error opening input file"); X exit (-1); X } X X /*-------------------------------------------------------------------------+ X | Open Temp file. | X +-------------------------------------------------------------------------*/ X if ( (outfile = fopen ("eudora.tmp", "w")) == NULL) X { X perror ("Error opening udora temp file"); X exit (-1); X } X X /*-------------------------------------------------------------------------+ X | Check for the existence of the signature file. | X +-------------------------------------------------------------------------*/ X if ( (sigfile = fopen (SIG_FILE, "r")) == NULL) X isSigfile = FALSE; X else X isSigfile = TRUE; X X fclose (sigfile); X X X /*-------------------------------------------------------------------------+ X | Priming read. Read in destination address from mail header. | X +-------------------------------------------------------------------------*/ X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X strcpy ( toAddress, (buffer1+4)); X X /*-------------------------------------------------------------------------+ X | Handle addresses of the form "username@domain (Real Name)" | X +-------------------------------------------------------------------------*/ X if ( (charPtr = strchr (toAddress, '(')) != NULL) X *charPtr = '\0'; X X /*-------------------------------------------------------------------------+ X | Handle addresses of the form "Real Name " | X +-------------------------------------------------------------------------*/ X else if ( (charPtr = strchr (toAddress, '<')) != NULL) X { X strcpy (toAddress, (charPtr+1)); X charPtr = strchr (toAddress, '>'); X *charPtr = '\0'; X } X /*-------------------------------------------------------------------------+ X | Handle a plain-jane normal type address. | X +-------------------------------------------------------------------------*/ X else X *(toAddress + strlen (toAddress)-1) = '\0'; X X /*-------------------------------------------------------------------------+ X | Read in subject and eat the rest of the header lines. | X +-------------------------------------------------------------------------*/ X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X strcpy ( subject, (buffer1+9) ); X *(subject + strlen (subject)-1) = '\0'; X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X X /*-------------------------------------------------------------------------+ X | Main Loop Time! We read in each message until we hit the header of the | X | following message. Then we mail the message. | X +-------------------------------------------------------------------------*/ X while (!feof (infile)) X { X /*---------------------------------------------------------------------+ X | If the line starts with "From:" then we've hit the header of the | X | next message. | X +---------------------------------------------------------------------*/ X if ( (buffer1[0] == 'F') && (buffer1[1] == 'r') && X (buffer1[2] == 'o') && (buffer1[3] == 'm') ) X { X /*-----------------------------------------------------------------+ X | Close the temp file. Mail the current message and post a status | X | report to stdout. | X +-----------------------------------------------------------------*/ X fclose (outfile); X X sprintf (buffer1, "mailing \"%s\" to %s", subject, toAddress); X fprintf (stdout, "%s\n", buffer1); X X sprintf (buffer1, "mail -s \"%s\" %s < eudora.tmp", subject, X toAddress); X system (buffer1); X X /*-----------------------------------------------------------------+ X | Remove the temp file, create a new one and open it. | X +-----------------------------------------------------------------*/ X remove ("eudora.tmp"); X X if ( (outfile = fopen ("eudora.tmp", "w")) == NULL) X { X perror ("Error opening output file"); X exit (-1); X } X X /*-----------------------------------------------------------------+ X | Read in address. | X +-----------------------------------------------------------------*/ X fgets (buffer1, 119, infile); X strcpy ( toAddress, (buffer1+4)); X X /*-----------------------------------------------------------------+ X | Handle addresses of the form "username@domain (Real Name)" | X +-----------------------------------------------------------------*/ X if ( (charPtr = strchr (toAddress, '(')) != NULL) X *charPtr = '\0'; X X /*-----------------------------------------------------------------+ X | Handle addresses of the form "Real Name " | X +-----------------------------------------------------------------*/ X else if ( (charPtr = strchr (toAddress, '<')) != NULL) X { X strcpy (toAddress, (charPtr+1)); X charPtr = strchr (toAddress, '>'); X *charPtr = '\0'; X } X /*-----------------------------------------------------------------+ X | Handle a plain-jane normal type address. | X +-----------------------------------------------------------------*/ X else X *(toAddress + strlen (toAddress)-1) = '\0'; X X /*-----------------------------------------------------------------+ X | Read in Subject and eat rest of mail header lines. | X +-----------------------------------------------------------------*/ X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X X strcpy ( subject, (buffer1+9) ); X *(subject + strlen (subject)-1) = '\0'; X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X fgets (buffer1, 119, infile); X X } X X /*---------------------------------------------------------------------+ X | If the line starts with "~s", then we insert the signature here. | X +---------------------------------------------------------------------*/ X else if ( (buffer1[0] == '~') && (buffer1[1] == 's') ) X { X if (isSigfile) X { X if ( (sigfile = fopen (SIG_FILE, "r")) == NULL) X { X perror ("Error opening signature file"); X exit (-1); X } X X fgets (buffer1, 119, sigfile); X while (!feof (sigfile)) X { X fputs (buffer1, outfile); X fgets (buffer1, 119, sigfile); X } X fclose (sigfile); X } X } X X /*---------------------------------------------------------------------+ X | This is just a line in the mail message. Write it to the temp file. | X +---------------------------------------------------------------------*/ X else X fprintf (outfile, "%s", buffer1); X X fgets (buffer1, 119, infile); X X } X X /*-------------------------------------------------------------------------+ X | We've reache the end of the mail file. Close it and mail the last | X | message. | X +-------------------------------------------------------------------------*/ X fclose (outfile); X sprintf (buffer1, "mailing \"%s\" to %s", subject, toAddress); X fprintf (stdout, "%s\n", buffer1); X X sprintf (buffer1, "mail -s \"%s\" %s < eudora.tmp", subject, toAddress); X system (buffer1); X X remove ("eudora.tmp"); X X} END_OF_udora.c if test 11642 -ne `wc -c udora.readme <<'END_OF_udora.readme' XUsing Eudora As An Offline UNIX Mail Reader X Xby Ken Kirksey X(kkirksey@world.std.com) X X X XINTRODUCTION X X The first time I saw Eudora, I thought it was the neatest thing since X sliced bread. One of my friends worked for the academic computing X department at the university I was attending (Auburn U., for those who X care), and he had Eudora running on the Mac in his office. I though to X myself, "Now this is the way to read my Internet mail!" Unfortunately, I X found out that to use Eudora you had to have a TCP/IP connection to the X network (which my friend had) or access to a SLIP server (which we didn't X have). So, I resigned myself to using "mail." X X Then I graduated and moved, and all of the sudden I had to make a long X distance call to get my mail (New Horrors! New Horrors!). Needless to say, X interative reading with "mail" wouldn't cut it. So I took to compressing X and downloading my mail spool file so I could read all my mail offline. X A great idea, except that all I had was a raw spool file that I could X peruse with a text editor. Not very pretty. X X Then I remembered Eudora. As fate would have it, Eudora could read the X raw mail spool files. So I could read my message in a nice way. But X replying to messages, or sending new ones, was a pain. So I wrote a X little C program that automated the process. Now I was back up to speed. X X So here I am, sharing my experience and that program with ya'll (southern X for you all :) I've tried everything I'll cover in here, so it's all been X play-tested, so to speak. If you have any problems with the program, or X these instructions, feel free to drop me a note at kkirksey@world.std.com. X X Note that throughout this document "Eudora" refers to the Mac program, X while "udora" (unix Eudora) refers to the UNIX side program. X X XGETTING EUDORA X X The first thing you need to do is get a copy of Eudora. The program X itself is available at info-mac in the comm directory. This archive X doesn't include the documentation, however. You don't NEED the X documentation to get up and running with Eudora, but I highly recommend X getting it. The full Eudora release used to be available at X ux1.cso.uiuc.edu in the mac/eudora directory, but it's gone now. A quick X archie search told me that it was available at orion.oac.uci.edu in the X directory /ntslib/mac/mail/eudora.1.2/NTS.dist. If anyone out there X knows where Eudora's new official home is, please drop me a note and I'll X include it in a later version of these here docs. X X XSETTING UP EUDORA X X Once you've installed Eudora, you need to set it up so that it will work X using it as an offline reader. X X First go to the "Configuration..." option under the "Special" menu. Make X sure that the "Communications Toolbox" radio button is checked. If X "MacTCP" is checked, it will scream at you since you don't have MacTCP X installed. If you do, why are you reading this? :) X X Then go to the "Switches..." option under the "Special" menu. Under X "Composition:" make sure that the "Immediate Send" checkbox is NOT X checked. This lets you queue up outgoing messages. Under "When X Quitting:" make sure that "Compact Mailboxes" is checked. X X Composing and replying to messages is pretty straightforward. Consult X the Eudora documentation if you have any problems. I'd advise reading X through it in any event. X X XGETTING YOUR MAIL TO YOUR MAC X X Under UNIX, your mail is usually stored in the /usr/spool/mail directory X in a file that is named the same as your login. For instance, mine is X stored in /usr/spool/mail/kkirksey. You want to move this file out of X the /usr/spool/mail directory and on to your mac. Basically, here's what X you do: X X 1) Move the spool file to your home directory with X X mv /usr/spool/mail/ . X X You want to move it rather than copy it, because if you copy it, you X aren't removing the messages you read from the spool file. It'll just X keep growing, and growing, and growing.... X X If your mail isn't kept in /usr/spool/mail, check with your sysadmin X to see where it is located. X X 2) Transfer your mail file to your mac via your favorite file transfer X protocol. X X If your communication program supports scripting, you can write a short X script to automate this procedure. X X As an option, you may want to compress the file with the UNIX "compress" X command. This gives you a .Z file that you can uncompress on your Mac X using the MacCompress program (avaliable at info-mac). If you call long X distance to get your mail, this step will save you mucho $. X X XIMPORTING YOUR MAIL INTO EUDORA X X Now that you've got your mail to your mac, you've got two options. The X first is just to drop the file into the Eudora Folder in your System X Folder. Eudora can read it just like one of it's own files. There's a X problem with doing it this way. What if you haven't finished reading X all your messages in you spool file (kkirksey for me) ? Well, you could X give your new spool file another name (kkirksey1 for instance). But now X you've got a couple of mail files where you could have only one. X X A better solution (what I do) is to concatenate your new mail on to the "In" X file in the Eudora Folder. That way, all your mail is kept in one place, and X you don't have to worry about what you have and haven't read. t. I use X Unity (available on info-mac) to concatenate the files together. X X To read your mail, just select "In" from the "Mailbox" menu in Eudora. X Since you've modified the "In" file, it will ask you if you want to X create a new table of contents for that file. Tell it Ok. X X XSENDING NEW MESSAGES OR REPLIES X X First of all, you need to have a copy of the udora.c program in your UNIX X account. To compile the program, just type X X cc udora.c -o udora X X at the prompt. You can remove the udora.c file after you've compiled it. X X I'm assuming that you've read the Eudora docs and have already composed X some new messages or replies. All outgoing messages are stored in the X "Out" file in the Eudora Folder. Upload this file to your UNIX account. X Be sure that you have compacted the mailboxes before you do this. X Eudora inserts some redundant header information in the Out file that X seems to disappear when you compact your mailboxes. udora won't crash X if you don't do this, but you will get some strange messages. X X Once you've uploaded "Out" to your account, just type X X udora Out X X at the prompt to mail your messages. It's as simple as that. After X you've successfully mailed your outgoing messages, be sure to empty X the "Out" mailbox in Eudora so you don't send them again. X X If you quit Eudora while you have messages in the Out mailbox, it will X ask you if you want to send the messages now or just quit. Always click X "Just Quit." It will get very confused if you tell it to send them. X X XSIGNATURES X X Even if you chose the signature option in Eudora, it doesn't include it X with your message in the "Out" file, so it doesn't work for our X purposes. I've included a signature option in udora to make up for X this. Keep your signature in a file named ".signature" in your home X directory. If you want udora to append your signature to a message, X just put ~s on a line by itself at the end of a message. Don't put X any spaces in front of ~s, or udora won't recoginze it as a signature X command. X X XSOME THINGS WORK, SOME DON'T X X Another Eudora feature that doesn't work for our purposes. Eudora X attaches the files as it's sending the message via TCP/IP, so I doesn't X include the attached file in the "Out" file. I'm thinking about adding X a file attach feature to udora. X X The Eudora nicknames feature doesn't work either, since it doesn't X expand the nicknames in the Out file. This is another possible X enhancement to udora. X X udora currently doesn't recognize the cc: and bcc: lines in the header, X so you bcc and cc's will be ignored. Yet another possible new feature. X X If you want to see any or all of these features added to udora, drop me X a note. If there's enough interest, I'll probably do it. X XTIPS X X If you subscribe to bunches of internet digests like I do, and like to X save your messages to text files, go to the "Switches..." option under X the "Special" menu and make sure that "Guess Paragraphs" is NOT X checked. If it is, it will sometimes munge your documents when you save X them. X X XCOMMMENTS, BUG REPORTS, etc. X X All welcome. Tell me what you think of this doc and udora. Just drop X me a note at kkirksey@world.std.com. END_OF_udora.readme echo shar: Missing newline added to \"udora.readme\" if test 9124 -ne `wc -c