zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
583 stars 93 forks source link

how to configure the mail server name? #382

Closed msimerson closed 3 months ago

msimerson commented 3 months ago

This PR is really more of an issue (with a patch) than a serious PR.

I've set up an instance of wildduck (with webmail, zonemta, zone-mta-admin, and Haraka) roughly following the setup scripts. It's running in a container with only private addresses (172.16.15.64 & fd7a:e5cd:1fc1:8901:dead:beef:cafe:40). Redirection and NAT rules map traffic to and from the container and its public IPs. The hostname within the container is wildduck and it has matching forward and reverse DNS (split horizon).

zone-mta/pools.toml

[[default]]
address=["0.0.0.0", "::"]
name="mail.tnpi.biz"

plugins/wildduck.toml

[wildduck]
enabled=["receiver", "sender"]
interfaces=["feeder"]

# optional hostname to be used in headers
# defaults to os.hostname()
hostname="mail.tnpi.biz"

[wildduck.srs]
    enabled=true
    secret="*******"
    rewriteDomain="tnpi.biz"

[wildduck.dkim]
# @include "/data/wildduck/config/dkim.toml

Having read the comment # optional hostname to be used in headers, in plugins/wildduck.toml, I expect that ZoneMTA will use the configured [host]name setting and that SMTP connections made to and from ZoneMTA will reflect these settings in the headers.

Instead, the HELO hostname and the hostname included in headers is os.hostname().

Mail Headers (without patch)

Received: from unknown (HELO wildduck) (172.16.15.64)
  by mail.theartfarm.com with SMTP; 29 Mar 2024 22:37:11 -0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tnpi.biz;<snip>
Received: from cali.tnpi.net ([204.11.99.4] ns2.cadillac.net)
 (Authenticated sender: matt)
 by wildduck (ZoneMTA) with ESMTPSA id 18e8c5c092d000dc30.001
 for <matt@si****on.net>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Fri, 29 Mar 2024 22:37:05 +0000
X-Zone-Loop: bba37dcdbb4f47bbffa820159b686f75a31516e46834
X-Originating-IP: [204.11.99.4]
Date: Fri, 29 Mar 2024 15:37:04 -0700
To: matt@si****on.net
From: matt@tnpi.biz
Subject: test Fri, 29 Mar 2024 15:37:04 -0700
Message-Id: <20240329153704.062441@cali.tnpi.net>
X-Mailer: swaks v20240103.0 jetmore.org/john/code/swaks/

This is a test mailing

Mail Headers (with patch)

Received: from unknown (HELO mail.tnpi.biz) (172.16.15.64)
  by mail.theartfarm.com with SMTP; 29 Mar 2024 23:05:31 -0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tnpi.biz;<snip>
Received: from cali.tnpi.net ([204.11.99.4] ns2.cadillac.net)
 (Authenticated sender: matt)
 by mail.tnpi.biz (ZoneMTA) with ESMTPSA id 18e8c760d3b0005088.001
 for <matt@si****on.net>
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Fri, 29 Mar 2024 23:05:30 +0000
X-Zone-Loop: 702873901ecdceea419d0ca32e532fa7509135c6c769
X-Originating-IP: [204.11.99.4]
Date: Fri, 29 Mar 2024 16:05:29 -0700
To: matt@si****on.net
From: matt@tnpi.biz
Subject: test Fri, 29 Mar 2024 16:05:29 -0700
Message-Id: <20240329160529.065457@cali.tnpi.net>
X-Mailer: swaks v20240103.0 jetmore.org/john/code/swaks/

This is a test mailing

Note the ZoneMTA hostname difference in the two Received headers.

I was poking in the code looking for where that hostname could be passed in and used but didn't find it. Yet. I suspect this is the underlying issues behind #162.

Is there a way to configure the hostname in ZoneMTA that I'm missing?

louis-lau commented 3 months ago

Address must be a string, not an array of strings. Look at the example config again :)

louis-lau commented 3 months ago

In your case the config would be

[[default]]
address="0.0.0.0"
name="mail.tnpi.biz"

[[default]]
address="::"
name="mail.tnpi.biz"

As your pool config doesn't have a valid address string it went back to its default config which uses os.hostname

msimerson commented 3 months ago

Indeed! Thanks @louis-lau! My error was specifying both IPv4 and IPv6 incorrectly.