Skip to content

Add with-email-local-smtp example#95885

Open
tsokolovs wants to merge 1 commit into
vercel:canaryfrom
tsokolovs:examples/with-email-local-smtp
Open

Add with-email-local-smtp example#95885
tsokolovs wants to merge 1 commit into
vercel:canaryfrom
tsokolovs:examples/with-email-local-smtp

Conversation

@tsokolovs

@tsokolovs tsokolovs commented Jul 17, 2026

Copy link
Copy Markdown

What?

Adds a new example demonstrating Mailtrap Local as the local SMTP catcher with Auth.js (NextAuth) to send a magic-link email sign-in.

Why?

There are many email providers, and if you are working on something before actually using it, you might either run out of free credits or have to start spending money just so that you can test your work. With this local setup it is easy and free to test your emails on your local machine.

How?

  • auth.ts configures NextAuth with PosgresAdapter and Nodemailer.
  • using docker-compose to spin up local services, including Mailtrap local and PostgreSQL.
  • init.sql taken from Auth.js documentation to provide necessary set-up for magic links.
  • README.md provides a step-by-step guide that I've tested myself.

Add an example showing Auth.js (NextAuth) magic-link email sign in wired
to a local SMTP catcher, so email flows can be tested during development
without sending real mail.

- Nodemailer (email) provider sends the sign-in link to Mailtrap Local,
  a single-binary MIT-licensed SMTP catcher with a web UI, started via
  docker-compose (SMTP on 3535, UI on 3550).
- Postgres (also in docker-compose) persists Auth.js verification tokens
  via @auth/pg-adapter; schema is loaded automatically from init.sql.
- Includes a small server action to send an arbitrary test email to the
  catcher so the setup can be verified independently of the auth flow.
@tsokolovs
tsokolovs force-pushed the examples/with-email-local-smtp branch from fcacb19 to 0c3ed28 Compare July 17, 2026 06:09
@tsokolovs
tsokolovs marked this pull request as ready for review July 17, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant