Skip Navigation

Collecting mail

Mutt doesn't want to collect your mail

In an ideal world, all your email arrives automatically at the machine that you use to read your mail - you just open up your mailspool and find it there. If this is the case for you, then you don't need to read this page.

The rest of us are in the situation where the final destination of our email is some pop3 or imap mailserver hosted by somebody else. What we need to do is retrieve that mail, deliver it locally and then delete it from the remote server.

You could do this in mutt, and many people have tried with some success using mutt's pop3/imap capabilities and a bunch of folder hooks. However doing this is hard and not very satisfactory - what you need is a separate program to manage this process for you.

fetchmail

Fetchmail is purpose designed to do nothing but connect to a series of remote mailservers specified in a configuration file, download all the mail and deliver it locally to the smtp port on the localhost.

You quite likely have fetchmail installed already, check by typing this command in your shell:

whereis fetchmail

If fetchmail is installed, then you need to configure the program by creating a ~/.fetchmailrc file. See the fetchmail FAQ and the fetchmail manual for details on setting this up.

A requirement of fetchmail is that the machine running fetchmail has to have a smtp server listening on localhost. You can check if you are running a local smtp server by using the telnet program to try to connect to the smtp port, type this command:

telnet localhost 25

You should get a 220 response indicating the service is ready. Type quit to cancel the session.

If there is no local smtp server, you may be able to hand mail directly to a Mail Delivery Agent (MDA) such as procmail with an additional mda procmail command in your ~/.fetchmailrc file.

To call fetchmail from within mutt, you need to add a macro to your ~/.muttrc file. A macro is a series of commands bound to a key or word like this:

macro generic G \
<shell-escape>'fetchmail'<enter> \
'Run fetchmail'

This macro applies to the generic view, the key it is bound to is G (shift and g), the description that appears in the help menu is Run fetchmail and the command that is executed is equivalent to typing !fetchmail in mutt and hitting enter.

getmail

Fetchmail can transfer mail from practically every kind of remote mail store, however buggy that remote server may be.

Fetchmail's size and method of taking mail that has already been delivered and re-rerouting it via smtp, is the reason many people use the alternative getmail program. See the getmail documentation for details on setting this up.

UUCP and ETRN

The preferred method of collecting mail if direct SMTP or SMTP with ETRN is not available, is to use UUCP. This has advantages over pop3 or imap for this particular job. See the UUCP Howto if this option is available to you.

<< | Up | >>

This document was last modified on 2005-08-17 00:39:38.
Bruno Postle
Copyright © 2001 Bruno Postle and others. This guide is released under the Free Documentation License. http://www.gnu.org/licenses/fdl.txt