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

> MailKit pointed at Unitpost.

System.Net.Mail.SmtpClient is obsolete. Use MailKit, STARTTLS on 587, username `unitpost`, API key as password.

### 1. Add MailKit

```bash
dotnet add package MailKit
```

### 2. Send

```csharp
using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;

var message = new MimeMessage();
message.From.Add(MailboxAddress.Parse("you@yourdomain.com"));
message.To.Add(MailboxAddress.Parse("customer@example.com"));
message.Subject = "Hello from .NET";
message.Body = new TextPart("html") { Text = "<p>Sent via SMTP.</p>" };

using var client = new SmtpClient();
await client.ConnectAsync("smtp.unitpost.com", 587, SecureSocketOptions.StartTls);
await client.AuthenticateAsync("unitpost", Environment.GetEnvironmentVariable("UNITPOST_API_KEY"));
await client.SendAsync(message);
await client.DisconnectAsync(true);
```

### 3. Verify delivery

Confirm in Activity.

## Related

- [Send email with Nodemailer over SMTP](https://www.unitpost.com/guides/smtp/nodemailer): createTransport pointed at Unitpost — Node, Next.js, or NestJS.
- [Send Supabase auth email over SMTP](https://www.unitpost.com/guides/smtp/supabase): Magic links and confirmations from your verified domain.
- [Send WordPress email over SMTP](https://www.unitpost.com/guides/smtp/wordpress): WP Mail SMTP pointed at Unitpost instead of PHP mail().
