I like to detect unreaded mails in Maildir mailboxes. The subfolder "new" only content mails that are not already pulled from an MUA. But I want the unreaded mails within INBOX (no virtual subdirs). Any suggestions how this can be implemented?

PS: I do not enter the raw mail!

Using Debian Squeeze with Postfix and Dovecot (POP, IMAP).

  • What is the purpose of this? A script to report something? The way you asked the question, I could just answer: Use Thunderbird, it will display all unread mails in the Inbox.
    – Sven
    Dec 28, 2011 at 17:31
  • The purpose is to show logged on control panel users how many unread messages they have. And I have not the option to connect via imap... only via Maildir.
    – burnersk
    Dec 28, 2011 at 18:04
  • I am quite certain that the IMAP library of the language you use for your control panel will have support for this kind of task, but I consider that a topic for StackOverflow.
    – Sven
    Dec 28, 2011 at 18:06
  • don't force all down to script... when the server is not listen on and firewall blocks soliloquy I can not connect via imap even if perl has an imap interface. I have to find a way with Maildir. Many programmers before me have tried expect Maildir.
    – burnersk
    Dec 28, 2011 at 18:12

1 Answer 1


You use Dovecot, so each file in the maildir folder that has :2,S near the end of the file name means it has been flagged as "Seen" or "Read".

More useful info about Maildir formats:



An example file name from my Maildir: 1324304849.M312689P14620.subdomain.domain,S=24816,W=25415:2,Sa

  • Obviously the above sets you on the right path, you may want to check with the stackoverflow guys for syntax examples for various languages. Perl, Python or Bash would probably be appropriate, just my opinion.
    – Tim
    Dec 28, 2011 at 18:14
  • 3
    Haha find . -type f | grep -E ',[^,]*S[^,]*$' finds all readed and find . -type f | grep -vE ',[^,]*S[^,]*$' find all unreaded. I use shell commands...
    – burnersk
    Dec 28, 2011 at 18:23
  • Awesome, glad it is working out for you :)
    – Tim
    Dec 28, 2011 at 18:31

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.