SMTP route not working for Mailcatcher Docker container


Have been working with Traefik for the past few weeks and I seem to get the hang of it as most of the things are working now after some vigorous testing and learning.

Now I seem to have hit a roadblock I am not able to solve even though I think it is correct, it must be wrong because it does not work :sweat_smile:

I am running a server with Docker and have several Docker containers running successfully but these are all PHP applications. Now I am trying to setup a Docker container with Mailcatcher and it only works half. The webinterface on port 1080 I can see and it is shown but the SMTP part is not responding as it should. Here is the output:

telnet 1025                                                                                                                                                                                                                                                                        
Connected to
Escape character is '^]'.

When I press Enter here I see this response:

HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

400 Bad RequestConnection closed by foreign host.

This makes me believe it is processing it as an http request instead of an smtp request.

There is an error in the Traefik dashboard. The error shown is:




invalid rule: "Host(``)" , unsupported function: Host 

Could someone please have a look and tell me what I am doing wrong?

Thank you very much. :smiling_face:

Here is my setup


  level = "DEBUG"
  filePath = '/var/log/traefik.log'

  filePath = '/var/log/access.log'
  bufferingSize = 100

    watch = true
    exposedByDefault = false
    network = "traefik-proxy"

    address = ":80"
          to = "websecure"
          scheme = "https"
    address = ":443"
      certResolver = "lets-encrypt"
    address = ":1080"
      certResolver = "lets-encrypt"
    address = ":1025"

      storage = "/etc/traefik/acme.json"
      email = "some@mailaddress"
      tlsChallenge = true

  insecure = false
  dashboard = true

Mailcatcher docker-compose.yml

version: "3.8"
    image: dockage/mailcatcher:latest
    container_name: "mailcatcher"
    restart: unless-stopped
      - "traefik.enable=true"
      - ""

      - "traefik.http.routers.mailcatcher-web.rule=Host('')"
      - "traefik.http.routers.mailcatcher-web.entrypoints=mailcatcherweb"
      - "traefik.http.routers.mailcatcher-web.service=mailcatcher-web"
      - ""

      - "traefik.tcp.routers.mailcatcher-smtp.rule=HostSNI('')"
      - "traefik.tcp.routers.mailcatcher-smtp.entrypoints=mailcatchersmtp"
      - "traefik.tcp.routers.mailcatcher-smtp.service=mailcatcher-smtp"
      - ""
      - traefik-proxy

    external: true

UFW config

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443                        ALLOW       Anywhere                  
1080/tcp                   ALLOW       Anywhere                  
1025/tcp                   ALLOW       Anywhere                  
8025/tcp                   ALLOW       Anywhere                  
25/tcp                     ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443 (v6)                   ALLOW       Anywhere (v6)             
1080/tcp (v6)              ALLOW       Anywhere (v6)             
1025/tcp (v6)              ALLOW       Anywhere (v6)             
8025/tcp (v6)              ALLOW       Anywhere (v6)             
25/tcp (v6)                ALLOW       Anywhere (v6) 

I think Host does not work on plain TCP connections, only on HTTP.

I also believe you should not set a router service in labels when using Docker configuration discovery, try removing


If you still get a HTTP response, then maybe Traefik is setting HTTP as default and you explicitly need to set it to TCP somewhere. Check the docs.


Thank you for your input. I am still trying to get this up and running to no avail. I have changed the configuration somewhat and the service name is needed.

In the Traefik logs I see this:

time="2022-10-15T18:50:50Z" level=debug msg="Creating server 0" entryPointName=mailcatcherweb serviceName=mailcatcher-web serverName=0 routerName=mailcatcher-web@docker
time="2022-10-15T18:50:50Z" level=debug msg="child now UP"
time="2022-10-15T18:50:50Z" level=debug msg="Propagating new UP status"
time="2022-10-15T18:50:50Z" level=debug msg="Added outgoing tracing middleware mailcatcher-web" middlewareType=TracingForwarder entryPointName=mailcatcherweb routerName=mailcatcher-web@docker middlewareName=tracing
time="2022-10-15T18:50:50Z" level=debug msg="Creating middleware" entryPointName=mailcatcherweb middlewareType=Recovery middlewareName=traefik-internal-recovery
time="2022-10-15T18:50:50Z" level=debug msg="Adding route for with TLS options default" entryPointName=websecure
time="2022-10-15T18:50:50Z" level=debug msg="Creating TCP server 0 at" routerName=mailcatcher-smtp@docker serviceName=mailcatcher-smtp entryPointName=mailcatchersmtp serverName=0
time="2022-10-15T18:50:50Z" level=debug msg="Adding TLS route for \"HostSNI(``)\"" entryPointName=mailcatchersmtp routerName=mailcatcher-smtp@docker
time="2022-10-15T18:50:50Z" level=debug msg="Adding route for with TLS options default" entryPointName=mailcatcherweb

This looks all good to me, also in the Traefik dashboard all lights are green.

One thing I noticed is when I try to reach the SMTP server, I see nothing happening in the Traefik log. This seems to me that Traefik is not even picking up the request.

This is the container configuration:

CONTAINER ID   IMAGE                              COMMAND                  CREATED          STATUS                 PORTS                                                                                                                                        NAMES
4d2c4e58efc3   jeanberu/mailcatcher               "mailcatcher --foreg…"   3 minutes ago    Up 3 minutes           1025/tcp, 1080/tcp                                                                                                                           mailcatcher
421c301ad35d   traefik:v2.8                       "/ trae…"   56 minutes ago   Up 56 minutes>80/tcp,>443/tcp,>1025/tcp,>1080/tcp,>8025/tcp                             traefik

Connecting to the SMTP server locally works, so I know the service is up and running.

Is there anyway to find out why Traefik does not seem to pick up the request in the first place?