Menu

How to send email from Next.js with OwnMailServer
📰

How to send email from Next.js with OwnMailServer

DEV Community: react·Hani Khanani·about 9 hours ago
#lFDkN6bx
#devtoreact#devto#dev#email#resend
Reading 0:00
15s threshold

To send email from Next.js, call an email API from server code: a route handler or a Server Action, never a client component. With OwnMailServer that's one fetch to POST https://api.ownmailserver.com/emails , with your API key read from an environment variable. If your app already uses Resend's SDK or React Email, keep the code: set RESEND_BASE_URL=https://api.ownmailserver.com and swap in our API key.

Your situation Use New packages

Starting fresh fetch to POST /emails None

Already on Resend's SDK The same SDK with RESEND_BASE_URL None

Want templates as React components React Email, with either of the above @react-email/components

A library that only speaks SMTP Nodemailer to smtp.ownmailserver.com:587 nodemailer

The examples use the App Router. The same calls work in the Pages Router's API routes.

Step 1: Add your API key

You need an approved OwnMailServer account with a verified sending domain : the from address must be on it, or the API returns 403 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.