Keep users informed with instant notification emails. Activity alerts, status updates, and important announcements delivered reliably.
Send notification emails with the TigerMail API.
type NotificationType = "comment" | "mention" | "update" | "alert";
interface Notification {
type: NotificationType;
userEmail: string;
userName: string;
title: string;
message: string;
actionUrl?: string;
actionLabel?: string;
}
async function sendNotificationEmail(notification: Notification) {
const actionHtml = notification.actionUrl
? `<p><a href="${notification.actionUrl}" style="
background: #f97316;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px;
">${notification.actionLabel || "View"}</a></p>`
: "";
const response = await fetch("https://tigermail.io/api/v1/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TIGERMAIL_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to: [notification.userEmail],
from: "notifications@yourapp.com",
subject: notification.title,
html: `
<p>Hi ${notification.userName},</p>
<p>${notification.message}</p>
${actionHtml}
<hr>
<p style="font-size: 12px; color: #666;">
<a href="https://yourapp.com/settings/notifications">
Manage notification preferences
</a>
</p>
`,
}),
});
return response.json();
}
// Usage examples:
await sendNotificationEmail({
type: "comment",
userEmail: "user@example.com",
userName: "John",
title: "New comment on your post",
message: "Sarah commented: 'Great work on this!'",
actionUrl: "https://yourapp.com/posts/123",
actionLabel: "View Comment",
});Follow these guidelines for effective notification emails.
Make a great first impression with welcome emails that engage new users. Guide them through onboarding and drive activation with clear next steps.
Send secure, reliable password reset emails that reach your users' inboxes instantly. Build trust with fast delivery and professional formatting.
Send professional order confirmations instantly after purchase. Keep customers informed with tracking details, order summaries, and next steps.