Agent Mail Sorter
I just wanted to try writing an agent once, okay?
It takes in your IMAP credentials, mirrors the IMAP folders into memory and then tells the LLM to sort the mails into (new) folders from the Inbox. The agent cannot modify your real Inbox and only ever acts on the in-memory clone.
Usage
Install the dependencies using uv: uv sync. Then you can run
uv run imap-sorter to run the agent. Use -h for the list of parameters the script
takes:
-h, --help show this help message and exit
--username USERNAME IMAP username
--password PASSWORD IMAP password
--host, -H HOST IMAP host
--port, -P PORT IMAP port
--data, -d DATA Instead of querying the IMAP server, use this JSON file
--output, -o OUTPUT Dump the agent's operations into this JSON file
--url, -u URL URL to an OpenAI-compatible inference endpoint
--api-key API_KEY API key to use with the OpenAI-compatible endpoint
--model MODEL Model name to use
Important to note that if you want preview what the agent has done afterwards, specify
--output to output the operations the agent performed into a JSON file. You can then
use uv run imap-sorter-preview to preview how the server would look like after the agent's
operations. This requires the data.json file that logging into the IMAP server will create.
License
Written by a human :)
Licensed under MIT. See LICENSE.md.