My Dockerfile
FROM python:3.10-alpine
LABEL Description="test smtp server"
EXPOSE 8025
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN python -m pip install --upgrade pip && pip install -r requirements.txt
CMD python3 -m aiosmtpd --nosetuid --debug --debug --listen 127.0.0.1:8025
When i run this container with command
docker build -t test-smtp-image . && docker run -p 8025:8025 --name skad-test-smtp test-smtp-image
And tying to send email to it from host where container running i got next Exception
raise SMTPConnectError(
aiosmtplib.errors.SMTPConnectError: Error connecting to 127.0.0.1 on port 8025: Unexpected EOF received
But it works great when i send email with same script and aiosmtpd running command on host
Sending mail script:
from email.message import EmailMessage
import aiosmtplib
import asyncio
m = EmailMessage()
m['From'] = "test@test.com"
m["To"] = 'test@test.com'
m["Subject"] = "Test subject"
m.set_content("Test msg")
loop = asyncio.get_event_loop()
r = loop.run_until_complete(aiosmtplib.send(m, hostname="127.0.0.1", port=8025))