Skip to content

feat: transform smtp-action into mail-action with IMAP receive (#82) - #92

Open
raphael-goetz wants to merge 1 commit into
mainfrom
#82-transform-smtp-action
Open

raphael-goetz wants to merge 1 commit into
mainfrom
#82-transform-smtp-action

Conversation

@raphael-goetz

Copy link
Copy Markdown
Member

Closes #82.

Transforms the smtp-action into a general-purpose mail-action that both sends mail (SMTP, as before) and receives it via a new IMAP trigger. Multiple servers are supported the same way as today — one IMAP/SMTP server per project configuration.

Changes

  • Rename actions/smtp-action → actions/mail-action (git history preserved; package @code0-tech/mail-action, action id/auth-token defaults, CI matrix, root README).
  • Config (per-project action config): keeps the SMTP keys and adds IMAP keys — imap_host, imap_port (993), imap_secure (true), imap_username, imap_password, imap_mailbox (INBOX).
  • Send: behavior unchanged; SMTP_SEND_RESULT → MAIL_SEND_RESULT, functions sendEmail / sendEmailWithAttachments kept.
  • Receive (new):
    • RECEIVED_MAIL data type (messageId, from, to[], cc[], subject, text, html, date).
    • MAIL_RECEIVED RuntimeEvent trigger with an addresses flow setting (string array; empty = match all). Matching is done in the action against the message's To/Cc recipients.
    • imapListener.ts: a reconciling ImapFlow connection manager — one connection per project that has a bound MAIL_RECEIVED flow, using that project's config. On new mail it parses with mailparser, then calls action.executeFlow for every matching flow.
  • Removed the erroneous smtp-action entry from .rust-actions in CI (it was always a node action).

Design notes

  • This is the first use of the action-driven RuntimeEvent model (registerRuntimeEventClass + executeFlow) in the TS actions — existing triggers are all REST webhooks. The Rust cron-action uses the same model.
  • The listener uses mailboxOpen() (not a held mailbox lock) so ImapFlow's automatic IDLE stays active and exists events fire; exists processing is serialized against a UID high-watermark to avoid duplicate dispatch.

Testing

  • npm run typecheck — clean.
  • npm run test — 5/5 pass (send-result + received-mail schemas, address matching).
  • ⚠️ The live IMAP receive path is not covered by automated tests (needs a real IMAP server). Please smoke-test against a real mailbox before merging.

🤖 Generated with Claude Code

Rename the SMTP action to a general-purpose mail action that can both
send mail (SMTP, as before) and receive it via a new IMAP trigger.

- rename actions/smtp-action -> actions/mail-action (package, action id)
- add per-project IMAP server config (imap_host/port/secure/username/
  password/mailbox) alongside the existing SMTP config
- rename SMTP_SEND_RESULT -> MAIL_SEND_RESULT; send functions unchanged
- add RECEIVED_MAIL data type and the MAIL_RECEIVED RuntimeEvent trigger
  with an `addresses` flow setting (string array; empty matches all)
- add imapListener: a reconciling ImapFlow connection manager (one per
  project with a bound flow) that parses incoming mail and executes each
  flow whose configured addresses match the message recipients
- update CI matrix and READMEs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

GitLab Pipeline Action

General information

Link to pipeline: https://gitlab.com/code0-tech/development/centaurus/-/pipelines/3015118587

Status: Passed
Duration: 10 minutes

Job summaries

docs:preview

Documentation preview available at https://code0-tech.gitlab.io/-/development/telescopium/-/jobs/17646673089/artifacts/out/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transform smtp action to native mail action.

1 participant