Email System
Transactional emails via Resend.
Overview
InkFlip uses Resend for transactional emails. All email logic is in lib/email.ts.
Email Types
| Trigger | Template | |
|---|---|---|
| Verification | User registration | emails/verification-email.tsx |
| Password Reset | Forgot password request | emails/reset-password-email.tsx |
| Welcome | After email verification | Inline |
| Purchase Confirmation | Payment webhook | Inline |
| Subscription Expiry | Days before expiry | Inline |
| Low Credits Alert | Balance below threshold | Inline |
| Newsletter confirmation | Newsletter subscribe/resubscribe | Inline |
Configuration
RESEND_API_KEY="re_your_api_key"
RESEND_FROM_EMAIL="InkFlip <noreply@inkflip.ink>"RESEND_FROM_EMAIL should use an address from a verified Resend domain. If it is not set, production can fall back to:
RESEND_VERIFIED_DOMAIN="inkflip.ink"
RESEND_FROM_NAME="InkFlip"For newsletter audience sync, configure:
RESEND_AUDIENCE_ID="your-resend-audience-id"Development Mode
In development without a verified domain, the app uses InkFlip <onboarding@resend.dev> as the sender fallback.
Production
For production, verify your sending domain in the Resend dashboard and set RESEND_FROM_EMAIL in Vercel. Also confirm NEXT_PUBLIC_APP_URL points to the production domain, because verification and password-reset links are built from it.
Namecheap DNS setup
- In Resend, open Domains, add
inkflip.ink, and copy the DNS records Resend shows for that domain. - In Namecheap, open Domain List →
inkflip.ink→ Advanced DNS. - Add each Resend record exactly as shown. Use the record type Resend provides, usually
TXTandCNAME. For Namecheap's Host field, enter only the host prefix, not the full domain suffix. For example, use_dmarcinstead of_dmarc.inkflip.ink. - Save the records and wait for DNS propagation. Then return to Resend and click Verify DNS Records.
- After Resend marks the domain verified, deploy with:
RESEND_FROM_EMAIL="InkFlip <noreply@inkflip.ink>"
NEXT_PUBLIC_APP_URL="https://inkflip.ink"
BETTER_AUTH_URL="https://inkflip.ink"The local .env.local can keep NEXT_PUBLIC_APP_URL="http://localhost:3000" for development. Production values should be set in the hosting provider environment.
Email Templates
Templates use React Email components in the emails/ directory:
// emails/verification-email.tsx
import { Html, Body, Text, Link } from '@react-email/components';
export default function VerificationEmail({ verificationUrl }: { verificationUrl: string }) {
return (
<Html>
<Body>
<Text>Click below to verify your email:</Text>
<Link href={verificationUrl}>Verify Email</Link>
</Body>
</Html>
);
}Error Handling
All email sends are wrapped in try-catch. Failed sends are logged and return a controlled result instead of throwing:
const result = await sendVerificationEmail(email, token);
if (!result.success) {
// handle email delivery failure
}