@arraypress/email
v1.0.0
Published
Multi-provider email sending — Resend, Postmark, AWS SES, Cloudflare. Zero dependencies.
Downloads
45
Maintainers
Readme
@arraypress/email
Multi-provider email sending for edge runtimes. Swap providers by changing one config line.
Supports Resend, Postmark, AWS SES, and Cloudflare Email Workers. Zero dependencies — uses the fetch API directly, no SDKs needed.
Installation
npm install @arraypress/emailUsage
import { createEmailClient } from '@arraypress/email';
const email = createEmailClient({
provider: 'resend',
apiKey: process.env.RESEND_API_KEY,
from: { name: 'My Store', email: '[email protected]' },
});
const result = await email.send({
to: '[email protected]',
subject: 'Your order is ready',
html: '<h1>Thanks for your purchase!</h1>',
text: 'Thanks for your purchase!',
});
if (result.success) {
console.log('Sent via', result.provider, result.id);
} else {
console.error('Failed:', result.error);
}Providers
Resend
createEmailClient({
provider: 'resend',
apiKey: 're_xxx',
from: { name: 'Store', email: '[email protected]' },
});Postmark
createEmailClient({
provider: 'postmark',
apiKey: 'your-server-token',
from: { name: 'Store', email: '[email protected]' },
});AWS SES
createEmailClient({
provider: 'ses',
apiKey: 'AKIAIOSFODNN7EXAMPLE', // AWS access key
secretKey: 'wJalrXUtnFEMI/K7MDENG...', // AWS secret key
region: 'us-east-1', // optional, default us-east-1
from: { name: 'Store', email: '[email protected]' },
});No AWS SDK required — signs requests using Web Crypto API.
Cloudflare Email Workers
createEmailClient({
provider: 'cloudflare',
binding: env.SEND_EMAIL, // from wrangler.toml
from: { name: 'Store', email: '[email protected]' },
});API
createEmailClient(config)
Returns an email client with a send method.
Config:
provider—'resend','postmark','ses', or'cloudflare'apiKey— API key (required for resend, postmark, ses)secretKey— AWS secret key (SES only)region— AWS region (SES only, default'us-east-1')binding— Cloudflare Email binding (cloudflare only)from— Default sender{ name?, email }
client.send(params)
Send an email. Returns { success, provider, id?, error? }.
Params:
to— recipient email or array of emailssubject— email subjecthtml— HTML bodytext— plain text bodyfrom— override default senderreplyTo— reply-to address
Switching Providers
Change one line — the send() API is identical across all providers:
// Before: Resend
const email = createEmailClient({ provider: 'resend', apiKey: '...', from: sender });
// After: Postmark (same send() calls work)
const email = createEmailClient({ provider: 'postmark', apiKey: '...', from: sender });License
MIT
