Skip to content

Manual Installation

For running directly on a host without containers.

Prerequisites: Python 3.11+, uv, and OpenSSL (for test certificates).

Steps

# 1. Clone and enter the repo
git clone https://github.com/justiniven/smtp-oauth-relay.git
cd smtp-oauth-relay

# 2. Install dependencies (creates .venv)
uv sync --no-dev

# 3. Run the server
cd src
TLS_SOURCE=file REQUIRE_TLS=true uv run python main.py

Warning

Make sure to install the required dependencies after each update. If upgrading from a version earlier than 1.7.1, use the new build system, uv instead of pip.

Generate a self-signed certificate (testing)

mkdir -p certs
openssl req -x509 -newkey rsa:2048 -nodes \
  -keyout certs/key.pem -out certs/cert.pem -days 365 \
  -subj "/CN=localhost"

Warning

Self-signed certificates are for testing only. Use a CA-issued certificate (e.g. Let's Encrypt) in production.

Run as a systemd service (Linux)

/etc/systemd/system/smtp-relay.service:

[Unit]
Description=SMTP OAuth Relay
After=network.target

[Service]
Type=simple
User=smtp-relay
WorkingDirectory=/opt/smtp-oauth-relay/src
Environment="TLS_SOURCE=file"
Environment="REQUIRE_TLS=true"
Environment="TLS_CERT_FILEPATH=/opt/smtp-oauth-relay/certs/cert.pem"
Environment="TLS_KEY_FILEPATH=/opt/smtp-oauth-relay/certs/key.pem"
ExecStart=/opt/smtp-oauth-relay/.venv/bin/python main.py
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now smtp-relay
sudo systemctl status smtp-relay

Next steps