[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# How to send automated emails from a Next.js app using a custom mail server

19 views · 0 likes · 4 posts


Sanjay Joshi (@sanjayjoshi) · 2026-03-20

I want to send automated emails from my `Next.js` website. Is it possible to connect my own mail server to it?


Pauline P. Narvas (@pawlean) · 2026-03-20

Hey, @sanjayjoshi! :slight_smile: 

I recommend checking out Resend:

https://resend.com/


ADALIGO (@nfdcopilot-5305) · 2026-03-20

Hey @sanjayjoshi! 👋

Yes, you can definitely use your own mail server with [Next.js](https://nextjs.org/). The usual way is to create an API route and use **Nodemailer** to send emails through your SMTP server. If you want something simpler and more reliable, modern tools like **Resend** (as recommended by **[Pauline P. Narvas](https://community.vercel.com/u/pawlean)**), **[SendGrid](https://www.twilio.com/en-us/sendgrid)**, or **[Postmark](https://www.mailgun.com/)**[ ](https://www.mailgun.com/), or **[Nodemailer](https://nodemailer.com/) ,** make it really easy to send transactional emails without worrying about spam issues.


Al441395 (@al441395-9679) · 2026-03-27

[quote="Sanjay Joshi, post:1, topic:36660, username:sanjayjoshi"]
I want to send automated emails from my `Next.js` website. Is it possible to connect my own mail server to it?

[/quote]

@sanjayjoshi Hi Mate

You can connect your own mail server (SMTP) to a Next.js app, but it’s usually not the best approach when you’re deploying on Vercel.

SMTP connections can be unreliable in serverless environments (timeouts, blocked ports, etc.), and you also have to deal with deliverability issues like SPF/DKIM setup yourself.

A much easier and more reliable option is to use a service like Resend. It’s designed specifically for apps running on Vercel and integrates really smoothly with Next.js.

Setup is very simple:

* Install the SDK

* Add your API key

* Send emails via their API (no SMTP needed)

Example:

```
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

await resend.emails.send({
  from: 'onboarding@yourdomain.com',
  to: 'user@example.com',
  subject: 'Hello!',
  html: '<p>It works 🎉</p>',
});

```

So in short:
Yes, SMTP is possible, but using Resend (or a similar email API) is the recommended and more reliable approach on Vercel.