
name: agentmaildescription: Email infrastructure for AI agents. Create accounts, send/receive emails, manage webhooks, and check karma balance via the AgentMail API.risk: safesource: communityAgentMail — 人工智能代理的电子邮件AgentMail 为 AI 代理提供真实的电子邮件地址theagentmail.net以及 REST API。代理可以发送和接收电子邮件注册服务GitHub、AWS、Slack 等并获取验证码。一个信誉系统防止垃圾邮件并保持共享域的声誉高。基础 URL:https://api.theagentmail.net何时使用一个人工智能代理需要一个真实的收件箱/发件箱用于注册、验证流程或事务性通信。您需要配置 AgentMail 帐户、发送消息、读取收件箱内容或注册入站 Webhook。你需要监控业力使用情况或将电子邮件事件接入代理自动化。快速开始所有请求都需要Authorization: Bearer am_...头部来自控制面板的 API 密钥。创建一个电子邮件账户-10 点声望curl-XPOST https://api.theagentmail.net/v1/accounts\-HAuthorization: Bearer am_...\-HContent-Type: application/json\-d{address: my-agenttheagentmail.net}响应{data: {id: ..., address: my-agenttheagentmail.net, displayName: null, createdAt: 123}}发送电子邮件-1 信誉值curl-XPOST https://api.theagentmail.net/v1/accounts/{accountId}/messages\-HAuthorization: Bearer am_...\-HContent-Type: application/json\-d{ to: [recipientexample.com], subject: Hello from my agent, text: Plain text body, html: pOptional HTML body/p }可选字段cc、bcc字符串数组、inReplyTo、references用于线程的字符串、attachments{filename, contentType, content}数组其中 content 为 base64。阅读收件箱# List messagescurlhttps://api.theagentmail.net/v1/accounts/{accountId}/messages\-HAuthorization: Bearer am_...# Get full message (with body and attachments)curlhttps://api.theagentmail.net/v1/accounts/{accountId}/messages/{messageId}\-HAuthorization: Bearer am_...查看业力curlhttps://api.theagentmail.net/v1/karma\-HAuthorization: Bearer am_...回应{data: {balance: 90, events: [...]}}注册 Webhook实时入站curl-XPOST https://api.theagentmail.net/v1/accounts/{accountId}/webhooks\-HAuthorization: Bearer am_...\-HContent-Type: application/json\-d{url: https://my-agent.example.com/inbox}Webhook 传递包括两个安全头X-AgentMail-Signature– 使用 webhook 秘钥对请求体进行 HMAC-SHA256 十六进制摘要签名X-AgentMail-Timestamp—— 邮件发送时的毫秒时间戳验证签名并拒绝时间戳超过 5 分钟的请求以防止重放攻击import{createHmac}fromcrypto;constverifyWebhook(body:string,signature:string,timestamp:string,secret:string){if(Date.now()-Number(timestamp)5*60*1000)returnfalse;returncreateHmac(sha256,secret).update(body).digest(hex)signature;};下载附件curlhttps://api.theagentmail.net/v1/accounts/{accountId}/messages/{messageId}/attachments/{attachmentId}\-HAuthorization: Bearer am_...返回{data: {url: https://signed-download-url...}}。完整的 API 参考MethodPathDescriptionKarmaPOST/v1/accountsCreate email account-10GET/v1/accountsList all accountsGET/v1/accounts/:idGet account detailsDELETE/v1/accounts/:idDelete account10POST/v1/accounts/:id/messagesSend email-1GET/v1/accounts/:id/messagesList messagesGET/v1/accounts/:id/messages/:msgIdGet full messageGET/v1/accounts/:id/messages/:msgId/attachments/:attIdGet attachment URLPOST/v1/accounts/:id/webhooksRegister webhookGET/v1/accounts/:id/webhooksList webhooksDELETE/v1/accounts/:id/webhooks/:whIdDelete webhookGET/v1/karmaGet balance events业力系统每一个行为都有业力的代价或回报EventKarmaWhymoney_paid100Purchase creditsemail_received2Someone replied from a trusted domainaccount_deleted10Karma refunded when you delete an addressemail_sent-1Sending costs karmaaccount_created-10Creating addresses costs karma重要规则业力只会授予来自可信提供商Gmail、Outlook、Yahoo、iCloud、ProtonMail、Fastmail、Hey 等的入站电子邮件。来自未知/一次性域的电子邮件不会获得业力。在代理回复之前你每个发送者只能获得一次业力。如果发送者 X 给你发送 5 封邮件而没有回复只有第一封会获得业力。回复 X 后X 的下一封邮件将再次获得业力。删除账户会退还创建账户所花费的10点业力。当业力为 0 时发送和创建账户会返回 HTTP 402。在进行消耗业力的操作之前请始终检查余额。TypeScript 软件开发工具包import{createClient}fromagentmail/sdk;constmailcreateClient({apiKey:am_...});// Create accountconstaccountawaitmail.accounts.create({address:my-agenttheagentmail.net,});// Send emailawaitmail.messages.send(account.id,{to:[humanexample.com],subject:Hello,text:Sent by an AI agent.,});// Read inboxconstmessagesawaitmail.messages.list(account.id);constdetailawaitmail.messages.get(account.id,messages[0].id);// Attachmentsconstattawaitmail.attachments.getUrl(accountId,messageId,attachmentId);// att.url is a signed download URL// Webhooksawaitmail.webhooks.create(account.id,{url:https://my-agent.example.com/inbox,});// Karmaconstkarmaawaitmail.karma.getBalance();console.log(karma.balance);错误处理import{AgentMailError}fromagentmail/sdk;try{awaitmail.messages.send(accountId,{to:[ab.com],subject:Hi,text:Hey});}catch(e){if(einstanceofAgentMailError){console.log(e.status);// 402, 404, 401, etc.console.log(e.code);// INSUFFICIENT_KARMA, NOT_FOUND, etc.console.log(e.message);}}常见模式注册服务并阅读验证电子邮件constaccountawaitmail.accounts.create({address:signup-bottheagentmail.net,});// Use the address to sign up (browser automation, API, etc.)// Poll for verification emailfor(leti0;i30;i){constmessagesawaitmail.messages.list(account.id);constverificationmessages.find(mm.subject.toLowerCase().includes(verify)||m.subject.toLowerCase().includes(confirm));if(verification){constdetailawaitmail.messages.get(account.id,verification.id);// Parse verification link/code from detail.bodyText or detail.bodyHtmlbreak;}awaitnewPromise(rsetTimeout(r,2000));}发送电子邮件并等待回复constsentawaitmail.messages.send(account.id,{to:[humancompany.com],subject:Question about order #12345,text:Can you check the status?,});for(leti0;i60;i){constmessagesawaitmail.messages.list(account.id);constreplymessages.find(mm.directioninboundm.timestampsent.timestamp);if(reply){constdetailawaitmail.messages.get(account.id,reply.id);// Process replybreak;}awaitnewPromise(rsetTimeout(r,5000));}类型typeAccount{id:string;address:string;displayName:string|null;createdAt:number};typeMessage{id:string;from:string;to:string[];subject:string;direction:inbound|outbound;status:string;timestamp:number};typeMessageDetailMessage{cc:string[]|null;bcc:string[]|null;bodyText:string|null;bodyHtml:string|null;inReplyTo:string|null;references:string|null;attachments:AttachmentMeta[]};typeAttachmentMeta{id:string;filename:string;contentType:string;size:number};typeKarmaBalance{balance:number;events:KarmaEvent[]};typeKarmaEvent{id:string;type:string;amount:number;timestamp:number;metadata?:Recordstring,unknown};限制仅当任务明确符合上述描述的范围时才使用此技能。不要将输出视为环境特定验证、测试或专家审查的替代品。如果缺少所需的输入、权限、安全界限或成功标准请停下来并要求澄清。