Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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'
    keep
    ssl
    mda "/usr/bin/procmail -f %F"
share|improve this question

2 Answers 2

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

[retriever]
type=SimpleIMAPSSLRetriever
server=mail.domain.com
username=user@domain.com
password=password

[destination]
type=MDA_external
path=/usr/bin/procmail

[options]
verbose=0
read_all=false
delete=false
delete_after=0
delete_bigger_than=0
max_bytes_per_session=0
max_message_size=0
max_messages_per_session=0
delivered_to=false
received=false
message_log=~/getmail.log
message_log_syslog=false
message_log_verbose=true
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
2  
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

 
discard

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.