# imapctl
Scriptable IMAP client for the shell.
Where it makes sense, commands read their input from `stdin` making it possible
to compose commands with pipes.
## Installation
### Nix flakes
Nix can take care of the toolchains for you ;)
```sh
nix run git+https://seed.radicle.garden/zjy7BiSYaEFtM9ohHwSfJGbyPQKp.git
# and building ofc
nix build git+https://seed.radicle.garden/zjy7BiSYaEFtM9ohHwSfJGbyPQKp.git
```
### Docker
```sh
nix build '#docker'
docker load < result
# To run:
docker run -ti imapctl
```
## Usage
Use `imapctl --help` for more help.
### Examples
#### Authenticate using environmental variables
```sh
export IMAPCTL_HOST=imap.example.com
export IMAPCTL_USERNAME=you@example.com
export IMAPCTL_PASSWD_CMD="pass show hosts/imap.example.com/you@example.com"
```
The other examples will assume these environmental variables to be set.
Alternatively, you can pass the `--host`, `--username` and `--passwd-cmd`
parameters.
#### List ID's for all messages in the *INBOX* mailbox
```sh
imapctl search all
```
#### List ID's for all messages in the *bla* mailbox
```sh
imapctl search --mailbox bla all
```
#### List *From* and *Subject* for all message in the *bla* mailbox
```sh
#### List *Date*, *From* and *Subject* for the *INBOX*
```sh
#### Copy/Sync messages from one mailbox (*INBOX*) to another (*bla*)
```sh
for msg in $(imapctl search all); do
(imapctl fetch $msg --format '{{body}}' |imapctl append --mailbox bla)
done
```