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