Skip to main content

Getting started

Manual setup

Skip the CLI and wire Postboi up by hand — install, set a provider, and send.


The Quick start CLI does all of this for you. Prefer to wire it up by hand? It’s three steps.

Install Postboi

bun add postboi 
bun add postboi 
npm install postboi 
npm install postboi 
pnpm add postboi 
pnpm add postboi 
yarn add postboi 
yarn add postboi 

Set your provider and credentials

Point Postboi at a provider and give it the credentials it needs. Each provider reads its own env vars — see [Providers](/providers) for the full list.
# .env
POSTBOI_PROVIDER=resend
RESEND_API_KEY=re_xxxxxxxx
POSTBOI_FROM=no-reply@example.com
# .env
POSTBOI_PROVIDER=resend
RESEND_API_KEY=re_xxxxxxxx
POSTBOI_FROM=no-reply@example.com

Send

No provider import, no constructor — credentials come from the environment.
import { send } from 'postboi';

await send({
	to: 'contact@example.com',
	subject: 'Hi',
	body: '<p>Hello</p>'
});
import { send } from 'postboi';

await send({
	to: 'contact@example.com',
	subject: 'Hi',
	body: '<p>Hello</p>'
});

Environment variables

init writes POSTBOI_PROVIDER, the provider’s credential env vars, and optional POSTBOI_* defaults. send() reads them on every call.

Variable For
POSTBOI_PROVIDER which provider to use (resend, mailgun, postmark, …)
provider creds e.g. RESEND_API_KEY, or MAILGUN_API_KEY + MAILGUN_DOMAIN
POSTBOI_FROM / POSTBOI_TO / POSTBOI_CC / POSTBOI_BCC / POSTBOI_REPLY_TO optional defaults applied to every send

On SvelteKit

A contact-form action is a one-liner. See SvelteKit form actions.

// +page.server.ts
import { send } from 'postboi/kit';

export const actions = { default: send };
// +page.server.ts
import { send } from 'postboi/kit';

export const actions = { default: send };

On runtimes without ambient env vars (e.g. Cloudflare Workers), construct the provider directly — see Using a provider directly.