diff --git a/cmd/root.go b/cmd/root.go index 4a98a13..1eb06de 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -105,6 +105,7 @@ func init() { rootCmd.Flags().BoolVar(&config.SMTPStrictRFCHeaders, "smtp-strict-rfc-headers", config.SMTPStrictRFCHeaders, "Return SMTP error if message headers contain ") rootCmd.Flags().IntVar(&config.SMTPMaxRecipients, "smtp-max-recipients", config.SMTPMaxRecipients, "Maximum SMTP recipients allowed") rootCmd.Flags().StringVar(&config.SMTPAllowedRecipients, "smtp-allowed-recipients", config.SMTPAllowedRecipients, "Only allow SMTP recipients matching a regular expression (default allow all)") + rootCmd.Flags().BoolVar(&smtpd.DisableReverseDNS, "smtp-disable-rdns", smtpd.DisableReverseDNS, "Disable SMTP reverse DNS lookups") rootCmd.Flags().StringVar(&config.SMTPRelayConfigFile, "smtp-relay-config", config.SMTPRelayConfigFile, "SMTP configuration file to allow releasing messages") rootCmd.Flags().BoolVar(&config.SMTPRelayAllIncoming, "smtp-relay-all", config.SMTPRelayAllIncoming, "Relay all incoming messages via external SMTP server (caution!)") @@ -175,6 +176,9 @@ func initConfigFromEnv() { if len(os.Getenv("MP_SMTP_ALLOWED_RECIPIENTS")) > 0 { config.SMTPAllowedRecipients = os.Getenv("MP_SMTP_ALLOWED_RECIPIENTS") } + if getEnabledFromEnv("MP_SMTP_DISABLE_RDNS") { + smtpd.DisableReverseDNS = true + } // Relay server config config.SMTPRelayConfigFile = os.Getenv("MP_SMTP_RELAY_CONFIG") diff --git a/go.mod b/go.mod index 54d3420..9b6190f 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/jhillyerd/enmime v1.1.0 github.com/klauspost/compress v1.17.4 github.com/leporo/sqlf v1.4.0 - github.com/mhale/smtpd v0.8.1 + github.com/mhale/smtpd v0.8.2 github.com/reiver/go-telnet v0.0.0-20180421082511-9ff0b2ab096e github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 @@ -60,7 +60,7 @@ require ( lukechampine.com/uint128 v1.3.0 // indirect modernc.org/cc/v3 v3.41.0 // indirect modernc.org/ccgo/v3 v3.16.15 // indirect - modernc.org/libc v1.40.5 // indirect + modernc.org/libc v1.40.6 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.7.2 // indirect modernc.org/opt v0.1.3 // indirect diff --git a/go.sum b/go.sum index 54c13e3..10ad90e 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mhale/smtpd v0.8.1 h1:O02u8O3eYAGxZCGf4E98WjyB+rA3DVFZtchEialjX4s= -github.com/mhale/smtpd v0.8.1/go.mod h1:MQl+y2hwIEQCXtNhe5+55n0GZOjSmeqORDIXbqUL3x4= +github.com/mhale/smtpd v0.8.2 h1:rHKOMHeFoDvcq8Na9ErCbNcjlWTSyGtznOmJpWsOzuc= +github.com/mhale/smtpd v0.8.2/go.mod h1:MQl+y2hwIEQCXtNhe5+55n0GZOjSmeqORDIXbqUL3x4= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -218,8 +218,8 @@ modernc.org/ccgo/v3 v3.16.15 h1:KbDR3ZAVU+wiLyMESPtbtE/Add4elztFyfsWoNTgxS0= modernc.org/ccgo/v3 v3.16.15/go.mod h1:yT7B+/E2m43tmMOT51GMoM98/MtHIcQQSleGnddkUNI= modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= -modernc.org/libc v1.40.5 h1:B9KljZSWzWCV2WtgQ54xu0Ig4imof21SLnKFx7qZ3os= -modernc.org/libc v1.40.5/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= +modernc.org/libc v1.40.6 h1:141JHq3SjhOOCjECBgD4K8VgTFOy19CnHwroC08DAig= +modernc.org/libc v1.40.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= diff --git a/package-lock.json b/package-lock.json index a3268d4..dd011df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1299,9 +1299,9 @@ } }, "node_modules/core-js-pure": { - "version": "3.35.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.35.0.tgz", - "integrity": "sha512-f+eRYmkou59uh7BPcyJ8MC76DiGhspj1KMxVIcF24tzP8NA9HVa1uC7BTW2tgx7E1QVCzDzsgp7kArrzhlz8Ew==", + "version": "3.35.1", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.35.1.tgz", + "integrity": "sha512-zcIdi/CL3MWbBJYo5YCeVAAx+Sy9yJE9I3/u9LkFABwbeaPhTMRWraM8mYFp9jW5Z50hOy7FVzCc8dCrpZqtIQ==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -2543,9 +2543,9 @@ } }, "node_modules/types-ramda": { - "version": "0.29.6", - "resolved": "https://registry.npmjs.org/types-ramda/-/types-ramda-0.29.6.tgz", - "integrity": "sha512-VJoOk1uYNh9ZguGd3eZvqkdhD4hTGtnjRBUx5Zc0U9ftmnCgiWcSj/lsahzKunbiwRje1MxxNkEy1UdcXRCpYw==", + "version": "0.29.7", + "resolved": "https://registry.npmjs.org/types-ramda/-/types-ramda-0.29.7.tgz", + "integrity": "sha512-8KBxZGJwUF3MpRkkJauSpvfHXk8Ssq15QXGuCBTDGeKd9PfheokkC3wAKRV3djej9O31Qa5M7Owsg8hF0GjtAw==", "dependencies": { "ts-toolbelt": "^9.6.0" } diff --git a/package.json b/package.json index 1ae34d4..7be3edf 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "build": "node esbuild.config.mjs", + "build": "MINIFY=true node esbuild.config.mjs", "watch": "WATCH=true node esbuild.config.mjs", "package": "MINIFY=true node esbuild.config.mjs", "update-caniemail": "wget -O utils/html-check/caniemail-data.json https://www.caniemail.com/api/data.json" diff --git a/server/smtpd/smtpd.go b/server/smtpd/smtpd.go index 70d8867..282e369 100644 --- a/server/smtpd/smtpd.go +++ b/server/smtpd/smtpd.go @@ -18,6 +18,11 @@ import ( "github.com/mhale/smtpd" ) +var ( + // DisableReverseDNS allows rDNS to be disabled + DisableReverseDNS bool +) + func mailHandler(origin net.Addr, from string, to []string, data []byte) error { if !config.SMTPStrictRFCHeaders { // replace all (\r\r\n) with (\r\n) @@ -191,14 +196,15 @@ func Listen() error { func listenAndServe(addr string, handler smtpd.Handler, authHandler smtpd.AuthHandler) error { srv := &smtpd.Server{ - Addr: addr, - Handler: handler, - HandlerRcpt: handlerRcpt, - Appname: "Mailpit", - Hostname: "", - AuthHandler: nil, - AuthRequired: false, - MaxRecipients: config.SMTPMaxRecipients, + Addr: addr, + Handler: handler, + HandlerRcpt: handlerRcpt, + Appname: "Mailpit", + Hostname: "", + AuthHandler: nil, + AuthRequired: false, + MaxRecipients: config.SMTPMaxRecipients, + DisableReverseDNS: DisableReverseDNS, } if config.SMTPAuthAllowInsecure {