Email Source/Output for Waken — IMAP polling in, SMTP send out.
Project description
waken-email
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 inloop.run_in_executor(...)forEmailSource's polling — the async IMAP libraries that exist (e.g.aioimaplib) are far less mature/widely used than stdlibimaplib, the same reasoningwaken-bedrockapplies to wrapping synchronousboto3.EmailOutput, by contrast, usesaiosmtplibdirectly rather than wrapping stdlibsmtplib— 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.
EmailSourcetracks 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-inFilesystemSource's_seenset orwaken-telegram'soffset. 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 whenstart()runs is the baseline, not a new arrival, and never fires — the same ruleFilesystemSourceapplies to pre-existing files. - Plain text only. Message bodies are parsed with stdlib
email(get_body(preferencelist=("plain",))) and only the firsttext/plainpart 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.filesattachments are likewise not sent byEmailOutputyet.
Development
git clone https://github.com/WakenHQ/waken-email
cd waken-email
pip install -e ".[dev]"
pytest
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file waken_email-0.1.0.tar.gz.
File metadata
- Download URL: waken_email-0.1.0.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e1a163513ecb61b535c96df1a3456f4028c936846409e43e179291f99f96b9
|
|
| MD5 |
be52ee5324cfe7876bc234772d3769ff
|
|
| BLAKE2b-256 |
c50a17b2c45d83d53e5d7db63b5859a234b1ddd5ad434a73dee24adb640a3b29
|
Provenance
The following attestation bundles were made for waken_email-0.1.0.tar.gz:
Publisher:
publish.yml on WakenHQ/waken-email
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waken_email-0.1.0.tar.gz -
Subject digest:
94e1a163513ecb61b535c96df1a3456f4028c936846409e43e179291f99f96b9 - Sigstore transparency entry: 2082077019
- Sigstore integration time:
-
Permalink:
WakenHQ/waken-email@1cb33e4f332fbdbb32287aab42f72bb8fe9d3d62 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/WakenHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1cb33e4f332fbdbb32287aab42f72bb8fe9d3d62 -
Trigger Event:
push
-
Statement type:
File details
Details for the file waken_email-0.1.0-py3-none-any.whl.
File metadata
- Download URL: waken_email-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75cc6c4a2e7f70c51289419d697e917f2c4239fad7efb82a9898ab5a07341aa6
|
|
| MD5 |
ec1778bc768d68b2dd90e038edef00f9
|
|
| BLAKE2b-256 |
a8f44ef0225081062243aea8f1b5a19a85fd00be261bcf08ca4a43e96839eb6e
|
Provenance
The following attestation bundles were made for waken_email-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on WakenHQ/waken-email
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
waken_email-0.1.0-py3-none-any.whl -
Subject digest:
75cc6c4a2e7f70c51289419d697e917f2c4239fad7efb82a9898ab5a07341aa6 - Sigstore transparency entry: 2082077025
- Sigstore integration time:
-
Permalink:
WakenHQ/waken-email@1cb33e4f332fbdbb32287aab42f72bb8fe9d3d62 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/WakenHQ
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1cb33e4f332fbdbb32287aab42f72bb8fe9d3d62 -
Trigger Event:
push
-
Statement type: