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

When fetchmail checks my IMAP inbox, it downloads any unread messages and removes the message 'unread' flag on the mail server.

Is there a way to have fetchmail download new messages without marking them as read?

I use procmail to automatically process new mail messages and run scripts based upon mail rules, so I want the messages downloaded, but would prefer it if the "new message" flag was preserved on messages I have not yet read in my e-mail client.

This is my .fetchmailrc file:

poll mail.domain.com protocol IMAP
    user "user@domain.com"
    password 'password'
    folder 'INBOX'
    mda "/usr/bin/procmail -f %F"
share|improve this question

I could not find a way to preserve or re-instate the 'unread' flag on the server.

In the end, I switched to using getmail, a more modern alternative to fetchmail that's written in Python. Unlike fetchmail, getmail retrieves messages based upon the server's message id rather than the message 'unread' flag.

This is the getmail configuration file I created that provided equivalence to my fetchmail configuration:

# ~/.getmail/getmailrc
# Configuration file to retrieve messages over secure IMAP
# and send them to procmail



share|improve this answer

My fetchmail(1) cites flags -k, --keep, and option keep to not download the messages.

fetchmail-6.3.22-1.fc18.x86_64, Fedora 18.

share|improve this answer
No, the keep flag is to prevent fetchmail from deleting the message from the server once it has been downloaded. Indeed, I am using the keep flag, as I want to keep the messages on the server. I'd just like to find a way to keep the "New message" flag too. – Steve HHH Mar 7 '13 at 23:08
And how will fetchmail (or anybody else) know that it already got the message? – vonbrand Mar 7 '13 at 23:11
By keeping track of the message id on the server, the same as an e-mail client would do. For example I would hope that fetchmail would know that it last downloaded message id 394, so if the next time it finds up to message 400, it should download messages 395-400, regardless of their 'unread' flag status. Downloading new messages based only upon the status of the 'unread' flag would be disappointingly simplistic for a tool with such a reputation as fetchmail. – Steve HHH Mar 7 '13 at 23:24
To keep track of the read/unread messages is precisely what the read/unread flag on the message is used for... – vonbrand Mar 7 '13 at 23:37
Indeed. And I'd like to use that flag if possible, so I can keep track of messages that I've read. The problem being that I can't do that any more because fetchmail marks all my messages as read. So what I'd love to be able to do is have fetchmail 'read' my mail without marking messages as read. Take for example, my phone and my desktop e-mail clients. They both 'read' my messages, and can indeed apply mail rules, but neither of them marks messages as read until I've viewed them. – Steve HHH Mar 7 '13 at 23:55

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.