Plunk Integration
How the Plunk email service is integrated.
This document explains how the Plunk email service is integrated for sending transactional emails. Plunk can be a cost-effective alternative to other providers, leveraging Amazon SES under the hood, and offers self-hosting options.
Configuration
-
Provider Selection: To use Plunk, the
NEXT_PUBLIC_EMAIL_PROVIDERenvironment variable must be set to"plunk". This can be done via the configuration UI (/configure) or directly in the.envfile. -
Secret Key: The
PLUNK_SECRET_KEYenvironment variable must contain a valid Secret Key obtained from your Plunk account or self-hosted instance.
How it Works
When NEXT_PUBLIC_EMAIL_PROVIDER is set to "plunk", the core email router calls the Plunk-specific sending logic located in src/server/email/send-email-plunk.ts.
This logic:
-
Uses the official
@plunk/nodeSDK. -
Checks if
PLUNK_SECRET_KEYis configured (isPlunkConfigured). -
Takes a standard
EmailPayload. -
Renders React components to HTML using
@react-email/render, as Plunk primarily uses the HTML body. -
Calls
plunk.emails.sendwithto,subject, andbody(HTML or text). -
Includes basic error handling.
-
Cost-Effective: Plunk often presents a cheaper alternative, especially when self-hosted or using their managed service built on AWS SES.
-
Daily Sending Limit: Be aware of potential sending limits, especially on free/basic tiers. See the General Email Configuration for discussion and mitigation strategies.
-
From Address: The
fromaddress is typically managed within your Plunk dashboard settings, not directly in the API call. -
Self-Hosting: Plunk can be self-hosted, giving you more control over your email infrastructure. Setup details are beyond this document; refer to official Plunk documentation.