From: kevin@edscom.demon.co.uk (Kevin Broadey)
Subject: Re: BUG ALERT: sendmail.el - how to fix your Rmail FCC files
Organization: EDS-Scicon, Milton Keynes, UK
Distribution: gnu
Date: Fri, 4 Sep 1992 08:49:01 GMT

If anyone out there has a broken Rmail FCC file and is cursing me for
posting a crappy "fix", please accept my humblest appologies.  If it's
any consolation, my FCC file got knackered too.  This article describes
the steps I took to fix it.

If your file is still broken after you've tried this, mail me and I'll
do my best to help sort it out.

--Kevin


First, the history of the wretched thing so that we're both talking
about the same thing:-

1)  I noticed that FCC copies of messages sent using "sendmail" were
    getting lost if the FCC file was being visited in RMAIL mode (or any
    other mode for that matter).

    I traced the fault to `mail-do-fcc' in sendmail.el, which simply
    used `write-region' to append the message to the disk file
    regardless of whether it was being visited.

    I knew that GNUS didn't have the same problem so I checked how it
    did it.  This led to the first "sendmail.el" change that I posted in
    gnu.emacs.sources and gnu.emacs.gnus - "Improved FCC handling for
    sendmail" - on August 21st.

2)  As I started using sendmail FCCs more regularly, I noticed that
    there was nothing in the To/From field in the RMAIL-summary buffer
    and that the message header in the RMAIL buffer didn't have the
    "Date:" and "From:" fields that are present in normal mail.

    RMAIL-summary usually shows who a message is from, except that when
    it is from you, it shows who it is to.  I assumed that the To/From
    field was left blank because RMAIL-summary couldn't find a "From:"
    line, so I came up with my ill-fated fix of changing "sendmail.el"
    to insert "Date: ...\nFrom: user".  This was posted to gnu.emacs.bug
    - "sendmail.el - FCC output doesn't have "From:" header field" - on
    August 28th.

    It worked fine when I tested it.  Unfortunately I didn't realise
    that I was always visiting the FCC file when I tested, so I didn't
    spot the "unvisited file" problem.

3)  On September 2nd I realised that message FCCs weren't there when I
    read the FCC file using RMAIL.  After a fair amount of digging
    around I realised that my "fix" was causing the problem because new
    messages weren't being appended to the FCC file in UNIX mail format.
    I fixed my FCC file (eventually) and corrected my fix so that it did
    The Right Thing when the file wasn't being visited or wasn't in
    RMAIL mode.  I then started looking at my BABYL conversion routine,
    and realised that I could use RMAIL's own.  While I was looking
    through this i realised that the thing that was messing up the
    header conversion was the format of the date in the "From" line.

    I posted the fixed fix to gnu.emacs.bug and gnu.emacs.sources -
    "BUG ALERT: sendmail.el - FCC output doesn't have "From: " header
    field" - on September 2nd.


Strewth! That was a bit long! Anyway, I'm assuming you got screwed up
after applying the patch mentioned in (2) above, so here's what you've
got to do to recover your FCC file.

1)  Run RMAIL on the file and do `h' to view the summary buffer.  Note
    which message is the last one.

2)  Switch to the RMAIL buffer and do

	C-x w (widen)
	M-x fundamental-mode RET

to get you out of RMAIL mode so you can edit the raw file.

3)  Find the last message, as noted in (1). Go to the end of the message
    and, on a line on its own, insert ^_ (a single character, control
    underscore) - you can do this by typing C-q C-_.  Note that this
    character may already be there (Rmail puts one at the end of the
    file).  If it is there, *don't* put another one in.

4)  Move down the file looking for the start of each new message. They
    should begin something like:-

	Date: Thu Sep  3 17:47:05 1992
	From: me

    Change these 2 lines to be:-

	From me Thu Sep  3 17:47:05 BST 1992

    Remember to put the time zone in.

5)  Check for control characters (eg ^_) at the *end* of the file.
    Delete them.

6)  Save the file (C-x C-s) and kill the buffer (C-x k RET).

7)  Cross your fingers :-) and run RMAIL on the file.  It should convert
    all your missing messages into BABYL format and everything should be
    wonderful.

8)  Apply the corrected patch to your sendmail.el.

--
Kevin Broadey <kbroadey@edscom.demon.co.uk>
EDS-Scicon, Wavendon Tower, Wavendon, Milton Keynes, MK17 8LX, England.
Phone: +44 908 284198 (direct) or +44 908 585858 ext 4198
These opinions are mine: others available on request.

Newsgroups: gnu.emacs.bug