Send Emails with Hono
Learn how to send transactional emails using PostStack and Hono.
1. Install the SDK
bash
bun add @poststack/sdk hono2. Initialize the client
typescript
import PostStack from '@poststack/sdk';
import { Hono } from 'hono';
const poststack = new PostStack(process.env.POSTSTACK_API_KEY!);
const app = new Hono();3. Send an email
typescript
app.post('/send', async (c) => {
const { to, subject, html } = await c.req.json();
const { data, error } = await poststack.emails.send({
from: 'hello@yourdomain.com',
to,
subject,
html,
});
if (error) return c.json({ error }, 400);
return c.json(data);
});
export default app;Ready to send emails with Hono?
Create a free account and get your API key in under a minute.