Skip to content

How to run mailserver only on subdomain mail.example.com and not example.com? #3152

@sebastian-ruiz

Description

@sebastian-ruiz

I would like to run mailserver ONLY on mail.example.com

I already point example.com to an public mail server (mailbox.org), via MX records, so I don't want to interfere with this.

I would like to run the mailserver only on mail.example.com and create an email address [email protected].

My configuration

I don't create any new MX records for mail.example.com.

I am using traefik that manages letsencrypt certificates, so following the documentation I have added the acme.json as a volume. I verify that my acme.json contains mail.example.com.

I looked at the documentation, but I am unclear on how exactly to restrict docker-mailserver to my subdomain. I tried various things like hostname: mail.example.com and - OVERRIDE_HOSTNAME=mail.example.com.

My docker-compose.yml file is as follows:

services:

  mailserver:
    image: docker.io/mailserver/docker-mailserver:latest
    container_name: mailserver
    hostname: mail.example.com
    domainname: mail.example.com
    ports:
    #   - "25:25"
      - "587:587"
      - "993:993"
    volumes:
      - ./traefik-data/acme.json:/etc/letsencrypt/acme.json:ro
      - ./data/dms/mail-data/:/var/mail/
      - ./data/dms/mail-state/:/var/mail-state/
      - ./data/dms/mail-logs/:/var/log/mail/
      - ./data/dms/config/:/tmp/docker-mailserver/
      - /etc/localtime:/etc/localtime:ro
    environment:
      - OVERRIDE_HOSTNAME=mail.example.com
      - SSL_TYPE=letsencrypt
      - SSL_DOMAIN=mail.example.com
      - TLS_LEVEL=intermediate
      - ENABLE_SPAMASSASSIN=0
      - SPAMASSASSIN_SPAM_TO_INBOX=0
      - ENABLE_CLAMAV=0
      - ENABLE_FAIL2BAN=0
      - ENABLE_POSTGREY=0
      - SPOOF_PROTECTION=0
    cap_add:
      - NET_ADMIN # For Fail2Ban to work
    restart: unless-stopped

  whoami:
    image: docker.io/traefik/whoami:latest
    networks:
      - web
    labels:
      - "traefik.http.routers.whoami.rule=Host(`mail.example.com`)"

networks:
  web:
    external: true

Logs

