アウトバウンド電子メールを送信する
目的: オプションのインライン部分と添付ファイルを使用して 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\"
}
]
}"
注意事項
- アウトバウンド送信は非同期であり、ジョブバックされます。
- 空の受信者セットはすぐに失敗します。