Email

Email Setup

Configure email providers - Resend, SMTP, or Console for development

TL;DR: Emails log to console by default. Set EMAIL_PROVIDER=resend for production.

Straktur supports multiple email providers through a unified adapter system.

Supported Providers

ProviderBest ForEdge Runtime
ConsoleDevelopment
ResendProduction
SMTPSelf-hosted, Gmail, SendGrid

Console

Default for development - emails are logged to your terminal instead of being sent.

EMAIL_PROVIDER=console
EMAIL_FROM=noreply@localhost

No configuration needed. Just check your terminal for email output.

For security, HTML content is not logged (may contain tokens). Only subject, recipient, and text preview are shown.


Resend

Recommended for production - modern API, great developer experience.

Setup

  1. Create account at resend.com
  2. Verify your domain in Domains section
  3. Create API key in API Keys
EMAIL_PROVIDER=resend
RESEND_API_KEY=re_123456789
EMAIL_FROM=[email protected]

You must verify your domain to send from custom addresses. Unverified accounts can only send to your own email.


SMTP

Universal option - works with any email service that supports SMTP.

Setup

EMAIL_PROVIDER=smtp
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your-username
SMTP_PASS=your-password
SMTP_SECURE=false
EMAIL_FROM=[email protected]

Common SMTP Configurations

SMTP does not work on Edge Runtime (Vercel Edge Functions). Use Resend for edge deployments.


Docker Development

Docker Compose includes Mailpit - a local SMTP server with web UI.

EMAIL_PROVIDER=smtp
SMTP_HOST=mailpit
SMTP_PORT=1025
EMAIL_FROM=noreply@localhost

View emails at http://localhost:8080


Environment Variables

VariableRequiredDefaultDescription
EMAIL_PROVIDERNoconsoleconsole, resend, or smtp
EMAIL_FROMYes-Sender address
EMAIL_REPLY_TONo-Reply-to address
RESEND_API_KEYIf Resend-Resend API key
SMTP_HOSTIf SMTP-SMTP server hostname
SMTP_PORTIf SMTP587SMTP port
SMTP_USERIf SMTP-SMTP username
SMTP_PASSIf SMTP-SMTP password
SMTP_SECUREIf SMTPfalseUse SSL/TLS

Sending Emails

Basic Email

import { sendEmail } from "@/lib/email"

await sendEmail({
  to: "[email protected]",
  subject: "Hello",
  html: "<h1>Welcome!</h1>",
  text: "Welcome!", // plaintext fallback
})

With React Email Template

import { sendTemplatedEmail } from "@/lib/email"
import { WelcomeEmail } from "@/emails/welcome-email"

await sendTemplatedEmail(
  WelcomeEmail,
  { userName: "John", loginUrl: "https://..." },
  { to: "[email protected]", subject: "Welcome to Straktur" }
)

Common Issues

On this page