Skip to main content

waken-email

CI License: MIT

Email Source/Output for Waken — IMAP polling in, SMTP send out.

Like waken-slack/waken-telegram/waken-voice, this is a channel adapter, not an AI backend: it implements Source/Output, not Target. Unlike those siblings, there's no single company or SDK to defer to here — SMTP and IMAP are generic protocols, not a vendor's product, so the configuration and secret names below (IMAP_*/SMTP_*) are this package's own invention, not inherited from anywhere.

Install

pip install waken-email

Usage

from waken import Runtime
from waken_claude import ClaudeAdapter
from waken_email import EmailOutput, EmailSource

runtime = Runtime()
runtime.target("claude", ClaudeAdapter())

runtime.source("email", EmailSource(target="claude"))
runtime.output("email", EmailOutput())

runtime.run()

EmailSource polls an IMAP inbox for new mail and dispatches each new message as an Event, keyed for replies by the sender's address (stashed in Event.metadata["to"]). EmailOutput sends a Target's Response back to that address over SMTP. Registering both under the same name ("email" above) means a reply to the original Target's answer goes back out over the same channel it came in on — see docs/api-spec.md §3 and §9 in the main waken repo for how Runtime.dispatch() resolves delivery.

Configuration

Both classes accept constructor keyword arguments, falling back to environment variables if omitted:

EmailSource Env var Default
host IMAP_HOST required
username IMAP_USERNAME required
password IMAP_PASSWORD required
folder — "INBOX"
interval — 30.0 seconds
use_ssl — True
EmailOutput Env var Default
host SMTP_HOST required
username SMTP_USERNAME required
password SMTP_PASSWORD required
port — 587
from_addr — username
use_tls — True (STARTTLS)

These names are invented for this package specifically — there's no provider SDK whose own default env vars to reuse the way waken-claude reuses ANTHROPIC_API_KEY or waken-slack reuses SLACK_BOT_TOKEN, since SMTP/IMAP are generic protocols implemented by every mail provider, not one company's SDK. See docs/adapter-ci-setup.md in the main waken repo for the broader convention this deliberately doesn't fit.

Design notes and scope boundaries

  • Sync stdlib for IMAP, async library for SMTP. imaplib (stdlib) is wrapped in loop.run_in_executor(...) for EmailSource's polling — the async IMAP libraries that exist (e.g. aioimaplib) are far less mature/widely used than stdlib imaplib, the same reasoning waken-bedrock applies to wrapping synchronous boto3. EmailOutput, by contrast, uses aiosmtplib directly rather than wrapping stdlib smtplib — a mature, widely-used async SMTP client actually exists for this side of the protocol, so there's no reason to prefer the executor-wrapping workaround here.
  • IMAP UID tracking, not an in-memory "seen" set. EmailSource tracks the highest IMAP UID processed so far rather than keeping an in-memory set of seen message ids — UIDs are monotonically increasing per mailbox (RFC 3501), so this is the IMAP-native equivalent of the built-in FilesystemSource's _seen set or waken-telegram's offset. A fresh IMAP connection is opened per poll and closed at the end of it, rather than holding one connection open across polls — simpler and more robust against idle-timeout disconnects. Whatever is already in the mailbox when start() runs is the baseline, not a new arrival, and never fires — the same rule FilesystemSource applies to pre-existing files.
  • Plain text only. Message bodies are parsed with stdlib email (get_body(preferencelist=("plain",))) and only the first text/plain part is used. An HTML-only email with no plain-text alternative part comes through with an empty body. Parsing or stripping HTML, and sending HTML replies, are both out of scope for v1. response.files attachments are likewise not sent by EmailOutput yet.

Development

git clone https://github.com/WakenHQ/waken-email
cd waken-email
pip install -e ".[dev]"
pytest

License

MIT

Metadata

Release files for waken-email 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for waken-email 0.1.0
File Size Uploaded
waken_email-0.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for waken-email 0.1.0
File Interpreter ABI Platform
waken_email-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.8 kB

Release files / waken_email-0.1.0.tar.gz

Download URL waken_email-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
94e1a163513ecb61b535c96df1a3456f4028c936846409e43e179291f99f96b9
BLAKE2b-256 checksum
How to use checksums
c50a17b2c45d83d53e5d7db63b5859a234b1ddd5ad434a73dee24adb640a3b29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.

Transparency log

Release files / waken_email-0.1.0-py3-none-any.whl

Download URL waken_email-0.1.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75cc6c4a2e7f70c51289419d697e917f2c4239fad7efb82a9898ab5a07341aa6
BLAKE2b-256 checksum
How to use checksums
a8f44ef0225081062243aea8f1b5a19a85fd00be261bcf08ca4a43e96839eb6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page