Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm setting up a system calling fetchmail from the commandline and specifying that the mail be stored in a specific file which is not /var/spool/mail/$USERNAME.

share|improve this question
up vote 2 down vote accepted

By default, fetchmail invokes the local mail transfer agent (MTA). That's the program you need to configure to set the location of users's mailbox. If you want to change the place where a specific user's mail is delivered, most MTAs read the file called .forward in your home directory. You can put a different path in your own ~/.forward file (just one line containing the full path of the mailbox file where you want your mail to be delivered).


You can also write |someprogram in your ~/.forward file to invoke a mail delivery agent (MDA), i.e. a program that reads the mail and determines what to do with it based on custom rules. Two popular MDAs are procmail and maildrop.

If you're only receiving mail through fetchmail, rather than go through the local MTA, you can tell fetchmail to invoke an MDA directly. Pass the -m option on the command line or use the mda setting in ~/.fetchmailrc. For example, one way to deliver mail directly to ~/mail/incoming is to put mda procmail in ~/.fetchmailrc, and have a ~/.procmailrc consisting of


Or put mda maildrop in ~/.fetchmailrc and have a ~/.mailfilter consisting of


(The resemblance between procmail and maildrop configuration files doesn't go much further.)

share|improve this answer
That would be fine, except strace -f doesn't show fetchmail creating any subprocesses. – HandyGandy Nov 10 '11 at 4:37
@HandyGandy Fetchmail would only create a subprocess if you tell it to invoke an MDA. If it's talking to an MTA, the MTA is a daemon reached over a local TCP socket. – Gilles Nov 10 '11 at 10:03
Yes. Sorry. Just after I hit return,I realised so and check /etc/rc* to find exim4. – HandyGandy Nov 11 '11 at 3:14

IIRC fetchmail doesn't write to mailboxes - by default it uses SMTP on localhost or the configured SMTP server or the configured MDA.

I assume you've not got an MTA configured since you're asking about file locations. But that you're using a non-standard location for the mailfile implies that you've already got an MDA configred - just use that. See the fetchmail man page for specifics.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.