feat: add email (IMAP/SMTP) target support#101
Merged
Conversation
Design for building email access into Shellgate using ImapFlow + Nodemailer, with new email target type, IMAP/SMTP auth, 8 MCP tools, and tabbed dashboard UI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review findings: fix bootstrap field names (name not description), add EmailConfig type union, explicit audit type extension, hardcoded approval for mail_send, hooks.server.ts auth bypass, npm dependencies, and files-to-modify checklist. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12-task plan covering schema, service, routes, MCP tools, dashboard UI, bootstrap, and manual integration testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ail column - Add EmailConfig type with imap/smtp sub-configs - Extend targets.type to "api" | "ssh" | "email" - Extend targets.config to SshConfig | EmailConfig - Add email varchar(255) column to targets table - Extend audit_logs.type to include "mail" - Add imapflow and nodemailer dependencies - Fix snapshot chain collision (0010/0011 duplicate ids) - Generate migration 0012_happy_pet_avengers Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mail field - Import EmailConfig from schema - Add validateEmailConfig: validates imap/smtp objects with host (required), port (1-65535, defaults: 993), and secure (boolean, default true) - Extend createTarget to accept type "email", validate email config, require email field, and include it in insert - Extend updateTarget to accept type "email", validate email config, and handle email field updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add "imap_smtp" to VALID_TYPES array
- Add imap_smtp branch in computeCredentialHint: parse JSON, display
"IMAP/SMTP ••• {username}" when username present, fallback to
"IMAP/SMTP credentials"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements all 9 mail service functions (listFolders, search, getMessage, getAttachment, send, createDraft, moveMessage, flagMessage, testConnection) with connect-per-request pattern and proper mailbox locking. Installs mailparser for MIME parsing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add /mail/* agent-facing routes (search, getMessage, attachment, send, draft, folders, move, flag), shared resolve helper, and hooks auth bypass. Send route requires X-Shellgate-Approved: true, returns 202 with approval_required payload otherwise. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gets Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replaces the flat target table with a tabbed view (API / SSH / Email) showing per-type counts. Installs the shadcn-svelte tabs component. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tail page Adds updateEmailConfig and testConnection server actions, a sheet for editing IMAP/SMTP settings, and a Test Connection card showing per-protocol IMAP/SMTP status on the target detail page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mail_search,mail_read,mail_attachment,mail_send,mail_draft,mail_folders,mail_move,mail_flagmail_sendrequires explicit user approval (hardcoded, not via guard engine)imap_smtpauth method type for email credentialsemailfield for email targetsLinear
DEA-4688
Test plan
emailcolumn to targets)imap_smtpcredentials and test connectionmail_foldersvia MCP — list mailbox foldersmail_searchvia MCP — search INBOXmail_readvia MCP — read a specific emailmail_draftvia MCP — create a draftmail_sendvia MCP — verify approval flow, then send🤖 Generated with Claude Code