ส่งอีเมลขาออก
วัตถุประสงค์: จัดคิวการดำเนินการส่ง SMTP ด้วยส่วนอินไลน์และไฟล์แนบเสริม
โฟลว์ UI
- ผู้ใช้เขียนข้อความ
- UI จับผู้รับ เรื่อง เนื้อหา สิ่งที่แนบมา
- UI เข้าคิว
POST /api/accounts/:account_id/smtp/messages - UI ติดตามงาน/งานที่ได้รับจนกว่าจะเสร็จสิ้น
- UI รีเฟรชรายชื่ออีเมลขาออก
โฟลว์ไลบรารีไคลเอนต์
const queued = await api.provider.smtp.sendMessage(accountId, {
credential_id: smtpCredentialId,
direction: "outbound",
from_json: [{ address: "info@example.com" }],
to_json: [{ address: "recipient@example.com" }],
subject: "Status update",
text_body: "Hello from Inbox Manager",
html_body: "<p>Hello from Inbox Manager</p>",
attachments: [
{
filename: "report.txt",
content_type: "text/plain",
content_b64: Buffer.from("report body").toString("base64"),
disposition: "attachment",
},
],
});
await api.jobs.waitForTask(accountId, queued.data.task_id);
HTTP/ขดไหล
API_BASE_URL="https://api.inbox-manager.com"
curl -sS -X POST "${API_BASE_URL}/api/accounts/${ACCOUNT_ID}/smtp/messages" \
-H "authorization: Bearer ${BEARER_TOKEN}" \
-H "content-type: application/json" \
--data "{
\"credential_id\":\"${SMTP_CREDENTIAL_ID}\",
\"direction\":\"outbound\",
\"from_json\":[{\"address\":\"${FROM_ADDRESS}\"}],
\"to_json\":[{\"address\":\"${TO_ADDRESS}\"}],
\"subject\":\"Status update\",
\"text_body\":\"Hello from Inbox Manager\",
\"attachments\":[
{
\"filename\":\"report.txt\",
\"content_type\":\"text/plain\",
\"content_b64\":\"${ATTACHMENT_B64}\",
\"disposition\":\"attachment\"
}
]
}"
หมายเหตุ
- การส่งขาออกเป็นแบบอะซิงโครนัสและได้รับการสนับสนุนงาน
- ชุดผู้รับที่ว่างเปล่าล้มเหลวอย่างรวดเร็ว