GuideIntegrationsAuth.js

    Auth.js / NextAuth Integration

    Connect NextAuth.js or Auth.js to Simply Send to deliver passwordless sign-in emails (Magic Links) from your custom domain.

    Overview

    Auth.js (formerly NextAuth.js) is a self-hosted library that uses NodeMailer to dispatch email verification magic links. By utilizing Simply Send's SMTP server, you get:

    Verified Sender Identity

    Magic links will arrive from [email protected].

    Detailed Tracking

    Monitor delivery rates, open rates, and bounces for your passwordless login flows in the Simply Send dashboard.

    Setup Guide

    To integrate Auth.js with Simply Send, provision SMTP credentials and add them as environment variables in your project.

    1. 1
      Provision Credentials in Simply SendGo to the Integrations tab in your User Portal and click Connect on the Auth.js card. Choose a credential label and click Create Credentials. Copy the details.
    2. 2
      Configure Environment VariablesAdd these configuration variables to your Next.js .env.local or environment configurations. Use the SMTP Server value shown in the Simply Send credential setup popup:
      EMAIL_SERVER_HOST=<smtp-server-from-setup>
      EMAIL_SERVER_PORT=587
      EMAIL_SERVER_USER=your-generated-username
      EMAIL_SERVER_PASSWORD=your-generated-password
      [email protected]
    3. 3
      Wire the Email Provider in Auth.jsIn your `auth.ts` or `[...nextauth].ts` setup file, initialize the standard EmailProvider:
      import EmailProvider from "next-auth/providers/email";
      
      export const authOptions = {
        providers: [
          EmailProvider({
            server: {
              host: process.env.EMAIL_SERVER_HOST,
              port: Number(process.env.EMAIL_SERVER_PORT),
              auth: {
                user: process.env.EMAIL_SERVER_USER,
                pass: process.env.EMAIL_SERVER_PASSWORD,
              },
            },
            from: process.env.EMAIL_FROM,
          }),
        ],
      };
    4. 4
      Add Compliance Variables to Your Email HTMLSimply Send requires two compliance variables in every email HTML body. Add them inside your custom sendVerificationRequest function (or directly in the html string passed to the mailer). These are replaced at send time with your configured unsubscribe link and company address from the Templates → Compliance section in Simply Send:
      <!-- Required in every email HTML -->
      <div>{{unsubscribe_email_html}}</div>
      <div>{{company_address_html}}</div>
      
      <!-- Optional -->
      <div>{{report_abuse_email_html}}</div>
      Emails missing these variables will be rejected by Simply Send with a MISSING_TEMPLATE_VARIABLES error.