基于 Resend API 的强大邮件服务
本邮件系统提供完整的 RESTful API,使您能够通过编程方式集成邮件发送功能。所有端点都返回 JSON 格式的响应。
/apistudyhard.qzz.ioapplication/json发送简单的 HTML 或纯文本格式的电子邮件。
/api/emails/send
{
"from": "Your Name <your@studyhard.qzz.io>", // 可选
"to": "recipient@example.com", // 必填
"subject": "Hello World", // 必填
"html": "<p>This is an HTML email</p>", // html或text至少需要一个
"text": "This is a plain text email" // html和text二选一,或者都提供
}
{
"data": {
"id": "email_id",
"from": "Your Name <your@studyhard.qzz.io>",
"to": "recipient@example.com",
"subject": "Hello World"
}
}
发送包含文件附件的电子邮件。
/api/emails/send-with-attachments
{
"from": "Your Name <your@studyhard.qzz.io>", // 可选
"to": "recipient@example.com", // 必填
"subject": "Email with Attachment", // 必填
"html": "<p>Please find the attachment</p>", // html或text至少需要一个
"text": "Please find the attachment", // html和text二选一,或者都提供
"attachments": [ // 必填
{
"filename": "document.pdf",
"content": "base64_encoded_content_here"
}
]
}
{
"data": {
"id": "email_id",
"from": "Your Name <your@studyhard.qzz.io>",
"to": "recipient@example.com",
"subject": "Email with Attachment"
}
}
预定在未来某个时间发送的邮件。
/api/emails/schedule
{
"from": "Your Name <your@studyhard.qzz.io>", // 可选
"to": "recipient@example.com", // 必填
"subject": "Scheduled Email", // 必填
"html": "<p>This is a scheduled email</p>", // html或text至少需要一个
"text": "This is a scheduled email", // html和text二选一,或者都提供
"scheduledAt": "2023-12-31 23:59" // 必填,格式为 YYYY-MM-DD HH:MM
}
{
"data": {
"id": "scheduled_email_id",
"scheduledTime": "2023-12-31T23:59:00.000Z"
},
"message": "邮件已成功安排在 2023-12-31 23:59 发送"
}
同时向多个收件人发送相同内容的邮件。
/api/emails/send-bulk
{
"from": "Your Name <your@studyhard.qzz.io>", // 可选
"recipients": [ // 必填
"recipient1@example.com",
"recipient2@example.com",
"recipient3@example.com"
],
"subject": "Bulk Email", // 必填
"html": "<p>This is a bulk email to multiple recipients</p>", // html或text至少需要一个
"text": "This is a bulk email to multiple recipients" // html和text二选一,或者都提供
}
{
"data": {
"id": "email_id",
"from": "Your Name <your@studyhard.qzz.io>",
"to": ["recipient1@example.com", "recipient2@example.com", "recipient3@example.com"],
"subject": "Bulk Email"
}
}
查看所有已安排的定时邮件。
/api/emails/scheduled
{
"data": [
{
"id": "scheduled_email_id_1",
"from": "Your Name <your@studyhard.qzz.io>",
"to": "recipient@example.com",
"subject": "Scheduled Email 1",
"html": "<p>This is a scheduled email</p>",
"scheduledTime": "2023-12-31T23:59:00.000Z",
"createdAt": "2023-12-01T10:00:00.000Z",
"status": "scheduled",
"sent": false
},
{
"id": "scheduled_email_id_2",
"from": "Your Name <your@studyhard.qzz.io>",
"to": "recipient@example.com",
"subject": "Scheduled Email 2",
"html": "<p>This is another scheduled email</p>",
"scheduledTime": "2024-01-01T12:00:00.000Z",
"createdAt": "2023-12-01T10:30:00.000Z",
"status": "scheduled",
"sent": false
}
]
}
取消并删除已安排的定时邮件。
/api/emails/scheduled/:id
:id - 定时邮件的唯一标识符{
"success": true,
"message": "定时邮件 scheduled_email_id 已删除"
}
检查API服务状态和待发送的定时邮件数量。
/api/health
{
"status": "healthy",
"pendingScheduledEmails": 2,
"serverTime": "2023-12-01T12:00:00.000Z",
"storage": "Cloudflare KV"
}