All products

NodemailerOfficial

Server-only Nodemailer SMTP plugin for BitaKit apps.

bitakit · Plugin for every BitaKit app

Type
Package
Needs a build
Kind
Plugin
BitaKit
Version
0.3.2
Latest
Works with
Any app
Every BitaKit app
Versions
1
version
Publisher
bitakit
Official

Preview

1 picture

Nodemailer

About

@bitakit/nodemailer

A server-side SMTP plugin for the shared BitaKit email service. There is no browser installation and no global SMTP instance: each runtime owns its transport and closes it on unmount.

import { createRuntime, getService } from '@bitakit/core';
import { emailService } from '@bitakit/email';
import { nodemailerPlugin } from '@bitakit/nodemailer';
import { betterAuthEmail } from '@bitakit/better-auth/email';

const runtime = createRuntime({
  plugins: [
    nodemailerPlugin({
      host: process.env.SMTP_HOST!,
      port: Number(process.env.SMTP_PORT),
      secure: process.env.SMTP_SECURE === 'true',
      user: process.env.SMTP_USER!,
      password: process.env.SMTP_PASSWORD!,
      from: process.env.SMTP_FROM!,
    }),
  ],
});
const dispose = runtime.mount();
const callbacks = betterAuthEmail(getService(runtime.services, emailService), {
  invitationURL: (id) => new URL(`/invitations/${encodeURIComponent(id)}`, appOrigin).href,
});
// Pass callbacks to your server-side Better Auth configuration.
// Call dispose when the server runtime is shut down, not after every request.

The route in the example must exist in the host. appOrigin comes from trusted server configuration. The host loads the local env file; the plugin never reads secret files or environment variables on its own. from must contain an address, for example Demo <sender@example.test>; a display name alone is not enough.

TLS is required, including with STARTTLS. The browser entry refuses to run. Credentials, message text and recipients are never logged. Registering the plugin opens no SMTP connection and sends nothing. The automated tests use transport doubles; no real test email is sent without an explicit request.

Setup

  1. Register `nodemailerPlugin({ host, port, secure, user, password, from })` in the app's server runtime with the SMTP settings from the server's environment (SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USER, SMTP_PASSWORD, SMTP_FROM); it provides the shared email service of `@bitakit/email`.
  2. Use an SMTP server with TLS or STARTTLS, and a sender (`from`) with an address, for example `App <mail@example.com>`.

Permissions

It adds and checks no permissions.

Information

Publisher
bitakit · Official
Type
PackageNeeds installation: add it to the app's code and build the app.
Kind
Plugin
Works with
Every BitaKit app
Categories
Email
Nodemailer · BitaKit Marketplace