Converting emacs RMAIL to mbox format

Converting emacs RMAIL to mbox format

/usr/local/bin/mm can be used to read and write several mail formats among which are babyl (which emacs RMAIL uses) and mbox (which virtually everybody understands). Unfortunately, emacs puts a mode notation on the first line of the rmail file it writes, making it unintelligible to mm. awk can be used to fix that:
    awk '{if(NR==1){printf "%s","BABYL OPTIONS:"}else{printf "\n%s",$0}}' < emacs-RMAIL.filename > fixed.babyl.filename
Then mm can be used to convert the result to mbox format:
    % mm get fixed.babyl.filename
    Columbia MM, Rutgers version 1.5(0)
    Please report any bugs using MM's BUG command, or send mail to BUG-MM.
    Suggestions are also welcome.
    x message read
    MM>set default-mail-type mbox
    MM>move mbox.filename all
    File does not exist: mbox.filename
    Do you want to create it? yes
     1:x
    MM>exit
    Expunging deleted messages.
    All messages deleted, deleting file...OK
    %
Clues: Some people have found the above file notation confusing. Here is some discussion:
You can also do this with the command
    % formail -B -s < emacs-RMAIL.filename > mbox.filename
on aramis or any other machine that has procmail installed.
And emacs now has an "M-x unrmail" and comes with a b2m program to do the right thing.
This page last updated July 6, 2007. (bad link removed; 1/17/10)