邮件
从你的应用发送事务性邮件。通过 Dashboard > Emails 或 SDK 管理发件人身份并追踪投递状态。
每个 Proyecta 应用都可以发送事务性邮件。验证发件人身份后,即可在应用代码中直接发送邮件——无需单独注册邮件服务商账号。
Emails 标签页
Section titled “Emails 标签页”在 builder 中打开 Dashboard > Emails。该标签页包含两个子标签:
| 标签页 | 用途 |
|---|---|
| Identities | 添加并验证发件人邮箱地址或域名 |
| Sent | 浏览已发送的邮件及其投递状态(已发送、已送达、已退回等) |
你可以添加新的发件人身份、浏览邮件投递历史——无需编写任何代码。
两步设置流程
Section titled “两步设置流程”- 创建并验证发件人身份(邮箱地址或域名)
- 调用
proyecta.email.send(),并在from字段中填写已验证的地址
验证单个邮箱地址
Section titled “验证单个邮箱地址”最简单的方式是验证单个邮箱地址。
import Proyecta from '@proyecta-ai/sdk';
const proyecta = new Proyecta({ apiKey: process.env.PROYECTA_API_KEY });
const identity = await proyecta.email.identities.create({ type: 'email', value: 'hello@myapp.com',});
// identity.status === 'verified' immediately upon creation如需重新触发验证检查:
await proyecta.email.identities.verify({ identityId: identity.id });验证整个域名
Section titled “验证整个域名”对于生产环境应用,建议验证整个域名,这样你就可以使用该域名下的任意地址发送邮件(hello@、support@、noreply@ 等)。
const identity = await proyecta.email.identities.create({ type: 'domain', value: 'myapp.com',});
// identity.status === 'verified' immediately upon creation基于 DNS 的域名验证(SPF/DKIM 记录生成与复查)已在规划中,但尚未实现。
身份验证完成后,使用以下方式发送邮件:
await proyecta.email.send({ from: 'Acme <hello@myapp.com>', to: 'customer@example.com', subject: 'Your receipt from Acme', html: '<p>Thanks for your order — here are the details.</p>', text: 'Thanks for your order — here are the details.',});send 返回完整的已发送邮件对象(包含 id、last_event 及消息字段),你可以用它在之后查询投递状态。
收件人。 to、cc 和 bcc 均支持单个地址或地址数组。
内容。 可提供 html、text 或两者兼有。为确保最佳送达率,建议同时提供纯文本版本。
回复地址、自定义 header、元数据标签。 reply_to 已支持(使用第一个地址)。自定义 header 和元数据标签可被 API 接受,但尚未转发至投递服务商。
追踪投递状态
Section titled “追踪投递状态”分页列出已发送的邮件及其最新投递事件:
const { data: emails } = await proyecta.email.list({ limit: 20 });for (const email of emails) { console.log(email.subject, '→', email.last_event); // last_event: 'sent' | 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained'}获取单封邮件的完整 HTML/文本内容:
const full = await proyecta.email.get('email_abc123');console.log(full.html, full.text, full.last_event);让 AI 帮你搞定
Section titled “让 AI 帮你搞定”你不需要手动编写这些代码,直接告诉 AI:
"Verify hello@myapp.com as a sending identity.""Send a welcome email with Proyecta Email whenever a new user signs up. Use a nice HTML template.""After a successful checkout, send the customer a receipt using proyecta.email.send.""Show me the last 20 emails we've sent and whether they bounced."
from地址必须是已验证的身份。 使用未验证的地址发送将返回错误。- 每月发送量有限制,具体取决于你的 Proyecta 套餐。
- 模板编辑器 — 在 builder 中可视化设计事务性邮件模板
- 批量发送 endpoint,用于大规模邮件群发