Search code examples
dockerdocker-composemail-server

RainLoop+tomav/docker-mailserver: Cannot connect to server from RainLoop Webmail client


To start off, I followed this guide to the letter: https://www.davd.eu/byecloud-building-a-mailserver-with-modern-webmail/

I am attempting to create a mailserver for my server, but I thought I'd test the above implementation locally first. Make sure I can get everything up and running at least so I can see what I should be expecting before trying it on the server. Here's what I did:

  1. Added "127.0.0.1 mail.fancydomain.tld" to "/etc/hosts" (I wanted to start by using mail.fancydomain.tld rather than my actual domain that the mailserver will be on to minimize any changing while following the guide)
  2. I created this "docker-compose.yml":

       version: "3"
    
        services:
          rainloop:
            image: hardware/rainloop
            links:
              - mail
            volumes:
              - ./data/rainloop:/rainloop/data
    
          mail:
            image: tvial/docker-mailserver:latest
            restart: always
            hostname: mail
            domainname: fancydomain.tld
            container_name: mail
            ports:
              - "25:25"
              - "143:143"
              - "587:587"
              - "993:993"
              - "4190:4190"
            volumes:
              - ./data/mail/data:/var/mail
              - ./data/mail/state:/var/mail-state
              - ./mail/config:/tmp/docker-mailserver/
              - ./data/entry/acme/acme-v01.api.letsencrypt.org/sites/mail.fancydomain.tld:/tmp/ssl:ro
            environment:
              - ENABLE_SPAMASSASSIN=1
              - ENABLE_CLAMAV=1
              - ENABLE_FAIL2BAN=1
              - ENABLE_POSTGREY=1
              - ONE_DIR=1
              - DMS_DEBUG=0
              - ENABLE_MANAGESIEVE=1
            cap_add:
              - NET_ADMIN
    
          entry:
            image: abiosoft/caddy:0.10.4
            restart: always
            privileged: true
            links:
              - rainloop
            ports:
              - "80:80"
              - "443:443"
            volumes:
              - ./entry/Caddyfile:/etc/Caddyfile
              - ./data/entry:/root/.caddy
    

    There is a small difference between this "docker-compose.yml" and the one provided by the site previously mentioned. All I did was remove the environment variables prefixed with "SSL_" as instructed by the guide for people who are just running it locally.

  3. I created a directory in the current working directory called "entry" and created a "Caddyfile" with these contents:

       http://mail.fancydomain.tld {
            proxy / rainloop:8888 {
                transparent
            }
        }
    

    Again, just a small difference from the one provided on the site. I prefixed the domain with "http://" for the same reason as step 2.

  4. I successfully started the container with docker-compose up -d
  5. I ran: curl -o setup.sh https://raw.githubusercontent.com/tomav/docker-mailserver/master/setup.sh; chmod a+x ./setup.sh to obtain the setup script.
  6. I ran: ./setup.sh email add webmaster@fancydomain.tld fancypassword with those exact credentials, again to minimizes changes to keep track of.
  7. I setup the DKIM records by running ./setup.sh config dkim but I did not proceed further with these records... As I'm not sure what to do with these locally.
  8. I successfully connected to the RainLoop Webmail client via, "http://mail.fancydomain.tld/" and proceeded to "http://mail.fancydomain.tld/?admin" to login with the credentials: Login=admin Password=12345
  9. I proceeded to "Domains" > "Add Domain" and used filled out the form as so:

    Name: fancydomain.tld
        IMAP
          Server: mail
          Port: 143
          Secure: STARTTLS
        SMTP
          Server: mail
          Port: 587
          Secure: STARTTLS
          Use short login: Checked
          Use authentication: Checked
        SIEVE
          Allow sieve scripts: Checked
          Server: mail
          Port: 4190
          Secure: STARTTLS
    
  10. From here I returned to "http://mail.fancydomain.tld" and tried to login to the Webmail client with this login: Login=webmaster@fancydomain.tld Password=fancypassword

This is where I get the error: "Can't connect to server"

I am not sure where to go from here. I don't know how to troubleshoot at all. Can I please get some help on what I should be doing to troubleshoot and figure out where the error is?

Thank you!

07/01/18 Update: So... I added "127.0.0.1 mail" into "/etc/hosts" and it worked! RainLoop can now connect to my mailserver! This brings up a new question though. For step 9, instead of "mail" for the three "Server" fields, I tried, "mail.fancydomain.tld" and according to the test, the connection is being refused. Why would the connection be refused for the full domain but not the short domain?


Solution

  • The solution for this one it to make sure both containers, RainLoop and Mail, share a bridged network. Then all the configurations can stay the same.