---
title: "Send email with PHPMailer over SMTP"
description: "PHPMailer SMTP mode pointed at Unitpost."
url: https://www.unitpost.com/guides/smtp/php
section: SMTP
updated: 2026-08-28
---
# Send email with PHPMailer 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 with PHPMailer over SMTP

> PHPMailer SMTP mode pointed at Unitpost.

Use PHPMailer's SMTP mode to deliver through Unitpost from plain PHP. Port 587 with STARTTLS; don't use port 25.

### 1. Install PHPMailer

Add it via Composer.

```bash
composer require phpmailer/phpmailer
```

### 2. Configure and send

Set PHPMailer to SMTP mode with your Unitpost credentials.

```php
<?php
use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host       = "smtp.unitpost.com";
$mail->SMTPAuth   = true;
$mail->Username   = "unitpost";
$mail->Password   = getenv("UNITPOST_API_KEY");
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port       = 587;

$mail->setFrom("you@yourdomain.com", "Your App");
$mail->addAddress("customer@example.com");
$mail->isHTML(true);
$mail->Subject = "Hello from Unitpost";
$mail->Body    = "<h1>Welcome!</h1><p>Sent via SMTP.</p>";
$mail->send();
```

### 3. Verify delivery

The message appears in your Unitpost Activity view with full tracking.

## Related

- [Send email from Next.js over SMTP](https://www.unitpost.com/guides/smtp/nextjs): Nodemailer in an App Router Route Handler.
- [Send email from NestJS over SMTP](https://www.unitpost.com/guides/smtp/nestjs): Nodemailer inside a NestJS provider.
- [Send email from Express over SMTP](https://www.unitpost.com/guides/smtp/express): Nodemailer from an Express route.
