Converting from Netscape Mail to Mutt

todd at mrball dot net

Last updated 02/10/03

Introduction

This document is intended to guide you in converting your existing Netscape Mail to Mutt. It is not simple. It will take an hour or so of steady typing if you are already familiar with the process. It will take quite a bit longer if you have to bounce back and forth between the various reference sources scattered about the internet. This document attempts to be as complete as possible, filling in holes that multiple other documents leave. When quoted from other sources, the full link to the source will be provided. Occassionally, you will see the bold CONCEPT indicating that the coming passage should probably be read more than once as it includes multiple important facts rolled into one.

The final authoritative answers to any question you might have should be obtained from the Mutt homepage or the mutt mailing list or your local mutt guru.

Requirements

  1. Mutt
  2. Fetchmail
  3. Procmail
  4. Written for Mandrake/RedHat based system. It is up to you to adjust for paths that might differ in your particular Linux distribution.

Sample Screen Shots

  1. Folder List (35KB)
  2. Messages in Folder (35KB)
  3. Read Message (30KB)
If you want to get the same color configuration as mine, I have links below to my config files that allow you to duplicate it.

Configure Fetchmail

  1. Quoting from the Fetchmail website: Fetchmail is a full-featured, robust, well-documented remote-mail retrieval and forwarding utility intended to be used over on-demand TCP/IP links (such as SLIP or PPP connections). It supports every remote-mail protocol now in use on the Internet: POP2, POP3, RPOP, APOP, KPOP, all flavors of IMAP, ETRN, and ODMR. It can even support IPv6 and IPSEC. Fetchmail retrieves mail from remote mail servers and forwards it via SMTP, so it can then be be read by normal mail user agents such as mutt, elm(1) or BSD Mail. It allows all your system MTA's filtering, forwarding, and aliasing facilities to work just as they would on normal mail.
  2. To make sure it's installed:
  3. The configuration is kept in a file named .fetchmailrc, which fetchmail expects to find in your home directory. The complete path is ~/.fetchmailrc. Use your favorite editor to create the file and put the following lines in it. Substitute the appropriate values for the arguments in italic.
  4. It is possible to configure this without using sendmail. I prefer to use sendmail due to the extra logging that it provides. This document will not discuss the method, but it can be found here if the link is still good.
  5. Set restrictive permissions on the .fetchmailrc:
  6. Start sendmail with Alternatively: Many systems have postfix instead of sendmail now. Run: If both of these commands fail, install whichever one you want (I use postfix with Mandrake and sendmail with others) with the following command: Now attempt to start it again.

  7. That's it for fetchmail!

Configure Procmail

  1. Quoting from the Procmail website: Procmail can be used to create mail-servers, mailing lists, sort your incoming mail into separate folders/files (real convenient when subscribing to one or more mailing lists or for prioritising your mail), preprocess your mail, start any programs upon mail arrival (e.g. to generate different chimes on your workstation for different types of mail) or selectively forward certain incoming mail automatically to someone.
  2. To make sure it's installed: If you have postfix or sendmail installed, you will certainly have procmail installed as both are configured by default to use procmail for local delivery, which means that to successfully install postfix or sendmail, it will have automatically installed procmail.
  3. The configuration is kept in a file named .procmailrc, which fetchmail expects to find in your home directory. The complete path is ~/.procmailrc. Use your favorite editor to create the file and put the following lines in it. Save the file, but we are going to add more to it in the next steps.
  4. If you get email that is sent simultaneously to you and to two other lists, this will nuke two of those so that you only see it once. Came from 'man procmail'. Append a blank line at the end of this section.
  5. I don't know why this is necessary. It was mentioned in a sample .procmailrc and is in the man page. Regenerate "From" lines to make sure they are valid. Append a blank line at the end of this section.
  6. The next step is the first step to duplicate the folder functionality present in Netscape. You create "recipes" that filter incoming emails and places them in the appropriate folder. You are duplicating the Edit->MessageFilters function in Netscape. As an example, I am subscribed the CerritosLUG mailing list. I filter this list's mail with a header that the Majordomo mailing list software inserts: My filter looks like: Append a blank line at the end of each section you create here.
    CONCEPT: The first line does a few things. A colon, a zero, and a colon. When written with this trailing colon, the system automatically handles message folder locking in the unlikely instance that more than one copy of procmail is running and each is delivering different messages to the same folder. The second line is where the pattern matching actually occurs. Procmail uses standard regular expressions for its pattern matching. The asterisk goes at the beginning of the line followed by a space. The caret indicates that the first thing that must exist is the "beginning of line", and is followed by the letters "X-BeenThere". Next is a period-asterisk combo that indicates that any number of characters up to the end of the line can occupy some space, including zero characters. The next text pattern that gets matched is "cerritoslug@". If you look at the bold line I quoted above that it is looking for, you can see the pattern matching steps. You must customize the pattern for your list's headers. Not all mailing lists are configured the same. The third line is the actual filename that procmail will put the email into. Case is important, so get it right. I converted all spaces to underscores and renamed all the old Netscape folders. It's up to you. The added complexity of quoting everything with spaces just didn't appeal to me.
  7. Repeat the above step for each folder that exists in Netscape. Do not make one for Drafts, Templates, Unsent, and Deleted. I actually deleted each of these. If you have mails you want to keep in any of these, do not delete them.
  8. Finally, add this last line to catch all remaining email that didn't go to a folder and put them in the Inbox folder.
  9. Save the file.
  10. This is required or procmail won't deliver your mail to your defined directory (it will only go to /var/spool/mail/{username}). Set restrictive permissions on the .procmailrc:
  11. If you would like to see a working procmail config file, you can download my procmailrc to either compare to yours, or use as a reference to build on.
  12. The last comment that I'll make about procmail is that there seems to be a maximum mailbox size of about 48 Megabytes. I don't know why nor can I find any documentation to that effect nor have I looked at the code. I just know that it will start bouncing messages when a mailbox gets above 48 Megs.


  13. That's it for procmail!

