Resend Email Service Guide

Learn how to set up and automate transactional and marketing emails with Resend, including DNS configuration to avoid spam folders.

Create a Resend Account

Sign up for Resend to start sending emails
  1. Visit resend.com
  2. Click "Sign up" and create your account
  3. Verify your email address
  4. Complete the onboarding process
  5. You'll receive 3,000 free emails per month on the free tier

Get Your API Key

Generate and configure your Resend API key

1. Navigate to API Keys

In your Resend dashboard, go to API Keys

2. Create API Key

  • Click "Create API Key"
  • Name: "Production" (or your preferred name)
  • Permission: "Full Access" for transactional emails
  • Click "Create"

3. Copy Your API Key

Existing Buildfast Integration

Buildfast already uses Resend for transactional emails

1. Resend Instance

The Resend client is initialized in lib/resend.ts:

import { Resend } from 'resend'; export const resend = new Resend(process.env.RESEND_API_KEY);

2. Webhook Integration

Transactional emails are sent from the Stripe webhook when a payment is processed:

  • Located in app/api/webhooks/route.ts
  • Sends payment confirmation emails
  • Uses React Email templates for beautiful HTML emails
  • Handles different payment statuses

3. React Email Template

The email template is in emails/vercel-email.tsx and includes:

  • Company logo
  • Dynamic headings based on payment status
  • Formatted payment amounts
  • Professional email layout

Environment Variables

Configure your Resend API key

Add to your .env file:

# Resend Configuration
RESEND_API_KEY=re_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

DNS Configuration (Avoid Spam Folders)

Set up DKIM, SPF, and DMARC to improve email deliverability

1. Add Your Domain to Resend

  • Go to Domains in your Resend dashboard
  • Click "Add Domain"
  • Enter your domain (e.g., yourdomain.com)
  • Click "Add"

2. Configure DNS Records

Add these records to your DNS provider (e.g., Vercel Domains):

SPF Record:

TXT @ "v=spf1 include:amazonses.com ~all"

DKIM Records (3 CNAME records):

resend._domainkey → resend._domainkey.yourdomain.com.dkim.amazonses.com
resend2._domainkey → resend2._domainkey.yourdomain.com.dkim.amazonses.com
resend3._domainkey → resend3._domainkey.yourdomain.com.dkim.amazonses.com

DMARC Record (Optional but recommended):

TXT _dmarc "v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com"

3. Verify Domain

  • Return to Resend dashboard
  • Click "Verify DNS records"
  • Wait for all records to show green checkmarks
  • DNS propagation can take up to 48 hours

Sending Emails

Examples of sending transactional and marketing emails

1. Basic Email

await resend.emails.send({ from: 'Your App <noreply@yourdomain.com>', to: 'user@example.com', subject: 'Welcome to Our App!', html: '<p>Thanks for signing up!</p>' });

2. React Email Template

import { WelcomeEmail } from '@/emails/welcome'; await resend.emails.send({ from: 'Your App <noreply@yourdomain.com>', to: user.email, subject: 'Welcome aboard!', react: WelcomeEmail({ username: user.name, loginUrl: 'https://app.yourdomain.com/login' }) });

3. Batch Emails (Marketing)

await resend.batch.send([ { from: 'Newsletter <news@yourdomain.com>', to: 'subscriber1@example.com', subject: 'Monthly Update', react: NewsletterEmail({ name: 'John' }) }, { from: 'Newsletter <news@yourdomain.com>', to: 'subscriber2@example.com', subject: 'Monthly Update', react: NewsletterEmail({ name: 'Jane' }) } ]);

Best Practices

Tips for better email deliverability and user experience

Use a subdomain for transactional emails

e.g., noreply@mail.yourdomain.com

Always include an unsubscribe link

Required for marketing emails, good practice for all

Test emails before sending

Use Resend's test mode or send to yourself first

Monitor your sender reputation

Check bounce rates and spam complaints regularly

Use React Email for consistent templates

Ensures emails look great across all clients

Test Your Integration

Verify email sending is working
  1. Start your development server:pnpm dev
  2. Make a test purchase through Stripe Checkout
  3. Check your email for the payment confirmation
  4. Verify the email arrives and displays correctly
  5. Check Resend dashboard for email logs and status
  6. Monitor for any bounce backs or delivery issues