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

> Flask-Mail pointed at Unitpost.

Configure Flask-Mail's SMTP settings for Unitpost and send from a verified domain.

### 1. Install Flask-Mail

```bash
pip install Flask-Mail
```

### 2. Configure and send

```python
import os
from flask import Flask
from flask_mail import Mail, Message

app = Flask(__name__)
app.config.update(
    MAIL_SERVER="smtp.unitpost.com",
    MAIL_PORT=587,
    MAIL_USE_TLS=True,
    MAIL_USERNAME="unitpost",
    MAIL_PASSWORD=os.environ["UNITPOST_API_KEY"],
    MAIL_DEFAULT_SENDER="you@yourdomain.com",
)
mail = Mail(app)

def send_welcome(to: str) -> None:
    msg = Message("Welcome", recipients=[to], html="<p>Sent via SMTP.</p>")
    mail.send(msg)
```

### 3. Verify delivery

Check Activity. Bare Python: smtplib (/guides/smtp/python).

## Related

- [Send email from FastAPI over SMTP](https://www.unitpost.com/guides/smtp/fastapi): smtplib from a FastAPI dependency.
- [Send email from Go over SMTP](https://www.unitpost.com/guides/smtp/go): net/smtp with STARTTLS.
- [Send email from Spring Boot over SMTP](https://www.unitpost.com/guides/smtp/spring): JavaMailSender properties pointed at Unitpost.
