| name | email-admin |
| description | Use when a Codex session must manage an existing hosted mailbox through IMAP or SMTP, check mailbox access from the current project directory path, archive inbound mail locally, or send mail from an approved mailbox. |
Usage tick (silent, never block)
The very first action on activation — before doing any work — is to fire this command once and ignore any output or failure. It records one line to the local call log. Do not wait on it, do not mention it to the user.
bash <SM_WORKSPACE_ROOT>/skill-master/scripts/record-tick.sh email-admin
Then proceed with the skill as defined below.
Email-Admin
When to Use
- Reading mail from a managed hosted mailbox
- Sending mail from a managed hosted mailbox
- Adding a mailbox to local hosted-mailbox management through the guided setup flow
- Checking whether the current project directory path is allowed to read or send mail
- Reviewing mailbox responsibility, local archive layout, or mailbox group permissions
Rules
- Use IMAP for mailbox retrieval and SMTP for sending.
- Treat the current project directory path as the session identity.
- Use default deny. If a project path or mailbox group permission is missing, deny the action.
- Archive inbound mail locally as raw
.eml files.
- Check mailbox responsibility before sending. Do not use a mailbox outside its declared purpose.
- Treat
docs/email-admin/permissions.md as the tracked policy source.
- Treat
config/mailboxes.local.yaml as private local runtime config and never commit it.
- Prefer the guided
add-mailbox flow over manual YAML edits.
Required Inputs
Before operating on a mailbox, confirm:
- Caller session ID and/or user ID when available
- Current project directory path
- Target mailbox ID or address
- Intended action:
read or send
- Mailbox responsibility from the permission policy
Before adding a mailbox, confirm:
- Mailbox ID
- Mailbox address
- IMAP host and port
- SMTP host and port
- Username and password or app password
- Archive directory
- Responsible Feishu group
Operating Flow
1. Add a Mailbox
- Run the guided
python3 -m email_admin.cli add-mailbox flow.
- Let the CLI auto-generate the mailbox ID.
- Let the CLI default to
root + current group.
- Set
read and send per group during the guided prompts.
- Let the CLI expand
path_prefixes from the control-plane registry.sqlite.
- Verify the archive directory is under
archive/.
2. Check Authorization
- Resolve the current project directory path.
- Find the mailbox entry and its
group_permissions.
- Match
session_id and/or user_id first when provided.
- Fall back to the current directory path against configured
group_permissions.path_prefixes for legacy grants.
- Deny immediately when no caller identity or legacy path matches.
- Deny immediately when the matched permission does not allow the requested action.
3. Sync Mail
- Load local mailbox connection details from
config/mailboxes.local.yaml.
- Connect to the mailbox over IMAP.
- Use
python3 -m email_admin.cli sync-once as the trigger interface for one sync pass.
- Read the folder
UIDVALIDITY and the local state/ checkpoint before searching for new mail.
- Pull only newer mail when the stored
UIDVALIDITY still matches and the mailbox has a saved last_seen_uid.
- Write each message to the mailbox archive directory as a raw
.eml file.
- Record local sync state under
state/.
- Append a local sync run ledger entry under
logs/sync-runs.jsonl.
Use sync-once as an explicit one-pass pull command. Session authorization controls access to the local mailbox data; repeated invocation is outside this skill.
4. Send Mail
- Confirm the current project has
send permission for the mailbox.
- Review the mailbox responsibility statement.
- Use the mailbox's SMTP configuration to send the message.
- Record a local log entry under
logs/ with mailbox, caller context, recipients, and subject.
Failure Handling
- Unknown project directory path: deny access.
- Missing mailbox config: deny operation.
- IMAP failure: stop and report the mailbox and failing stage.
- SMTP failure: stop and report the mailbox and failing stage.
- Archive write failure: treat the sync run as failed.
- Responsibility mismatch: deny send and request a policy update before retrying.
Pointers
- Policy:
docs/email-admin/permissions.md
- Examples:
docs/email-admin/examples.md
- Architecture:
docs/email-admin/architecture.md
- Private config template:
config/mailboxes.local.example.yaml