All guides
Send Email from Elysia
Send emails from Elysia with end-to-end type safety
1. Install the SDK
bun add sendpigeon2. Set your API key
Add your SendPigeon API key to your environment variables:
SENDPIGEON_API_KEY=your_api_key_hereGet your API key from the dashboard.
3. Send your first email
import { Elysia, t } from "elysia";
import { SendPigeon } from "sendpigeon";
const client = new SendPigeon(Bun.env.SENDPIGEON_API_KEY!);
const app = new Elysia()
.post(
"/contact",
async ({ body }) => {
await client.emails.send({
from: "hello@yourdomain.com",
to: body.email,
subject: `Thanks for reaching out, ${body.name}!`,
html: `<h1>We got your message</h1><p>We'll get back to you soon.</p>`,
});
return { success: true };
},
{
body: t.Object({
email: t.String({ format: "email" }),
name: t.String(),
}),
}
)
.listen(3000);Features
- End-to-end type safety
- Built-in validation
- Runs on Bun
Ready to send emails?
Get started with 1,000 free emails per month.
Start for free