Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mail server template. #408

Open
ShubashBiswas opened this issue Sep 3, 2024 · 6 comments
Open

Add a mail server template. #408

ShubashBiswas opened this issue Sep 3, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@ShubashBiswas
Copy link

What problem will this feature address?

I face TLS certificate issues with the docker mail server application

Describe the solution you'd like

I'm requesting to dokploy developer to create a webmail template using well-known mail application for docker
Like docker mail server, mailu

Describe alternatives you've considered

None

Additional context

No response

@ShubashBiswas ShubashBiswas added the enhancement New feature or request label Sep 3, 2024
@Eliminationzx
Copy link

bump

@Eliminationzx
Copy link

Eliminationzx commented Sep 9, 2024

I have been working with the docker-mailserver configuration and wanted to contribute by reviewing a potential setup that I believe works as intended. Below is the Docker Compose snippet I’m using:

services:
  mailserver:
    image: ghcr.io/docker-mailserver/docker-mailserver:latest
    hostname: ${DMS_HOSTNAME}
    ports:
      - "25:25"    # SMTP (STARTTLS)
      - "465:465"  # SMTP (Implicit TLS)
      - "587:587"  # SMTP (STARTTLS)
      - "143:143"  # IMAP (STARTTLS)
      - "993:993"  # IMAP (Implicit TLS)
    volumes:
      - dms-mail-data:/var/mail/
      - dms-mail-state:/var/mail-state/
      - dms-mail-logs:/var/log/mail/
      - dms-mail-config:/tmp/docker-mailserver/
      - /etc/dokploy/traefik/dynamic/acme.json:/etc/letsencrypt/acme.json:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - ENABLE_FAIL2BAN=${DMS_ENABLE_FAIL2BAN}
      - PERMIT_DOCKER=${DMS_PERMIT_DOCKER}
      - SPOOF_PROTECTION=${DMS_SPOOF_PROTECTION}
      - SSL_TYPE=${DMS_SSL_TYPE}
      - SSL_DOMAIN=${DMS_SSL_DOMAIN}
      - POSTMASTER_ADDRESS=${DMS_POSTMASTER_ADDRESS}
    cap_add:
      - NET_ADMIN
    restart: always
    stop_grace_period: 1m
    healthcheck:
      test: ${DMS_HEALTHCHECK_CMD}
      timeout: ${DMS_HEALTHCHECK_TIMEOUT}
      retries: ${DMS_HEALTHCHECK_RETRIES}
    command: >
      sh -c '
        if [ ! -s /tmp/docker-mailserver/postfix-accounts.cf ]; then
          echo "File does not exist or is empty. Running setup command...";
          setup email add "${DMS_DEFAULT_USER}" "${DMS_DEFAULT_USER_PASS}";
        else
          echo "File exists and is not empty. Skipping setup command.";
        fi
        exec supervisord -c /etc/supervisor/supervisord.conf
      '
    networks:
      - dokploy-network
      
networks:
  dokploy-network:
    external: true

volumes:
  dms-mail-data:
  dms-mail-state:
  dms-mail-logs:
  dms-mail-config:

Environment:

DMS_HOSTNAME=mail.example.com
DMS_HEALTHCHECK_CMD="ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1"
DMS_HEALTHCHECK_TIMEOUT=3s
DMS_HEALTHCHECK_RETRIES=0
[email protected]
[email protected]
DMS_DEFAULT_USER_PASS=password
DMS_ENABLE_FAIL2BAN=1
DMS_PERMIT_DOCKER=network
DMS_SPOOF_PROTECTION=0
DMS_SSL_TYPE=letsencrypt
DMS_SSL_DOMAIN=example.com

@Siumauricio
Looking forward to any suggestions or corrections you may have. I hope this configuration can either be helpful or be improved further to meet the needs of others.

@SashaGoncharov19
Copy link
Contributor

image
@Eliminationzx the functionality of the deployable should be available out of the box, preferably without additional manipulations

@DeveloperRaju23
Copy link

DeveloperRaju23 commented Sep 10, 2024

Dear @Eliminationzx @SashaGoncharov19

I am facing an issue with running the docker-mailserver. The deployment was smooth but the main problem occurred during setup emails.

Steps I followed

  1. Create a Service with docker-compose type
  2. Copy and paste the code in raw
  3. Configured the environments
  4. Add a domain: mail.example.com with port 80 and Letsencrypt enabled (tried without adding domain also)
  5. Deploy the code
  6. Open the terminal to set the email and run the command: setup email add [email protected] Pass123
  7. Got the error below

2024-09-10 02:49:18+00:00 INFO start-mailserver.sh: Welcome to docker-mailserver v14.0.0

2024-09-10 02:49:18+00:00 INFO start-mailserver.sh: Checking configuration

2024-09-10 02:49:18+00:00 INFO start-mailserver.sh: Configuring mail server

2024-09-10 02:49:18+00:00 WARN start-mailserver.sh: You need at least one mail account to start Dovecot (120s left for account creation before shutdown)

2024-09-10 02:49:28+00:00 WARN start-mailserver.sh: You need at least one mail account to start Dovecot (110s left for account creation before shutdown)

2024-09-10 02:49:39+00:00 WARN start-mailserver.sh: _extract_certs_from_acme | Unable to find key and/or cert for 'mail.example.com' in '/etc/letsencrypt/acme.json'

2024-09-10 02:49:39+00:00 WARN start-mailserver.sh: _extract_certs_from_acme | Unable to find key and/or cert for 'mail.example.com' in '/etc/letsencrypt/acme.json'

2024-09-10 02:49:39+00:00 WARN start-mailserver.sh: _extract_certs_from_acme | Unable to find key and/or cert for 'example.com' in '/etc/letsencrypt/acme.json'

2024-09-10 02:49:39+00:00 WARN start-mailserver.sh: letsencrypt (acme.json) failed to identify a certificate to extract

2024-09-10 02:49:39+00:00 ERROR start-mailserver.sh: Cannot find a valid DOMAIN for '/etc/letsencrypt/live//', tried: 'mail.example.com', 'mail.example.com', 'example.com'

2024-09-10 02:49:39+00:00 ERROR start-mailserver.sh: _find_letsencrypt_domain | LETSENCRYPT_DOMAIN appears to be misconfigured, please verify.

2024-09-10 02:49:39+00:00 ERROR start-mailserver.sh: Shutting down

2024-09-10 02:49:40,341 WARN exited: mailserver (exit status 1; not expected)

2024-09-10 02:49:40,341 WARN received SIGTERM indicating exit request

After that got another error also

image

For more reading:

  1. Docker Mailserver edge Security | TLS (aka SSL)
  2. Tutorials | Mail Server behind a Proxy

@Eliminationzx
Copy link

Eliminationzx commented Sep 10, 2024

image @Eliminationzx the functionality of the deployable should be available out of the box, preferably without additional manipulations

@SashaGoncharov19 @DeveloperRaju23
Post updated.

@SashaGoncharov19
Copy link
Contributor

@Eliminationzx The setup appears to be in order. However, some documentation is required to explain the correct procedure for starting up the mail server.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants