Your question
How can I use stalwart-cli to write a script that shows me the size of each user’s mailbox?
Now let’s check the query command doc for syntax examples.
Now I have enough to answer well.
Each Account object exposes a server-set usedDiskQuota field (in bytes), so you can query all User accounts and pull that field with stalwart-cli query:
stalwart-cli query account --fields name,emailAddress,usedDiskQuota --json \
| jq -r '[.emailAddress, .usedDiskQuota] | @tsv'
This streams one JSON line per account (NDJSON), so it works fine even with many users. If you’d rather have a human-readable table, drop --json:
stalwart-cli query account --fields name,emailAddress,usedDiskQuota
You can also filter, e.g. only accounts over a certain size:
stalwart-cli query account --where usedDiskQuota>=1000000000 --fields emailAddress,usedDiskQuota
Reference: Account object (see the usedDiskQuota field) and Searching and listing with the CLI.
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.
{
printf “%-35s | %18s\n” “E-Mail” “Größe”
printf – “-----------------------------------±-------------------\n”
scli query account --fields emailAddress,usedDiskQuota --json
| jq -r ‘[.emailAddress, .usedDiskQuota] | @tsv’
| while IFS=$‘\t’ read -r mail bytes; do
printf “%-35s | %18s\n” “$mail” “$(awk “BEGIN { printf “%.3f MB”, $bytes / 1024 / 1024 }”)”
done
}