mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.71k stars 113 forks source link

Mox not able to send mail to itself #37

Closed dmikushin closed 1 year ago

dmikushin commented 1 year ago

I've been testing Mox installation on the host system (without Docker). Receiving mail works well, sending mail does not work. To test the simpest case, I've asked Mox to send mail to itself - and it fails, please see the error log below. No, I have no idea why it tries to connect to 127.0.1.1, I don't have such address in mox.conf, it's only 127.0.0.1 there for internal use.

Jun 12 00:27:21 xxxxxxxxxxx mox[426904]: l=debug m="connection attempt for smtp delivery" err="dial tcp 10.0.0.67:0->127.0.1.1:25: connect: connection refused" cid=188ace60a13 from=team@xxxxxxxxxxx recipient=team@xxxxxxxxxxx attempts=3 msgid=4 cid=188ace60a12 pkg=queue host=xxxxxxxxxxx addr=127.0.1.1:25 laddr=10.0.0.67:0
Jun 12 00:27:21 xxxxxxxxxxx mox[426904]: l=debug m="connecting to remote smtp" err="dial tcp 10.0.0.67:0->127.0.1.1:25: connect: connection refused" cid=188ace60a13 from=team@xxxxxxxxxxx recipient=team@xxxxxxxxxxx attempts=3 msgid=4 cid=188ace60a12 pkg=queue host=xxxxxxxxxxx
Jun 12 00:27:21 xxxxxxxxxxx mox[426904]: l=debug m="queue deliverhost result" cid=188ace60a13 from=team@xxxxxxxxxxx recipient=team@xxxxxxxxxxx attempts=3 msgid=4 cid=188ace60a12 pkg=queue host=xxxxxxxxxxx attempt=4 tlsmode=opportunistic permanent=false badtls=false secodeopt= errmsg="dialing smtp server: dial tcp 10.0.0.67:0->127.0.1.1:25: connect: connection refused" ok=false duration=1.13015ms
Jun 12 00:27:21 xxxxxxxxxxx mox[426904]: l=error m="temporary failure delivering from queue" err="dialing smtp server: dial tcp 10.0.0.67:0->127.0.1.1:25: connect: connection refused" from=team@xxxxxxxxxxx recipient=team@xxxxxxxxxxx attempts=3 msgid=4 cid=188ace60a12 pkg=queue backoff=59m28s nextattempt="2023-06-12 01:26:49.051541254 +0000 UTC m=+5272.039868567"
mjl- commented 1 year ago

You probably have your host name resolving to 127.0.1.1 in /etc/hosts. This is what linux installs often do (possibly because it gets its (fixed) IP through DHCP? not sure). If you remove that line, or replace 127.0.1.1 with the actual IP, I think that will resolve the problem.

I would not recommend to let mox listen on that IP due to the SPF configuration.

I'll be adding a warning to the quickstart if the host name resolves to a 127.0.0.0/8 address. It was already in the code as a todo, see https://github.com/mjl-/mox/blob/main/quickstart.go#L317 and https://github.com/mjl-/mox/blob/main/quickstart.go#L308.

Thanks for the report!

dmikushin commented 1 year ago

Thanks, you are right, I have 127.0.1.1 in /etc/hosts !

127.0.1.1   xxxxxxxxxxx xxxxxxxxxxx
dmikushin commented 1 year ago

I've replaced 127.0.1.1 in /etc/hosts with 10.0.0.67 - an actual address of the main network interface reported by ifconfig and now email delivery to Mox itself works! Thanks a lot for pointing me to this.