Thanks to visit codestin.com
Credit goes to github.com

Skip to content

question: How to configure for testing SMTP server locally? #3634

@jaimebw

Description

@jaimebw

Subject

I would like some feedback concerning a use case

Description

Hi, Im wriing this issue just to ask for help for setting up docker-mailserver. Currently, I'm trying to develop some stuff and I need to run docker-mailserver on local(mainly to run tests). The IMAP server works fine but the SMTP server is another story...
I'm using smtplib in Python. This an example of script of what I am using to test the SMTP server:

import imaplib
server = smtplib.SMTP("localhost", 25)
server.login(f"[email protected]", "test")

The error I'm running into looks like this:

>               raise SMTPServerDisconnected("Connection unexpectedly closed")
E               smtplib.SMTPServerDisconnected: Connection unexpectedly closed

/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/smtplib.py:405: SMTPServerDisconnected

My compose.yml looks like this:

services:
  mailserver:
    image: ghcr.io/docker-mailserver/docker-mailserver:latest
    container_name: mailserver
    # Provide the FQDN of your mail server here (Your DNS MX record should point to this value)
    hostname: mail.mail.local
    env_file: local-mailserver.env
    # More information about the mail-server ports:
    # https://docker-mailserver.github.io/docker-mailserver/latest/config/security/understanding-the-ports/
    # To avoid conflicts with yaml base-60 float, DO NOT remove the quotation marks.
    ports:
      - "25:25"
      - "143:143"  # IMAP4 (explicit TLS => STARTTLS)
      - "465:465"  # ESMTP (implicit TLS)
      - "587:587"  # ESMTP (explicit TLS => STARTTLS)
      - "993:993"  # IMAP4 (implicit TLS)
      - "5000:5000" # Localhost
    volumes:
      - ./docker-data/certbot/certs/:/etc/letsencrypt
      - ./docker-data/dms/mail-data/:/var/mail/
      - ./docker-data/dms/mail-state/:/var/mail-state/
      - ./docker-data/dms/mail-logs/:/var/log/mail/
      - ./docker-data/dms/config/:/tmp/docker-mailserver/
      - /etc/localtime:/etc/localtime:ro
    restart: always
    stop_grace_period: 1m
    # Uncomment if using `ENABLE_FAIL2BAN=1`:
    # cap_add:
    #   - NET_ADMIN
    healthcheck:
      test: "ss --listening --tcp | grep -P 'LISTEN.+:smtp' || exit 1"
      timeout: 3s

The local-mailserver.env is the default mailserve.env( no SSL certifactes)

As stated before, I have no problems connecting to the IMAP server.

If you need more details, please let me know. Thanks in advance!

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