Email System
Transactional emails via Resend.
Overview
Videa 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 |
Configuration
RESEND_API_KEY="re_your_api_key"
RESEND_FROM_EMAIL="Videa <noreply@yourdomain.com>"Development Mode
In development without a verified domain, Resend uses onboarding@resend.dev as the sender. You'll see this in your console logs.
Production
For production, verify your domain in the Resend dashboard and set RESEND_FROM_EMAIL to use your verified domain.
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({ url }: { url: string }) {
return (
<Html>
<Body>
<Text>Click below to verify your email:</Text>
<Link href={url}>Verify Email</Link>
</Body>
</Html>
);
}Error Handling
All email sends are wrapped in try-catch. Failed sends are logged but don't crash the application. The system returns a success/error tuple instead of throwing:
const [success, error] = await sendVerificationEmail(email, token);