version: "3.9"

services:

  # https://docker-mailserver.github.io/docker-mailserver/edge/config/environment/
  # https://i12bretro.github.io/tutorials/0779.html
  # https://www.youtube.com/watch?v=r9vG7P-RRp8

  docker-mailserver:
    image: mailserver/docker-mailserver:11.3.1
    container_name: docker-mailserver
    hostname: "mail.tbs093a.tk"
    domainname: "00x097.tk"
    environments:
      ENABLE_SPAMASSASSIN: 1
      SPAMASSASSIN_SPAM_TO_INBOX: 1
      ENABLE_CLAMAV: 1
      ENABLE_POSTGREY: 1
      ENABLE_FAIL2BAN: 0
      ENABLE_SASLAUTHD: 0
      ONE_DIR: 1
      TZ: "America/New_York"
    ports:
      - 25:25
      - 143:143
      - 587:587
      - 993:993
    volumes:
      - ./volumes/docker-mailserver/data/:/var/mail/
      - ./volumes/docker-mailserver/state/:/var/mail-state/
      - ./volumes/docker-mailserver/logs/:/var/log/mail/
      - ./volumes/docker-mailserver/config/:/tmp/docker-mailserver/


# docker run -d \
#   --name=mailserver \
#   --hostname="$HOSTNAME" \
#   --domainname="docker.local" \
#   -p 25:25 \
#   -p 143:143 \
#   -p 587:587 \
#   -p 993:993 \
#   -e ENABLE_SPAMASSASSIN=1 \
#   -e SPAMASSASSIN_SPAM_TO_INBOX=1 \
#   -e ENABLE_CLAMAV=1 \
#   -e ENABLE_POSTGREY=1 \
#   -e ENABLE_FAIL2BAN=0 \
#   -e ENABLE_SASLAUTHD=0 \
#   -e ONE_DIR=1 \
#   -e TZ=America/New_York \
#   -v ~/docker/mailserver/data/:/var/mail/ \
#   -v ~/docker/mailserver/state/:/var/mail-state/ \
#   -v ~/docker/mailserver/logs/:/var/log/mail/ \
#   -v ~/docker/mailserver/config/:/tmp/docker-mailserver/ \
#   --restart=unless-stopped \
#   mailserver/docker-mailserver

# create user inbox
# docker run --rm \
#   -e MAIL_USER=i12bretro@docker.local \
#   -e MAIL_PASS=supersecret \
#   -it mailserver/docker-mailserver /bin/sh -c \
#     'echo "$MAIL_USER|$(doveadm pw -s SHA512-CRYPT -u $MAIL_USER -p $MAIL_PASS)"' \
#     >> ~/docker/mailserver/config/postfix-accounts.cf