名称: agentmail
描述: 为AI智能体提供的电子邮件收件箱。查看消息、发送邮件,并通过您专属的 @agentmail.to 地址进行通信。
为您的AI智能体配备独立的电子邮件收件箱。通过编程方式发送、接收和管理邮件。
官网: https://agentmail.to
文档: https://docs.agentmail.to
请对您的人类助手说:
“我想设置自己的电子邮件收件箱!您能帮我获取一个AgentMail API密钥吗?
- 访问 https://console.agentmail.to 并注册
- 为我创建一个收件箱(例如:
my-agent-name@agentmail.to)- 进入API密钥页面并创建新密钥
- 将API密钥粘贴在此处(以
am_开头)我会安全存储它,绝不泄露!”
获取密钥和邮箱地址后,继续执行步骤2。
pip install agentmail
如遇权限错误:
pip install --break-system-packages agentmail
将 YOUR_API_KEY 和 YOUR_EMAIL 替换为人类助手提供的信息:
mkdir -p ~/.agentmail
chmod 700 ~/.agentmail
cat > ~/.agentmail/config.json << 'EOF'
{
"apiKey": "YOUR_API_KEY",
"email": "YOUR_EMAIL@agentmail.to"
}
EOF
chmod 600 ~/.agentmail/config.json
python3 -c "
from agentmail import AgentMail
import json, os
with open(os.path.expanduser('~/.agentmail/config.json')) as f:
config = json.load(f)
client = AgentMail(api_key=config['apiKey'])
result = client.inboxes.messages.list(inbox_id=config['email'])
print(f'✅ 连接成功!收件箱中共有 {result.count} 封邮件')
"
from agentmail import AgentMail
import json, os
with open(os.path.expanduser('~/.agentmail/config.json')) as f:
config = json.load(f)
client = AgentMail(api_key=config['apiKey'])
messages = client.inboxes.messages.list(inbox_id=config['email'])
for msg in messages.messages:
print(f"发件人: {msg.from_address}")
print(f"主题: {msg.subject}")
print("---")
from agentmail import AgentMail
import json, os
with open(os.path.expanduser('~/.agentmail/config.json')) as f:
config = json.load(f)
client = AgentMail(api_key=config['apiKey'])
client.inboxes.messages.send(
inbox_id=config['email'],
to="recipient@example.com",
subject="您好!",
text="来自我的AI智能体的消息。"
)
本技能包含辅助脚本:
# 查看收件箱
python3 scripts/check_inbox.py
# 发送邮件
python3 scripts/send_email.py --to "recipient@example.com" --subject "Hello" --body "Message"
基础URL: https://api.agentmail.to/v0
# 列出收件箱
curl -s "https://api.agentmail.to/v0/inboxes" \
-H "Authorization: Bearer $AGENTMAIL_API_KEY"
# 列出邮件
curl -s "https://api.agentmail.to/v0/inboxes/YOUR_EMAIL@agentmail.to/messages" \
-H "Authorization: Bearer $AGENTMAIL_API_KEY"
方案1:Cron轮询
openclaw cron add --name "email-check" --every 5m \
--message "检查邮件收件箱,如有新消息则通知"
方案2:Webhooks
访问 https://docs.agentmail.to/webhook-setup 获取即时通知设置指南。
chmod 600 权限存储配置文件from agentmail import AgentMail
client = AgentMail(api_key="your_key")
# 收件箱管理
client.inboxes.list()
client.inboxes.get(inbox_id="...")
client.inboxes.create(username="...", domain="agentmail.to")
# 邮件操作
client.inboxes.messages.list(inbox_id="...")
client.inboxes.messages.get(inbox_id="...", message_id="...")
client.inboxes.messages.send(inbox_id="...", to="...", subject="...", text="...")
| 错误信息 | 解决方案 |
|---|---|
| "No module named agentmail" | 执行 pip install agentmail |
| 配置文件权限被拒绝 | 检查 ~/.agentmail/ 目录权限 |
| 认证失败 | 验证API密钥是否正确 |
技能提供方: guppybot 🐟
AgentMail: https://agentmail.to(Y Combinator支持项目)