loganmarchione / docker-postfixrelay

Runs Postfix (as a relay) in Docker
https://hub.docker.com/r/loganmarchione/docker-postfixrelay
MIT License
28 stars 5 forks source link

lost connection after CONNECT from localhost[127.0.0.1] #37

Closed glennpierce closed 8 months ago

glennpierce commented 8 months ago

I have a setup like

version: "3"
services:
  postfixrelay:
    container_name: docker-postfixrelay
    restart: unless-stopped
    environment:
      - TZ=Europe/London
      - RELAY_HOST=smtp.gmail.com
      - RELAY_PORT=587
      - RELAY_USER=support@carnego.net
      - RELAY_PASS=******
      - FROMADDRESS=support@carnego.net
      - TEST_EMAIL=****@gmail.com
      - MYORIGIN=carnego.net
      - MYNETWORKS=127.0.0.0/24, 192.168.80.0/20, 192.168.22.0/24
      - MSG_SIZE=30720000
    networks:
      - carnego
    ports:
      - 192.168.80.1:8025:25
    image: loganmarchione/docker-postfixrelay:latest
networks:
  carnego:
    external: true

network carnego is

"Subnet": "192.168.80.0/20", "Gateway": "192.168.80.1

The test email gets sent ok when I deploy but when I try to send from the host say from a python script

like

s = smtplib.SMTP('192.168.80.1', port=8025)

I get

lost connection after CONNECT from localhost[127.0.0.1]

Any idea why ?

Note I get the same error without mynetworks being set

loganmarchione commented 8 months ago
glennpierce commented 8 months ago
  • Is your Python script on the same machine as the container? yep

  • Is 192.168.80.1 the IP of the Docker host? Typically x.x.x.1 is the IP of the router...

yes it is the router. The ip of the container is 192.168.80.6

  • Can you telnet to that host/port? Like telnet 192.168.80.1:8025, and then tail the Docker logs to see if it connects?

I did telnet 192.168.80.1 8025

and I get

Escape character is '^]'. 220 686db07d8b90.localdomain ESMTP Postfix

Actually having just sent a test through telent it did work.

So The python code sending must be at fault so not your problem I think. I wlll close the issue. Thanks