Email 设置
概述
Email channel 让 Anyy 通过 IMAP 接收邮件,并通过 SMTP 回复。收到的邮件会进入 resident gateway,成为一个 Anyy 会话;回复会尽量回到同一个邮件线程里。
这个页面只讲消息网关里的 Email channel,不讲邮箱管理或日历连接器工具。
前提条件
- 一个给 Anyy 专用的邮箱。
- 邮箱已开启 IMAP。
- 同一邮箱可以通过 SMTP 发信。
- 如果邮箱服务商要求,准备 app password 或服务密码。
- IMAP host 和 SMTP host。
配置
创建凭据
在邮件服务商侧创建或准备邮箱凭据。开启双重验证的邮箱通常要用 app password,不要用账号主密码。
Anyy 需要这些值:
| 值 | 配置字段 |
|---|---|
| 邮箱地址 | address |
| IMAP host | imap_host |
| SMTP host | smtp_host |
| 邮箱密码或 app password | password_ref secret |
配置 Anyy
anyy setup channels email \
--set [email protected] \
--set imap_host=imap.example.com \
--set smtp_host=smtp.example.com \
--secret password='app-password' \
--write-config
这个命令会写入 channels.email,并把密码保存为 Anyy secret。默认值包括:
| 字段 | 默认值 |
|---|---|
account_id | mailbox |
imap_port | 993 |
smtp_port | 587 |
mailbox | INBOX |
poll_interval_ms | 15000 |
dm_policy | open |
send_chunk_chars | 50000 |
如果服务商使用不同端口或邮箱目录,编辑 config.yaml。
启动 Gateway
anyy gateway start
anyy channels reload
运行 Doctor 检查
anyy channels doctor email
anyy doctor
Doctor 会检查必填字段和 secret ref,不会登录邮件服务商。
访问策略
私信
Email 是 direct-message channel。dm_policy 支持:
| Policy | 行为 |
|---|---|
open | 任意发件人都可以开始会话。 |
allowlist | 只接受 allow_from 中的发件人。 |
disabled | 忽略入站邮件。 |
个人部署建议使用 allowlist:
channels:
email:
dm_policy: allowlist
allow_from:
群组
Email adapter 不支持群组 channel。用 allow_from 控制发件人访问。
管理员
Channel access 和命令授权是两层。Email 决定消息能不能进入 Anyy;命令权限由共享的 messaging command 层处理。
Sessions
每个被接受的发件人/邮件线程会映射到一个 Anyy messaging session。可用时,回复会保留邮件线程 header。
媒体支持
入站媒体
当前 Email channel 处理文本邮件。Adapter 没有声明 inbound media 能力。
出站媒体
Email channel 发送文本回复。生成的 artifact 会留在 session 中,但这个 adapter 没有声明原生 outbound media。
命令
Messaging commands 和其他 channel 使用同一套 dispatcher。权限允许时,可以在邮件正文中发送 /status 或 /stop。
Cron 投递
配置好默认绑定或 delivery target 后,Email 可以作为 cron delivery channel:
anyy cron create \
--name "Morning email" \
--schedule "0 9 * * *" \
--prompt "Send my morning summary" \
--delivery-target current_user_default \
--delivery-channel email
故障排查
- 收不到邮件:检查
imap_host、imap_port、mailbox 名称和服务商 IMAP 设置。 - 无法回复:检查
smtp_host、smtp_port,以及服务商是否要求 app password。 - 发件人被拒绝:检查
dm_policy和allow_from。 - Doctor 通过但 runtime 失败:doctor 只检查配置形状;登录错误会出现在 gateway 日志和 channel status 中。