Many apps need email notification features — order confirmations, alerts, registration verification. This guide shows how to build a complete email notification system with YYDS Mail API.
Architecture
- System generates a dedicated inbox
- External services send email to that address
- YYDS Mail receives the email
- Webhook notifies your server
- Your server processes the email
- Triggers business logic
Step 1: Create Dedicated Inbox
const res = await fetch("https://maliapi.215.im/v1/accounts", {
method: "POST",
headers: {
"X-API-Key": process.env.YYDS_API_KEY,
"Content-Type": "application/json",
},
});
const { data: account } = await res.json();
console.log("Notification inbox:", account.address);
Use a paid plan to keep this address long-term.
Step 2: Configure Webhook
await fetch("https://maliapi.215.im/v1/webhooks", {
method: "POST",
headers: {
"X-API-Key": process.env.YYDS_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://your-app.com/api/mail-webhook",
events: ["message.received"],
}),
});
Step 3: Receive and Process
app.post("/api/mail-webhook", async (req, res) => {
const { type, data } = req.body;
if (type === "message.received") {
const { from, subject, text } = data;
if (from.includes("alert@monitoring.com")) {
await handleAlert(subject, text);
} else if (from.includes("orders@shop.com")) {
await handleOrder(subject, text);
}
}
res.json({ ok: true });
});
Use Cases
Monitoring Alerts
Monitoring system sends alerts to your YYDS Mail inbox → Webhook forwards to Slack/Discord.
Order Confirmations
E-commerce sends order emails → auto-extract order ID → update database.
Registration Verification
Auto-extract verification codes to complete registration flows.
Best Practices
- Dedicated inboxes: one per notification type for routing
- Async processing: return 200 fast, process in background
- Persist to database: prevent data loss on processing failure
- Retry queue: failed tasks retry later
- Monitor: track webhook receipt and processing success rates
FAQ
How many emails can one inbox receive? Depends on plan quota. High-volume needs use higher plans.
What if Webhooks miss messages? Implement polling fallback: periodically check inbox for missed messages.
Can I filter by sender?
Yes — filter by from field in your server code.
Want to build a notification system? See full API docs, or read Webhook guide.
