---
title: "Send email from NestJS over SMTP"
description: "Nodemailer inside a NestJS provider."
url: https://www.unitpost.com/guides/smtp/nestjs
section: SMTP
updated: 2026-08-28
---
# Send email from NestJS over SMTP

## Connection settings

- **Host**: smtp.unitpost.com
- **Username**: unitpost (always this literal value)
- **Password**: Your Unitpost API key (must carry emails:send)
- **Port (STARTTLS)**: 587 (or 2587 if blocked)
- **Port (implicit TLS)**: 465 (or 2465 if blocked)
- **From address**: Any address on a verified domain

## Send email from NestJS over SMTP

> Nodemailer inside a NestJS provider.

Inject a Nodemailer transport in NestJS and send over Unitpost SMTP. Same credentials as any other stack.

### 1. Install Nodemailer

```bash
npm install nodemailer
npm install -D @types/nodemailer
```

### 2. Provide a transporter

```typescript
import { Injectable } from "@nestjs/common";
import nodemailer from "nodemailer";

@Injectable()
export class MailService {
  private transporter = nodemailer.createTransport({
    host: "smtp.unitpost.com",
    port: 587,
    secure: false,
    auth: {
      user: "unitpost",
      pass: process.env.UNITPOST_API_KEY,
    },
  });

  sendWelcome(to: string) {
    return this.transporter.sendMail({
      from: "you@yourdomain.com",
      to,
      subject: "Welcome",
      html: "<p>Sent via SMTP.</p>",
    });
  }
}
```

### 3. Verify delivery

The send shows up in Activity. See also Nodemailer (/guides/smtp/nodemailer).

## Related

- [Send email from Express over SMTP](https://www.unitpost.com/guides/smtp/express): Nodemailer from an Express route.
- [Send email from Python over SMTP](https://www.unitpost.com/guides/smtp/python): stdlib smtplib — no framework required.
- [Send email from Flask over SMTP](https://www.unitpost.com/guides/smtp/flask): Flask-Mail pointed at Unitpost.
