Tools to get a report of which folders have new mail?
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
Are you using maildrop or flat files In your config? If you are using maildrop where there is a file for each file then you could use free into the folder new but I do not know what config you have check tre command and see if that does some of what you want.
Il giorno 18 lug 2022, alle ore 20:20, Steve Litt <slitt@troubleshooters.com> ha scritto:
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
Remo Mattei said on Mon, 18 Jul 2022 20:51:16 -0700
Are you using maildrop or flat files In your config?
Thanks Remo,
If by "maildrop" you mean "maildir", I'm using maildir. Otherwise, I don't know what maildrop is.
If you are using maildrop where there is a file for each file then you could use free into the folder new
My Dovecot setup uses maildir and there's definitely one file per message. When I type "free" at my Linux command line it just lists statistics about memory. The doveadm man page doesn't list a command called "free". So I'm not sure what "free into the new folder" means.
but I do not know what config you have check tre command and see if that does some of what you want.
Thanks,
SteveT
Il giorno 18 lug 2022, alle ore 20:20, Steve Litt <slitt@troubleshooters.com> ha scritto:
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
Yes sorry maildir maildrop is something for rules using in qmail.
Remo
On Jul 18, 2022, at 9:01 PM, Steve Litt <slitt@troubleshooters.com> wrote:
Remo Mattei said on Mon, 18 Jul 2022 20:51:16 -0700
Are you using maildrop or flat files In your config?
Thanks Remo,
If by "maildrop" you mean "maildir", I'm using maildir. Otherwise, I don't know what maildrop is.
If you are using maildrop where there is a file for each file then you could use free into the folder new
My Dovecot setup uses maildir and there's definitely one file per message. When I type "free" at my Linux command line it just lists statistics about memory. The doveadm man page doesn't list a command called "free". So I'm not sure what "free into the new folder" means.
but I do not know what config you have check tre command and see if that does some of what you want.
Thanks,
SteveT
Il giorno 18 lug 2022, alle ore 20:20, Steve Litt <slitt@troubleshooters.com> ha scritto:
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
On 19/07/22 3:18 pm, Steve Litt wrote:
Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy?
See doveadm(1) and doveadm-mailbox(1), specifically the doveadm mailbox list
command.
Also, is there a way to show only those with new mail?
Look at doveadm-search(1) and doveadm-search-query(7) for this.
You can loop through the list of mailboxes from doveadm mailbox list and
pass them one at a time to doveadm search NEW MAILBOX mailboxname
to
see if any messages are returned from the search.
Peter
On Tue, 2022-07-19 at 16:33 +1200, Peter wrote:
On 19/07/22 3:18 pm, Steve Litt wrote:
Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy?
See doveadm(1) and doveadm-mailbox(1), specifically the
doveadm mailbox list
command.Also, is there a way to show only those with new mail?
Look at doveadm-search(1) and doveadm-search-query(7) for this.
You can loop through the list of mailboxes from doveadm mailbox list and pass them one at a time to
doveadm search NEW MAILBOX mailboxname
to see if any messages are returned from the search.
Thanks Peter. I'll look into everything you mentioned in the next few days.
SteveT
"Peter" == Peter <peter@pajamian.dhs.org> writes:
Peter> On 19/07/22 3:18 pm, Steve Litt wrote:
Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy?
Peter> See doveadm(1) and doveadm-mailbox(1), specifically the doveadm mailbox Peter> list
command.
Also, is there a way to show only those with new mail?
Peter> Look at doveadm-search(1) and doveadm-search-query(7) for this.
Peter> You can loop through the list of mailboxes from doveadm mailbox
Peter> list and pass them one at a time to doveadm search NEW MAILBOX Peter> mailboxname
to see if any messages are returned from the
Peter> search.
You will run into problems if you use an iPhone to also access your mail via IMAP as well, for some reason it marks all new email as SEEN, even if they haven't been opened. It's .... annoying to say the least. It's an iPhone issue from what I see. The archives will have more on this from three or four years ago when I last beat my head against this.
Maybe it's time to fine a new iPhone mail client now that you can get rid of the default iOS mail client if you like.
On 19/07/2022 06:18 EEST Steve Litt <slitt@troubleshooters.com> wrote:
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
doveadm -fjson mailbox status -u user unseen "*"
Aki
On Tue, 2022-07-19 at 09:19 +0300, Aki Tuomi wrote:
On 19/07/2022 06:18 EEST Steve Litt <slitt@troubleshooters.com> wrote:
Hi all,
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
Thanks,
SteveT
Steve Litt Summer 2022 featured book: Thriving in Tough Times http://www.troubleshooters.com/bookstore/thrive.htm
doveadm -fjson mailbox status -u user unseen "*"
Very nice Aki! I can pass that JSON to a Python program I make to parse JSON, and then just report the ones not having "unseen":"0" . Thank you!
SteveT
On Tue, 2022-07-19 at 09:19 +0300, Aki Tuomi wrote:
doveadm -fjson mailbox status -u user unseen "*"
As promised, the following is the Python 3 script to take advantage of your command by printing out the mailbox name and number of unseen for each folder that has some unseen messages:
=========================================== #!/usr/bin/python3
import json; import subprocess;
def main(): cmd='doveadm -fjson mailbox status -u slitt unseen "*"' sp=subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE) rc=sp.wait() print('\n\n\n\n') jstrng,junk=sp.communicate() jsn=json.loads(jstrng) newboxes={} for rec in jsn: if rec['unseen'] != "0": unseen=rec['unseen'] mailbox=rec['mailbox'] newboxes[mailbox] = unseen for key in sorted(newboxes.keys(), key=str.lower): print("{}: {} unread.".format(key, newboxes[key]))
if __name__ == '__main__': main()
My 20 minutes of testing indicate this is not always accurate and must not be relied on without backup methods, but I'm going to be using it until I find something better.
Thanks,
Steve
On 2022-07-18 11:18 p.m., Steve Litt wrote:
I use a Dovecot IMAP server on my Linux desktop computer, and I'm pretty good at writing shellscripts. Is there any way I could use doveadm or other tools to create a report that shows all my folders in a hierarchy? Also, is there a way to show only those with new mail?
you could use "doveadm mailbox list" to build the list of folders and "doveadm search" to search each folder for appropriate IMAP flags https://wiki2.dovecot.org/Tools/Doveadm/SearchQuery
e.g. doveadm mailbox list -u username | sort doveadm search -u username mailbox foldername UNSEEN (or NEW instead of UNSEEN)
participants (7)
-
Aki Tuomi
-
John Stoffel
-
Oscar del Rio
-
Peter
-
Remo Mattei
-
Remo Mattei
-
Steve Litt