axllent / mailpit

An email and SMTP testing tool with API for developers
https://mailpit.axllent.org
MIT License
6.18k stars 153 forks source link

Recipient allowlist on smtpd #375

Closed sorcix closed 1 month ago

sorcix commented 1 month ago

I'm using Mailpit as a simple single-user temporary e-mail server. While I understand it's not meant to be used like this, it actually works really great. The only downside, for my use case, is that it accepts every random message sent to port 25.

Would you accept a PR that adds an additional flag --smtp-allow-recipients that takes a regex and rejects/drops e-mails where the recipient doesn't match? Could be used with something like @(temp.example.com|foo.com)$.

axllent commented 1 month ago

I'm pretty sure this already exists.

From the docs: --smtp-allowed-recipients: Only allow SMTP recipients matching a regular expression. Use this to restrict incoming mail to only those sent to a pre-defined list. An example would be --smtp-allowed-recipients '@example.com$' to only allow emails sent to recipients ending in @example.com.

sorcix commented 1 month ago

D'oh. I managed to overlook an option that's named almost the same as what I proposed. That's what I was looking for, thanks.

axllent commented 1 month ago

All good ;-) There's a lot of options unfortunately, so sometimes easy to overlook stuff.