6

I would like to retrieve mail from a server using fetchmail and have it deposit it directly into an mailbox/repository and not hand it off to a mda. Is this possible? How?

In the alternate, is there an mda which simply recieves things from er fetchamil and stores them in some sort of repository without doing any processing?

HandyGandy
  • 2,201
  • 3
  • 23
  • 30

2 Answers2

4

Use the mda option in your .fetchmailrc to specify maildrop or procmail as your MDA.

mda "/usr/bin/maildrop"

This will deposit the mail in the system mailbox (typically /var/spool/mail/handygandy or /var/mail/handygandy). If you want it elsewhere, or if you want to dispatch the mails based on their content, write a ~/.mailfilter file.

to mail/fetched
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
3

Since mda is just a program read the whole email from stdin and write it to somewhere, you can write the simplest mda in bash:

mda "/bin/sh -c 'cat > INBOX/new/$(date +%''s_%N)'"

The tricky single quote is a work-around to avoid "%s", because fetchmail will replace "%s" with the current user name: Encode literal percent in fetchmail's mda option

heiz
  • 1,803
  • 2
  • 12
  • 7
  • I just tried it with only `cat` and it worked as well: `cat >> somefile`. I guess that means `/bin/sh` is optional. – EdwardTeach Dec 29 '21 at 20:00