services:
  smtp-relay:
    image: loganmarchione/docker-postfixrelay:latest
    container_name: smtp_relay_node${SMTP_NODE_ID}
    restart: always
    ports:
      - "2525:25"
    environment:
      # 1. THE UPSTREAM SMARTHOST (Where mail goes)
      - RELAY_HOST=${SMTP_RELAY_HOST}
      - RELAY_PORT=${SMTP_RELAY_PORT}
      - RELAY_USER=${SMTP_RELAY_USER}
      - RELAY_PASS=${SMTP_RELAY_PASS}

      # 2. INTERNAL SECURITY (Who can send)
      # Allow your entire subnet (e.g., 192.168.1.0/24) to send without auth
      - MYNETWORKS=${SMTP_RELAY_NETWORKS}

      # 3. IDENTIFICATION
      # The hostname this relay announces itself as
      - SYSTEM_TIMEZONE=America/Edmonton
      - MESSAGE_SIZE_LIMIT=10240000

    volumes:
      # QUEUE PERSISTENCE (Critical for HA)
      # If Node 1 dies, Node 2 sees the pending mail queue on Gluster
      - /docker/smtp-relay/queue:/var/spool/postfix
      
    networks:
      - smtp_external # Attached to Traefik network just in case, or for internal access

networks:
  smtp_external:
    external: true