Skip to content

Connect and store a mail account #8

Description

@Hohnik

Parent

Spec: MailChat MVP — email-as-chat

What to build

As a user, I can connect an IMAP/SMTP mailbox to MailChat by providing my address and app-specific password, and see it listed as a connected, validated account. Credentials are encrypted at rest using a master key sourced from the environment; the connection is validated against the real mail server (reusing the already-built, live-verified IMAP/SMTP clients) before the account is considered connected. Supports connecting more than one account to the same instance.

Acceptance criteria

  • An Account model (provider/host/port/address) and a linked Credentials model exist, with credentials encrypted at rest (Fernet-style) using a master key read from an environment variable — never stored in the database.
  • A connect service validates the supplied credentials against the real IMAP and SMTP servers (reusing the existing imap_client/smtp_client connect functions) before persisting the account as connected; a disconnect operation removes/deactivates an account.
  • A minimal htmx-rendered form lets a user submit an account's address, host/port config, and app-specific password, and lists currently connected accounts.
  • Connecting more than one account works — each is stored and listed independently.
  • After IMAP verification succeeds, the connect flow lists the account's IMAP folders (reusing imap_client.list_folders) and lets the user pick which one is their Sent folder from that list — no free-text entry, no auto-detection/guessing. The selection is stored as a new Account.sent_folder field, defaulting to "Sent" only as the pre-selected option in the picker (not silently assumed if the user doesn't have a folder called that). (Decided in Decide reply send-from account and how sent replies re-enter the conversation — needed so sync can poll Sent per account; see Group messages into person+subject conversations and Reply within a conversation.)
  • Tests: encrypt/decrypt round-trip unit test (no mocking); connect-service tests mocking the IMAP/SMTP connection boundary (same pattern as existing imap_client/smtp_client tests) covering both successful and failing credentials; an htmx route test (FastAPI TestClient) asserting the add-account form renders and a submitted account appears in the connected-accounts list.
  • Tests: connect-flow test covering the new folder-picker step — asserting the folder list is shown after verification and the selected folder is persisted as Account.sent_folder.

Blocked by

  • None — can start immediately

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions