Create an Email Client

Learn how to set up an email service provider for your Codelesskit project. Choose from Resend, SendGrid, or Postmark.

Overview

Before installing the email feature, you need to set up an email service provider account and get your API key. This guide will walk you through setting up each provider. Once your email client is ready, you can install the email feature using:

pnpm dlx codelesskit@latest add emails

Resend

Resend is a modern email API built for developers. It offers a great developer experience with excellent documentation and developer tools.

Step 1: Create a Resend Account

Visit resend.com and sign up for a free account. The free tier includes 3,000 emails per month.

Step 2: Verify Your Domain

Add and verify your domain in the Resend dashboard. This allows you to send emails from your own domain (e.g., noreply@yourdomain.com). For development, you can use Resend's test domain.

Step 3: Get Your API Key

Navigate to API Keys in the Resend dashboard and create a new API key. Copy the key immediately as it won't be shown again.

Step 4: Add to Environment Variables

Add the API key to your `.env` file:

.env
1
2
3
4
5
6
7
# Email Configuration
EMAIL_FROM="noreply@yourdomain.com"
EMAIL_REPLY_TO="support@yourdomain.com"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
 
# Resend Configuration
RESEND_API_KEY="re_xxxxxxxxxxxxx"

Next Steps

Now you can install the email feature. See the Emails module documentation for installation instructions.

SendGrid

SendGrid is a popular email service with extensive features and high deliverability rates. It offers a free tier with 100 emails per day.

Step 1: Create a SendGrid Account

Visit sendgrid.com and sign up for a free account.

Step 2: Verify Your Sender Identity

In the SendGrid dashboard, go to Settings → Sender Authentication. You can either verify a single sender email address (for testing) or authenticate your entire domain (for production).

Step 3: Create an API Key

Navigate to Settings → API Keys in the SendGrid dashboard. Click "Create API Key" and give it a name (e.g., "Codelesskit Production"). Select "Full Access" or "Restricted Access" with Mail Send permissions. Copy the API key immediately.

Step 4: Add to Environment Variables

Add the API key to your `.env` file:

.env
1
2
3
4
5
6
7
# Email Configuration
EMAIL_FROM="noreply@yourdomain.com"
EMAIL_REPLY_TO="support@yourdomain.com"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
 
# SendGrid Configuration
SENDGRID_API_KEY="SG.xxxxxxxxxxxxx"

Next Steps

Now you can install the email feature. See the Emails module documentation for installation instructions.

Postmark

Postmark is a reliable transactional email service focused on deliverability. It offers a free tier with 100 emails per month.

Step 1: Create a Postmark Account

Visit postmarkapp.com and sign up for a free account.

Step 2: Create a Server

In the Postmark dashboard, create a new Server. A Server in Postmark represents an application or environment (e.g., Production, Staging). Give it a descriptive name.

Step 3: Verify Your Domain

Add and verify your sending domain in the Server settings. Postmark will provide DNS records that you need to add to your domain. This is required for sending emails.

Step 4: Get Your Server API Token

In your Server settings, find the "API Tokens" section. Copy the Server API Token. This is what you'll use to authenticate API requests.

Step 5: Add to Environment Variables

Add the API token to your `.env` file:

.env
1
2
3
4
5
6
7
# Email Configuration
EMAIL_FROM="noreply@yourdomain.com"
EMAIL_REPLY_TO="support@yourdomain.com"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
 
# Postmark Configuration
POSTMARK_API_KEY="your-server-api-token-here"

Next Steps

Now you can install the email feature. See the Emails module documentation for installation instructions.

Create an Email Client | Codelesskit