Integration
Send emails from Deno with Postkit
Send transactional emails from Deno using built-in fetch. No npm install required — just import and send.
1. Set your API key
# .env or Deno.env POSTKIT_API_KEY=pk_live_...
2. Send an email
typescript
// main.ts
Deno.serve(async (req: Request) => {
if (req.method !== "POST") {
return new Response("Method not allowed", { status: 405 });
}
const { to, name } = await req.json();
const res = await fetch("https://api.postkit.eu/v1/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${Deno.env.get("POSTKIT_API_KEY")}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "hello@yourapp.eu",
to,
subject: "Welcome aboard!",
html: `<h1>Welcome, ${name}!</h1>`,
}),
});
return new Response(JSON.stringify(await res.json()), {
headers: { "Content-Type": "application/json" },
});
});3. Handle webhooks
Postkit sends delivery events (sent, delivered, bounced, opened, clicked) via HMAC-SHA256 signed webhooks following the Standard Webhooks specification.
typescript
// webhooks.ts — same HMAC verification pattern
// Use the Web Crypto API (built into Deno) for HMAC-SHA256