3

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.

5

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).

/home/handygandy/mail/incoming

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

DEFAULT=$HOME/mail/incoming

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

DEFAULT=$HOME/mail/incoming

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

  • 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 'SO- stop being evil' 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
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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