Read and reply to webmail from a persistent headful browser via CDP — with an OCR fallback for messages that render in opaque containers.
Built for a Discord-bridge assistant that needed to check a Zoho Mail inbox and send replies entirely through browser automation. Works against any webmail that exposes a standard message list + compose UI; the selectors here target the Zoho Mail layout.
- Node.js 18+ with
playwrightinstalled (npm i playwright) - A persistent Chromium with remote debugging on
127.0.0.1:9333(start withchromium --remote-debugging-port=9333 --user-data-dir=<profile>) tesseract+tesseract-data-engon PATH for the OCR fallback
node email.mjs list [count] # latest N inbox messages
node email.mjs read <n|"subject match"> # open a message, print its body
node email.mjs reply <n|"subject match"> "<body>" # reply and sendThe script connects to the always-on browser, drives the webmail tab (creating it if missing), lists rows, opens messages, and clicks through the compose UI to send replies. Message text is read from the DOM first; if the body renders inside opaque/split nodes, the pane is screenshotted and OCR'd with tesseract.
- No credentials are stored in this repo — the browser profile holds the session.
- The OCR fallback writes a temp screenshot to
/tmp/opencode/zoho-email-ocr.png. - Keep this tool to your own accounts; automated replies to strangers are a quick way to get flagged as spam.