[   INF   ]  Welcome to docker-mailserver 11.3.0
[   INF   ]  Initializing setup
[   INF   ]  Checking configuration
[   INF   ]  Configuring mail server
[ WARNING ]  You need at least one mail account to start Dovecot (120s left for account creation before shutdown)
[   INF   ]  Post-configuration checks
[   INF   ]  Starting miscellaneous tasks
[   INF   ]  Starting daemons
[   INF   ]  mail.example.com is up and running
Mar  4 22:11:17 mail amavis[553]: starting. /usr/sbin/amavisd-new at mail.example.com amavisd-new-2.11.1 (20181009), Unicode aware, LC_CTYPE="C.UTF-8"
Mar  4 22:11:17 mail amavis[553]: perl=5.032001, user=, EUID: 110 (110);  group=, EGID: 112 112 (112 112)
Mar  4 22:11:17 mail amavis[553]: Net::Server: Group Not Defined.  Defaulting to EGID '112 112'
Mar  4 22:11:17 mail amavis[553]: Net::Server: User Not Defined.  Defaulting to EUID '110'
Mar  4 22:11:17 mail amavis[553]: No ext program for   .zoo, tried: zoo
Mar  4 22:11:17 mail amavis[553]: No ext program for   .doc, tried: ripole
Mar  4 22:11:17 mail amavis[553]: No decoder for       .F
Mar  4 22:11:17 mail amavis[553]: No decoder for       .doc
Mar  4 22:11:17 mail amavis[553]: No decoder for       .zoo
Mar  4 22:11:17 mail postfix/postdrop[573]: warning: unable to look up public/pickup: No such file or directory
Mar  4 22:11:19 mail postfix/master[1212]: daemon started -- version 3.5.17, configuration /etc/postfix
Mar  4 22:11:19 mail postfix/pickup[1216]: BE6811AEA3EE: uid=0 from=<root>
Mar  4 22:11:19 mail postfix/cleanup[1221]: warning: connect to Milter service inet:localhost:8891: Cannot assign requested address
Mar  4 22:11:19 mail postfix/cleanup[1221]: BE6811AEA3EE: message-id=<[email protected]>
Mar  4 22:11:19 mail postfix/qmgr[1217]: BE6811AEA3EE: from=<[email protected]>, size=713, nrcpt=1 (queue active)
Mar  4 22:11:19 mail postfix/smtp[1231]: connect to mxext1.mailbox.org[2001:67c:2050:104:0:1:25:1]:25: Cannot assign requested address
Mar  4 22:11:20 mail postfix/smtp[1231]: Trusted TLS connection established to mxext2.mailbox.org[80.241.60.215]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256
Mar  4 22:11:20 mail postfix/smtp[1231]: BE6811AEA3EE: to=<[email protected]>, relay=mxext2.mailbox.org[80.241.60.215]:25, delay=2.9, delays=2.3/0.01/0.38/0.24, dsn=5.1.1, status=bounced (host mxext2.mailbox.org[80.241.60.215] said: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table (in reply to RCPT TO command))
Mar  4 22:11:20 mail postfix/cleanup[1221]: 6B5E91AEA3F2: message-id=<[email protected]>
Mar  4 22:11:20 mail postfix/bounce[1241]: BE6811AEA3EE: sender non-delivery notification: 6B5E91AEA3F2
Mar  4 22:11:20 mail postfix/qmgr[1217]: 6B5E91AEA3F2: from=<>, size=2838, nrcpt=1 (queue active)
Mar  4 22:11:20 mail postfix/trivial-rewrite[1227]: warning: do not list domain mail.example.com in BOTH mydestination and virtual_mailbox_domains
Mar  4 22:11:20 mail postfix/qmgr[1217]: BE6811AEA3EE: removed
Mar  4 22:11:20 mail postfix/cleanup[1221]: 6E69B1AEA3F1: message-id=<[email protected]>
Mar  4 22:11:20 mail postfix/local[1244]: 6B5E91AEA3F2: to=<[email protected]>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=2.0.0, status=sent (forwarded as 6E69B1AEA3F1)
Mar  4 22:11:20 mail postfix/qmgr[1217]: 6E69B1AEA3F1: from=<>, size=2967, nrcpt=1 (queue active)
Mar  4 22:11:20 mail postfix/qmgr[1217]: 6B5E91AEA3F2: removed
Mar  4 22:11:20 mail postfix/smtp[1231]: connect to mxext2.mailbox.org[2001:67c:2050:104:0:2:25:1]:25: Cannot assign requested address
Mar  4 22:11:20 mail postfix/smtp[1231]: connect to mxext1.mailbox.org[2001:67c:2050:104:0:1:25:1]:25: Cannot assign requested address
Mar  4 22:11:20 mail postfix/smtp[1231]: Trusted TLS connection established to mxext1.mailbox.org[80.241.60.212]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256
Mar  4 22:11:20 mail postfix/smtp[1231]: 6E69B1AEA3F1: to=<[email protected]>, orig_to=<[email protected]>, relay=mxext1.mailbox.org[80.241.60.212]:25, delay=0.41, delays=0/0/0.33/0.08, dsn=5.1.1, status=bounced (host mxext1.mailbox.org[80.241.60.212] said: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table (in reply to RCPT TO command))
Mar  4 22:11:20 mail postfix/qmgr[1217]: 6E69B1AEA3F1: removed
Mar  4 22:11:35 mail dovecot: imap-login: Disconnected (disconnected before auth was ready, waited 0 secs): user=<>, rip=192.168.1.1, lip=172.31.0.2, TLS handshaking: Connection closed, session=<ivvKgRn298vAqAEB>

As you can see, something isn't setup correctly, because there are many references to mailbox.org which is the mail server running on example.com

Furthermore, when I try and connect as [email protected] with Thunderbird I get the error:

Mar  4 22:11:35 mail dovecot: imap-login: Disconnected (disconnected before auth was ready, waited 0 secs): user=<>, rip=192.168.1.1, lip=172.31.0.2, TLS handshaking: Connection closed, session=<ivvKgRn298vAqAEB>

Any help would be really welcome. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions