Setting up Node Mail Stack

I’ve created another experiments with Haraka and end up with fully working recipe in Docker Compose. The idea is to create a catch-all mails to a subdomain. And everything I sign up to a service for example eHarmony, my email to sign up would be eharmony@subdomain.domain.ltd. Sometimes that service don’t have a way to unsubscribe and end up with in your mailbox unless you have a great spam assassin.

That service is notorious for sending out horrendous spam. Therefor you just block them completely by creating an eharmony alias for your blocked@subdomain.domain.ltd.

I’ve used legacy Google Apps to make it happen, before that there was a service called Otherinbox that did just do that. I love the idea to keep all your email things in order and also you know exactly where those weird mails come from.

For now it’s work in progress, but soon I’ll make this recipe public.

Here’s a sneak-peak on some of the files.

version: "3.8"
services:
  certs:
    env_file: docker-compose.env
    build: build/certs
    volumes:
      - ./data/ssl:/etc/ssl

  #### wildduck - api:8080 imap:143,993 pop3:110,995 u2f:3000
  wildduck:
    env_file: docker-compose.env
    build: build/wildduck
    # image: nodemailer/wildduck
    restart: always
    ports:
      - "143:143"
      - "110:110"
      - "993:993"
      - "995:995"
    depends_on:
      - redis
      - mongo
    volumes:
      - ./data/wildduck:/wildduck/config
    volumes_from:
      - data

  #### wildduck-webmail - web:3000
  wildduck-webmail:
    env_file: docker-compose.env
    # image: nodemailer/wildduck-webmail
    build: build/wildduck-webmail
    restart: always
    command: --config="/etc/wildduck/www.toml"
    volumes:
      - ./data/wildduck-webmail:/etc/wildduck
    volumes_from:
      - data

  #### haraka - smtp:25,465,587
  haraka:
    env_file: docker-compose.env
    build: build/haraka
    restart: unless-stopped
    depends_on:
      - redis
      - mongo
    ports:
      - '25:25'
      - '465:465'
      - '587:587'
    volumes:
      - ./data/haraka:/app/outbound
    volumes_from:
      - data

  #### zonemta - smtp:2525 http_api:12080 internal_data_channel:12081 other:31239
  zonemta:
    env_file: docker-compose.env
    build: build/zonemta
    restart: unless-stopped
    ports:
      - '2525:2525'
    volumes:
      - ./data/zonemta:/app/zonemta/config
    volumes_from:
      - data

  #### redis - redis:6379/3
  redis:
    image: redis:alpine
    restart: always
    volumes:
      - ./data/redis:/data

  #### mongo - mongo:27017/wildduck
  mongo:
    image: mongo
    restart: always
    volumes:
      - ./data/mongo:/data/db

  #### mongo-express - mail-admin:8081
  mongo-express:
    image: mongo-express
    restart: always
    depends_on: 
      - mongo

  data:
    image: node:10-alpine
    command: echo "Done."
    volumes:
      - ./data/ssl:/etc/ssl:ro
      - ./data/tmp:/tmp
      - ./ssl:/ssl:ro

# create network: docker network create xnmp-network
networks:
  default:
    external:
      name: xnmp-network
File: docker-compose.yml
DOMAIN=example.com
FQDN=mail.${DOMAIN}
MAIL_DOMAIN=${DOMAIN}

TLS_KEY=/ssl/tls_key.pem
TLS_CERT=/ssl/tls_cert.pem
TLS_DHPARAMS=/ssl/dhparams.pem
LOOPSECRET=881e0ed6-5b6d-11eb-ae93-0242ac130002
API_ACCESSTOKEN=1123123ae354869460e45
SRS_SECRET=asecretcatnip

#### Mongo
# MONGO_INITDB_ROOT_USERNAME=${DB_ROOT}
# MONGO_INITDB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}

#### Mongo Express
# ME_CONFIG_MONGODB_SERVER=${DB_HOST}
# ME_CONFIG_MONGODB_ADMINUSERNAME=${DB_ROOT}
# ME_CONFIG_MONGODB_ADMINPASSWORD=${DB_ROOT_PASSWORD}

