I’m playing with Stalwart in order to evaluate if it fits as a replacement for my aging mailserver (Courier-mta + Courier-imap).
I prefer doing as much as possible directly from the shell, and I assume stalwart-cli is the right tool for the job.
With my current Courier setup, viewing an email message is as simple as using cat on the corresponding file in the maildir. How can I accomplish something similar in Stalwart to view an email message in the terminal (either just the plain text body or the raw message)?
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
stalwart-cli only manages configuration objects (the x: types), so it cannot read mail, and there is no maildir to cat either: message bodies live in the blob store, content-addressed under hashed paths and optionally LZ4-compressed, so the files on disk are neither named nor readable per message.
The direct equivalent of your Courier workflow is a terminal MUA over IMAP. mutt, neomutt, aerc, alpine and himalaya all work against Stalwart like any other IMAP server. For actual shell scripting, Email/query plus Email/get gives you a blobId, and GET /jmap/download/{accountId}/{blobId}/{name}?accept=message/rfc822 with a bearer token writes the raw message to stdout.
I need actual shell scripting solution. I’ve tried to follow your hints, but my bash scirpt, while it seems to work (no error messages), it does not show any email messages.
I suspect the problem is that I’m using admin credentials to obtain the bearer token, but then I try to read messages of a different user.
Can you confirm that should be possible? (since that would be the direct equivalent of my Courier workflow).