Sign inSign up

agna/postfix-smtp

By agna

•Updated over 1 year ago

Modern Postfix SMTP server with SASL authentication, TLS & DKIM signing capability. Ubuntu 24.04

Image
Networking
Web servers
0

440

agna/postfix-smtp repository overview

⁠Postfix SMTP Server with DKIM

Modern Postfix SMTP server with SASL authentication, TLS encryption, and DKIM signing support.

⁠Quick Start

docker run -d \
  -e maildomain=mail.example.com \
  -e smtp_user=user1:pass1 \
  -p 25:25 -p 587:587 \
  agna/postfix-smtp

⁠Features

  • SMTP with STARTTLS (port 587)
  • SASL authentication
  • DKIM signing
  • Multiple user support
  • Let's Encrypt support
  • Ubuntu 24.04 base

⁠Environment Variables

  • maildomain: Server hostname
  • smtp_user: User credentials (format: user:pass,user2:pass2)

⁠Basic Setup

  1. Create directories:
mkdir -p {certs,domainkeys}
  1. Generate self-signed certificate (development):
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout certs/smtp.key -out certs/smtp.crt
  1. Generate DKIM keys:
opendkim-genkey -D domainkeys/ -d yourdomain.com -s mail
  1. Run container:
docker run -d \
  -e maildomain=mail.yourdomain.com \
  -e smtp_user=user1:pass1,user2:pass2 \
  -v $PWD/certs:/etc/postfix/certs \
  -v $PWD/domainkeys:/etc/opendkim/domainkeys \
  -p 25:25 \
  -p 587:587 \
  agna/postfix-smtp

⁠Let's Encrypt Setup

  1. Install certbot:
sudo apt-get install certbot
  1. Get certificate:
sudo certbot certonly --standalone -d mail.yourdomain.com
  1. Copy certificates:
sudo cp /etc/letsencrypt/live/mail.yourdomain.com/fullchain.pem certs/smtp.crt
sudo cp /etc/letsencrypt/live/mail.yourdomain.com/privkey.pem certs/smtp.key
  1. Auto-renewal:
# /etc/cron.d/certbot-renewal
0 0 1 * * root certbot renew --deploy-hook "cp /etc/letsencrypt/live/mail.yourdomain.com/{fullchain.pem,privkey.pem} /path/to/certs/ && docker restart postfix-smtp"

⁠DNS Configuration

  1. Add DKIM record:
mail._domainkey.yourdomain.com. TXT "v=DKIM1; k=rsa; p=<content of domainkeys/mail.txt>"
  1. Add SPF record:
yourdomain.com. TXT "v=spf1 ip4:<your-server-ip> -all"

⁠Testing

Test SMTP:

telnet localhost 25

Test TLS:

openssl s_client -connect localhost:587 -starttls smtp

Test authentication:

swaks --auth-user user1 --auth-password pass1 \
  --server localhost:587 \
  --tls \
  --to [email protected] \
  --from [email protected]

Tag summary

Content type

Image

Digest

sha256:d535788cf…

Size

87.4 MB

Last updated

over 1 year ago

docker pull agna/postfix-smtp