Can fetchmail write to file?

2.2k Views Asked by At

During testing of a new server I need to test the fetchmail functionality but I can't get it to work the way I expect it to. How can I send the fetched email either to a specified file or to stdout?

My /etc/fetchmailrc looks something like this:

set syslog

set daemon 10

# TEST
poll mail.example.com proto imap
  user "ulf" password "testpassword" idle
  ssl
  folder "INBOX/test_2016-10-24"
  keep
  mda "tee /tmp/fetch_test"

I then run fetchmail like:

$ sudo fetchmail -vk -f /etc/fetchmailrc

or (as suggested here):

$ sudo fetchmail -vk -m cat -f /etc/fetchmailrc

I have also tried this (Write retrieved emails in a file) without success.

There is one mail in the specified folder and when I run any of the commands above a lot of data is produced in /var/log/syslog before it halts. The last 3 lines indicates that there is one message found but then?

...
Oct 25 15:16:25 example fetchmail[7271]: 1 message (1 seen) for ulf at mail.example.com (folder INBOX/test_2016-10-24).
Oct 25 15:16:25 example fetchmail[7271]: IMAP> A0005 IDLE
Oct 25 15:16:25 example fetchmail[7271]: IMAP< + idling
1

There are 1 best solutions below

0
On

Seems my error is obvious if you think about it or read the output:

...
Oct 25 15:16:25 example fetchmail[7271]: 1 message (1 seen) ...
...

1 seen is the key here. Only mails marked as unread in the mailbox will be fetched. Mails that has already been read or seen will not be fetched.