Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# .env.example — copy to .env and fill in values before running docker compose
#
# See docker-compose.yml and docker-compose.msgraph.yml for usage.

# ── HTTP Server ──────────────────────────────────────────────────────────────
# Required: API key checked via X-API-Key header on all non-health endpoints.
SERVE_API_KEY=change-me

# Optional: host port to publish (default 8080).
# SERVE_PORT=8080

# ── SMTP ─────────────────────────────────────────────────────────────────────
# Required for POST /smtp/sendmail to be available.
SMTPHOST=smtp.example.com
SMTPPORT=587
SMTPUSERNAME=user@example.com
SMTPPASSWORD=secret
SMTPFROM=user@example.com
SMTPSTARTTLS=true
# SMTPSMTPS=false
# SMTPSKIPVERIFY=false
# SMTPTLSVERSION=1.2
# SMTPAUTHMETHOD=auto

# ── Microsoft Graph ──────────────────────────────────────────────────────────
# Required for POST /msgraph/sendmail to be available
# (used with docker-compose.msgraph.yml).
MSGRAPHTENANTID=00000000-0000-0000-0000-000000000000
MSGRAPHCLIENTID=00000000-0000-0000-0000-000000000000
MSGRAPHSECRET=your-client-secret
# MSGRAPHPFX=
# MSGRAPHPFXPASS=
# MSGRAPHBEARERTOKEN=
# MSGRAPHMAILBOX=mailbox@example.com
# MSGRAPHPROXY=
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.24-alpine AS builder

WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go build -ldflags="-s -w" -o /gomailtest ./cmd/gomailtest


FROM alpine:3.21

RUN apk add --no-cache ca-certificates tzdata

COPY --from=builder /gomailtest /usr/local/bin/gomailtest

EXPOSE 8080

ENTRYPOINT ["gomailtest"]
CMD ["serve"]
31 changes: 31 additions & 0 deletions docker-compose.msgraph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# docker-compose.msgraph.yml — gomailtest serve (Microsoft Graph backend)
#
# Use this override file together with docker-compose.yml to enable the
# MS Graph sendmail endpoint in addition to (or instead of) SMTP:
#
# docker compose -f docker-compose.yml -f docker-compose.msgraph.yml up
#
# Required MS Graph environment variables:
# MSGRAPHTENANTID — Azure AD Tenant ID (GUID)
# MSGRAPHCLIENTID — Application (Client) ID (GUID)
#
# Authentication — set exactly one of:
# MSGRAPHSECRET — Client Secret
# MSGRAPHPFX — Path to .pfx certificate file (mount the file into the container)
# MSGRAPHPFXPASS — Password for the .pfx file (if using MSGRAPHPFX)
# MSGRAPHBEARERTOKEN — Pre-obtained Bearer token
#
# Optional MS Graph variables:
# MSGRAPHMAILBOX, MSGRAPHPROXY

services:
gomailtest-serve:
environment:
MSGRAPHTENANTID: "${MSGRAPHTENANTID}"
MSGRAPHCLIENTID: "${MSGRAPHCLIENTID}"
MSGRAPHSECRET: "${MSGRAPHSECRET:-}"
MSGRAPHPFX: "${MSGRAPHPFX:-}"
MSGRAPHPFXPASS: "${MSGRAPHPFXPASS:-}"
MSGRAPHBEARERTOKEN: "${MSGRAPHBEARERTOKEN:-}"
MSGRAPHMAILBOX: "${MSGRAPHMAILBOX:-}"
MSGRAPHPROXY: "${MSGRAPHPROXY:-}"
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# docker-compose.yml — gomailtest serve (SMTP backend)
#
# Copy .env.example to .env and fill in values before running:
# docker compose up
#
# Required environment variables:
# SERVE_API_KEY — X-API-Key header value required by all non-health endpoints
# SMTPHOST — SMTP server hostname
#
# Optional SMTP variables (see docs/protocols/smtp.md for the full list):
# SMTPPORT, SMTPUSERNAME, SMTPPASSWORD, SMTPFROM,
# SMTPSTARTTLS, SMTPSMTPS, SMTPSKIPVERIFY, SMTPTLSVERSION,
# SMTPAUTHMETHOD, SMTPTIMEOUT

services:
gomailtest-serve:
build:
context: .
dockerfile: Dockerfile
image: gomailtest:latest
command: ["serve"]
ports:
- "${SERVE_PORT:-8080}:8080"
environment:
SERVE_API_KEY: "${SERVE_API_KEY}"
SERVE_PORT: "8080"
SMTPHOST: "${SMTPHOST}"
SMTPPORT: "${SMTPPORT:-25}"
SMTPUSERNAME: "${SMTPUSERNAME:-}"
SMTPPASSWORD: "${SMTPPASSWORD:-}"
SMTPFROM: "${SMTPFROM:-}"
SMTPSTARTTLS: "${SMTPSTARTTLS:-false}"
SMTPSMTPS: "${SMTPSMTPS:-false}"
SMTPSKIPVERIFY: "${SMTPSKIPVERIFY:-false}"
SMTPTLSVERSION: "${SMTPTLSVERSION:-1.2}"
SMTPAUTHMETHOD: "${SMTPAUTHMETHOD:-auto}"
SMTPTIMEOUT: "${SMTPTIMEOUT:-}"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s
Loading