Email — Postfix SMTP

Host: Postfix installed on the server host (not in Docker) Relay: smtp.gmail.com:587 Gmail Account: aboodm7med1995@gmail.com The Coderz Stack sends automated emails for Grafana alerts and Prefect flow notifications via a Postfix SMTP relay configured on the host server. Postfix relays all outgoing mail through Gmail’s SMTP servers.

How It Works

Grafana Alert / Prefect Flow


  host.docker.internal:25
  (Postfix on host, port 25)


  smtp.gmail.com:587
  (Gmail relay, TLS)


  aboodm7med1995@gmail.com
Docker containers reach the host Postfix via host.docker.internal — a special DNS name that resolves to the Docker host’s IP.

When Emails Are Sent

TriggerFromSubject
CPU > 80% for 5minGrafana[ALERTING] High CPU Usage
RAM > 85% for 5minGrafana[ALERTING] High Memory Usage
Disk > 90% for 5minGrafana[ALERTING] High Disk Usage
Containers < 6 for 2minGrafana[ALERTING] Low Container Count
Service health check failsPrefect[ALERT] Service Down
CPU/RAM/Disk threshold exceededPrefect[THRESHOLD] Resource Alert
Container restart loop detectedPrefect[ALERT] Container Restarting
k3s pod failurePrefect[ALERT] Kubernetes Health Check Failed
Daily summaryPrefect[REPORT] Daily Stack Summary
Weekly cleanupPrefect[REPORT] Weekly Cleanup Summary

Test Email

Send a test email from the host:
echo "Test from Coderz server" | mail -s "Coderz Test Email" aboodm7med1995@gmail.com

Test Email from Docker Container

docker exec coderz-prefect-worker \
  sh -c 'echo "Test" | sendmail -v aboodm7med1995@gmail.com'

Postfix Configuration Files

FilePurpose
/etc/postfix/main.cfMain Postfix configuration
/etc/postfix/sasl_passwdGmail credentials (chmod 600)
/etc/postfix/sasl_passwd.dbCompiled credentials database

Check Email Delivery

# Check mail queue
mailq

# View Postfix logs
tail -f /var/log/mail.log

# Force flush the queue
postfix flush

Grafana SMTP Settings

In docker-compose.yml under the grafana service:
environment:
  GF_SMTP_ENABLED: "true"
  GF_SMTP_HOST: "host.docker.internal:25"
  GF_SMTP_FROM_ADDRESS: "alerts@coderz.local"
  GF_SMTP_FROM_NAME: "Coderz Alerts"
extra_hosts:
  - "host.docker.internal:host-gateway"
The extra_hosts entry is required — it maps host.docker.internal to the Docker gateway IP so the container can reach the host’s Postfix.