mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-27 09:16:02 +03:00
[GH-ISSUE #230] How to disable reverse DNS lookup? #148
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#148
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Atesca on GitHub (Jan 3, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/230
Mailpit uses smtpd as smtp server
smtpd tries to do a reverse DNS lookup of the IP sending the mail, see https://github.com/mhale/smtpd/blob/cfd012220c479797ab15cee042831c95ea95dd1e/smtpd.go#L244
docker compose generates a domain name based on <contianer_name>-<container_id>.<network_name>
if I run the Mailpit as part of a docker compose project the generated name might get too long and the reverse DNS lookup return bad rdata
dockerd[1528]: level=error msg="[resolver] failed to write response" error="dns: bad rdata"with that bad rdata the lookup times out after 10 seconds and the sender is resolved as
unknownBut the 10 second timeout is too long for the Symfony 4.4 Mailer which uses a timeout of 5 seconds, see https://github.com/symfony/mailer/blob/554b8c0dc2db9d74e760fd6b726f527364f03302/Transport/Smtp/Stream/SocketStream.php#L29
Even with newer versions of Symfony, waiting 10 seconds for the timeout to occur seems wrong
Steps to reproduce:
Create a directory
really-long-project-name-for-testing-dns-rdataadd a
docker-compose.yamlwith:add a demo
email.txtsend the email with
docker compose run --rm curl smtp://mailpit:1025 --mail-from sender@example.com --mail-rcpt recipient@example.com --upload-file /email.txtIt will send the email with an "unknown" as the hostname of the sending IP, but it'll take 10 seconds which is too long to send emails from a Symfony 4.4 project
@axllent commented on GitHub (Jan 3, 2024):
@atesca09 Yes I can confirm this problem. There are two issues here:
--name <shorter-name>to your docker compose command and provide a valid hostname. There is an open issue for Docker relating to this.mhale/smtpdpackage, not Mailpit itself. The 10s timeout is however a hardcoded DNS lookup timeout in Go itself, so that timeout can't be changed in smtpd. Please refer to the open issue on smtpd where there is a request to optionally allow disabling the DNS lookup entirely (which I could then make configurable with a flag in Mailpit). Whilst this does not change the Docker bug (names longer than 63 chars), there are several other reasons one may want to disable DNS lookups in smtpd. Please feel free to add to that smtpd issue so the author understands the need and can then maybe implement the option to disable it sooner.In the meantime there is nothing I can do here unfortunately.
@Atesca commented on GitHub (Jan 4, 2024):
@axllent yeah I thought so, I was just checking in, in case I missed something.
Unfortunately the workaround specifying a shorter name isn't an option for me in the current setup.
I guess we'll have to wait for smtpd to provide the option to skip the reverse DNS lookup
@axllent commented on GitHub (Jan 4, 2024):
@atesca09 I will probably submit a pull request to smtpd later today if get around to it. Out of curiosity, are you using Gitlab CI (in relation to it not being an option for you)?
@Atesca commented on GitHub (Jan 5, 2024):
@axllent No the issue for my use-case isn't in GitLab. Besides the workaround with emptying /etc/resolv.conf is unacceptable for the use-case. It is more a problem with the amount of projects that are affected (~100+) and the amount of changes that have to be made just to replace the old mailhog with mailpit
@axllent commented on GitHub (Jan 21, 2024):
@atesca09 This new feature has been released in v1.13.0 and should solve your issue completely. Starting Mailpit with either the
--smtp-disable-rdnsflag or settingMP_SMTP_DISABLE_RDNS=truein your environment (Docker) disables the reverse DNS entirely. Obviously you need to pull the latestaxllent/mailpitimage first :)Please confirm this resolves your issue? Thanks.
@Atesca commented on GitHub (Jan 21, 2024):
Confirmed, this works for me. Thanks a lot @axllent