#### Haraka SMTP Server
## CMD_ARGS
HARAKA_CMD_ARGS="\
  --redis.host=redis \
  --redis.port=6379 \
  --redis.db=3 \
  --mongo.url=mongodb://mongo:27017/wildduck \
  --mongo.sender=zone-mta \
  --sender.enabled=true \
  --sender.zone=default \
  --sender.gfs=mail \
  --sender.collection=zone-queue \
  --sender.loopSecret=${LOOPSECRET} \
  --srs.secret=${SRS_SECRET}
  "

#### Wildduck IMAP Server
## CMD_ARGS
WILDDUCK_CMD_ARGS="\
  --emailDomain=${DOMAIN} \
  --dbs.mongo=mongodb://mongo:27017/wildduck \
  --dbs.redis=redis://redis:6379/3 \
  --u2f.appId=https://wildduck:3000 \
  --imap.enabled=true \
  --imap.port=993 \
  --imap.host=0.0.0.0 \
  --imap.secure=true \
  --imap.setup.hostname=${DOMAIN} \
  --imap.setup.secure=true \
  --imap.setup.port=993 \
  --pop3.enabled=true \
  --pop3.port=995 \
  --pop3.host=0.0.0.0 \
  --pop3.secure=true \
  --pop3.setup.hostname=${DOMAIN} \
  --pop3.setup.secure=true \
  --pop3.setup.port=995 \
  --lmtp.enabled=true \
  --lmtp.port=2424 \
  --lmtp.host=0.0.0.0 \
  --lmtp.disableSTARTTLS=false \
  --api.enabled=true \
  --api.port=8080 \
  --api.host=0.0.0.0 \
  --api.accessToken=${API_ACCESSTOKEN} \
  --sender.loopSecret=${LOOPSECRET} \
  --smtp.setup.hostname=${DOMAIN} \
  --smtp.setup.secure=false \
  --smtp.setup.port=2525 \
  --tls.key=${TLS_KEY} \
  --tls.cert=${TLS_CERT} \
  "

#### Wildduck-Webmail - mail.sylo.space
WILDDUCKWEBMAIL_API_HOST=wildduck
WILDDUCKWEBMAIL_API_PORT=8080
## CMD_ARGS
WILDDUCKWEBMAIL_CMD_ARGS="\
  --service.domain=${DOMAIN} \
  --dbs.mongo=mongodb://mongo:27017/wildduck \
  --dbs.redis=redis://redis:6379/3 \
  --api.url=http://wildduck:8080 \
  --api.accessToken=${API_ACCESSTOKEN} \
  --u2f.appId=https://wildduck:3000 \
  --setup.imap.hostname=${DOMAIN} \
  --setup.imap.secure=true \
  --setup.imap.port=993 \
  --setup.pop3.hostname=${DOMAIN} \
  --setup.pop3.secure=true \
  --setup.pop3.port=995 \
  --setup.smtp.hostname=${DOMAIN} \
  --setup.smtp.secure=false \
  --setup.smtp.port=2525 \
  --tls.key=${TLS_KEY} \
  --tls.cert=${TLS_CERT} \
  "
#### Zone-MTA
ZONEMTA_API_HOST=wildduck
ZONEMTA_API_PORT=8080
## CMD_ARGS
ZONEMTA_CMD_ARGS="\
  --dbs.mongo=mongodb://mongo:27017/zone-mta \
  --dbs.redis=redis://redis:6379/3 \
  --dbs.redis.host=redis \
  --dbs.redis.port=6379 \
  --dbs.redis.db=3 \
  --modules/zonemta-loop-breaker.secret=${LOOPSECRET} \
  --log.level=error \
  --smtpInterfaces.feeder.host=0.0.0.0 \
  --smtpInterfaces.feeder.port=2525 \
  --smtpInterfaces.feeder.authentication=true \
  --smtpInterfaces.feeder.secure=false \
  --smtpInterfaces.feeder.key=${TLS_KEY} \
  --smtpInterfaces.feeder.cert=${TLS_CERT} \
  "
File: docker-compose.env