Getting Started with MailPort

MailPort is a type-safe Node.js email SDK for Node.js 22+.

1. Installation

Install the unified umbrella package:

npm install mailport

2. Basic Configuration

Create a mailer instance using environment variables for credentials:

import { createMailer, smtp } from 'mailport';

const mailer = createMailer({
  transport: smtp({
    host: process.env.SMTP_HOST!,
    port: Number(process.env.SMTP_PORT) || 587,
    tls: 'starttls',
    auth: {
      user: process.env.SMTP_USER!,
      pass: process.env.SMTP_PASSWORD!,
    },
  }),
});

const result = await mailer.send({
  from: 'app@example.com',
  to: 'user@example.com',
  subject: 'Welcome to MailPort',
  text: 'Your email setup is running cleanly.',
});

console.log('Accepted recipients:', result.accepted);