Configure Mutt

  1. Quoting from the Mutt website: Mutt is a small but very powerful text-based mail client for Unix operating systems.
  2. To make sure it's installed:
  3. Go to the muttrc builder site and create a generic muttrc. At the time of this writing, all this required was clicking the "muttrc builder" button on the main page, then clicking the "download .muttrc" button. Save it to your home directory.
  4. You can also just download my .muttrc if you would like to see a working config.
  5. Mutt is very strong in regards to its ability to handle messages that are signed and/or encrypted using PGP keys and the open source program gnupg. If you wish to see a functioning configuration, you can download my gpg.muttrc and simply include it in your muttrc, just like I did in my config file, linked above.
  6. All commands are assumed that you are in your home directory. If you are not, modify the paths appropriately. The downloaded muttrc will be called mrcb.muttrc--just rename it to .muttrc:
  7. Remove all mail configuration options from Netscape (Edit->Preferences). Exit Netscape. Make sure that you do not have any of Netscape Browser, Netscape Composer, or Netscape Mail open.
  8. In your home directory, rename nsmail to Mail and delete anything unused:
  9. Next, open the .muttrc with your favorite editor. When modifying lines, you must uncomment them by removing the "#" sign from the front of the line. Otherwise, your modifications will have no effect.
  10. First modify the "set realname" and "set hostname" entries. I would advise using your real name and the domain that your mail comes from. As an example, mail from me appears from mrball.net even though the actual machine that it comes from arm.mrball.net. So my entry for hostname looks like: Note that I do not have quotes around mrball.net. It's optional. If you feel like being technically correct, leave the quotes around the actual argument.
  11. Under "General Mutt Options," modify the timeout setting and set it to 60 seconds. This tells mutt to check for new mail every 60 seconds. CONCEPT: Mutt is really only looking at the timestamp of the local files. Procmail was configured above to get mail from your mail server every 120 seconds.
  12. Under "OS Specific Options," modify the spoolfile setting to point to our new default Inbox configured in .procmailrc. Normally it would be /var/spool/mail/$USER but we want it to be /home/$USER/Mail/Inbox.
  13. Under "Menu Index", set the following option to not mark New messages as Old if you decide the leave the mailbox before reading all the new messages:
  14. Under "Internal Pager," modify the pager index to 8 lines and the pager stop to yes. By default, mutt will show a message that you select with the entire screen. The pager index lines allocates the number of lines you set to show the message listing at the top of the screen. To see this, a good pager screenshot exists on the mutt website. Mutt also by default will move to the next message when you PageDn past the end of the file. I find this annoying, so I disable it by setting pager stop to yes.
  15. Under "Composing," set the editor to use vi and set the auto-wrap to 72 characters. If you wish to use [insert favorite] editor, modify the parameter for your needs. If you want to use something like Midnight Commander's editor, you would use "mcedit" instead. I also run a special program named makesig.pl which parses a file or multiple files, each containing multiple signatures seperated by a blank line and randomly selects one of them. In mutt, if you put a pipe "|" symbol at the end of a variable setting, mutt runs that command and uses whatever output it provides. For this to work, you will need to 'urpmi makesig.pl' which installs the makesig.pl package.
  16. Under "Replying," set include to yes. This tells mutt to automatically quote the message that you are replying to. You can leave it alone if you want it to always ask you. I found that annoying too.
  17. Under "Folder and Mailbox," set the folder location, set the browser to sort by reverse date and set mutt to keep a copy of all emails that you send. Setting folder to "~/Mail" tells mutt where to find your mailboxes. Sorting due to reverse date is mostly useful for viewing which folders have received new mail most recently. The sort behavior within the message folders is adjusted in a step further down. Set the folder that mutt is to save a copy of sent email and enable mutt to save the copy with the set copy parameter. CONCEPT: The folder is set to "+Sent". The + sign expands to the full path defined in the "set folder" command just above it. For this reason, it is IMPORTANT that the "set folder" command exist before any assumed file paths are encountered. I moved the "set folder" line to be the very first line in the "Folder and Mailbox" section. Also, just as in the procmail configuration, capitalization is important. If the file is named "Sent", then you cannot use sent or SENT. It has to match exactly.
  18. In the "Headers" section, set it so that you can edit some of the important headers:
  19. Under "Sendmail," you set sendmail to the location of your sendmail binary. If you have sendmail installed from rpm, you will leave it alone as the rpm installs it at /usr/lib/sendmail. If you have sendmail installed from source, you should modify it to /usr/sbin/sendmail.
  20. Add the following commands to the end. The first sets mutt to display messages in all folders in threaded mode. The period is interpreted as all folders. The second sets the Sent mail folder to display the messages sorted by reverse date (newest to oldest). The next two lines are for proper handling of attachments (in my opinion). The next two lines are for using T and G to go to the top and bottom of the message when you're viewing it.
  21. Add the mailboxes that you defined previously in .procmailrc. As with procmail, capitalization is important. You can specify multiple mailboxes on one line and can have multiple lines specifying mailboxes. The + sign expands the folder path, same as above. The following are examples. You want at the very least to define the Inbox.
  22. Move back up to the top of the .muttrc file and add the following lines. You can download the .color.muttrc that I use. Rename it to .color.muttrc on your local machine. The .aliases.muttrc file will contain entries similar to the following: The alias allows me to type "cerr" at the To: prompt and mutt will automatically expand it to the full address "cerritoslug@cerritoslug.org".
  23. Save the .muttrc.
  24. Create or add to a ~/.mailcap file the following line:
  25. Create or use the .color.muttrc that is specified above. If you are using mutt inside an X term, you'll probably want to set the default term colors to White on Black so that the color file displays properly. In KDE 1.x, this is done with Options->Schema->WhiteOnBlack. One of mutt's features is its flexibility and configurability. Feel free to experiment!
  26. Create a .aliases.muttrc file with your entries.
  27. Add the following line to the end of your .bashrc. It creates an alias for mutt that automatically calls fetchmail, starts mutt, then kills fetchmail when you exit mutt. CONCEPT: This alias is four separate commands. The first thing it does is fetch all the messages from your mail server, but doesn't let fetchmail daemonize itself. This allows you to see all the messages that come in (sometimes knowing how many emails have arrived is important). The next command starts fetchmail in daemon mode, which checks for new mail every 120 seconds (set in the .fetchmailrc above). The next command actually starts mutt. The final command kills the fetchmail daemon when you exit mutt. When you exit, it will tell you that it killed the fetchmail daemon. This is normal.
  28. Addendum: I no longer do it that way. I now set fetchmail to daemonize with: Then at the end of my ~/.bash_profile, I have: This makes it so that all I have to do is login and it will automatically start fetchmail for me if it's not running.
  29. Test your fetchmail configuration by running: The -d0 keeps fetchmail from going into daemon mode. The main goal of this test is to see if fetchmail can communicate with your imap server and download new email.
  30. Either source the file ~/.bash_profile or logout and log back in to have the changes to the environment take effect and fetchmail automatically start.
  31. Test mutt for configuration errors by running: If it reports no errors, that's a very good thing. Yes, I know we specifically did not run the mutt alias that we created in .bashrc. The main goal of this test is to see if mutt complains about the config file.
  32. Now just run "mutt" to test the alias. It should be working properly.

Using Mutt

  1. For online documentation press F1 in RedHat. In Mandrake, look at /usr/share/doc/mutt-{version}/manual.txt.
  2. Press c to "change" folders. If there is any new mail, it will put the name of the first folder that has new mail. (If there is no new mail, it will say "Press ? to see folder list".) Press Enter. Alternately, you can press TAB to get a full folder list. Any folders with new messages will have a capital "N" on the left hand side of the screen. Pressing TAB again will give you the raw file list.
  3. Assuming you entered a folder, mutt will highlight the first new message in that folder. Press TAB to go to the next new message. Pressing Enter will scroll down one line at a time. BackSpace is supposed to go up one line at a time, but it might not work properly if you are running in an X term of some sort. You can press PgUp and PgDn to move up or down in the message body one page at a time.
  4. To write a new email, press m. To reply to the author only, press the r key. To reply to the mailing list, press L.
  5. For further information, press ?.

Check back regularly for additions. The last addition was some additional settings to make it more user friendly.

Blue skies................................Todd