mjl- / mox

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

How to block a specific account for incoming emails? #156

Open ally9335 opened 6 months ago

ally9335 commented 6 months ago

There're 2 emails I have: the main one and catchall. I receive spam on 3rd, specific, email address that's among "catchall".

Is there a way to block it for incoming emails? Whether it be soft reject or bounce, or hard one - doesn't matter.

mjl- commented 6 months ago

hi @ally9335, i don't think that's possible currently. but your use-case makes sense.

to implement this, i think we could extend the "rulesets" of a "destination" in an "account". https://www.xmox.nl/config/#cfg-domains-conf-Accounts-x-Destinations-x-Rulesets

we could add an SMTPRcptToRegexp, just like the "mail from" (the code already has a todo for that, see https://github.com/mjl-/mox/blob/a3f5fd26a6ce4df1b7acaf6a37479c3959aa6a4a/config/config.go#L450).

a ruleset currently has a group of fields that influence matching, and a group of fields that influence spam filtering, and then a "Mailbox" to deliver to. we could add a field that specifies the kind of error to return, e.g. "user not found" (550 i believe), or a limited set of other errors.

your catchall destination could then be configured with a regexp matching the 3rd address that is being spammed, and with an error response that rejects the message. the smtp server would have to recognize this configuration.

perhaps there are other/better options.

ally9335 commented 6 months ago

@mjl- there's no middleware support? Milter as in Postfix? It then could attached, if there was support for it, without changing the existing code.

mjl- commented 6 months ago

@mjl- there's no middleware support? Milter as in Postfix? It then could attached, if there was support for it, without changing the existing code.

no, currently no milter code. it would be quite involved in the smtp server. and setting it up would complicate setting up quite a bit. we've had more requests about it. so far the approach has been to look at the use case and just implement it directly in mox. but milter support may come at some point...

another option is a new config option (e.g. in a ruleset) to deliver to an lmtp connection instead of a mailbox. that has been requested as part of running mailing list software. it could also be configured to send to an lmtp service that just rejects the message.

but as a user it doesn't sound too great to have to configure a milter or an lmtp service just to get email to a message rejected. (:

ally9335 commented 3 months ago

@mjl- If I add an address on which I receive spam into the list, won't this work? Or is this list for the opposite case - for outgoing emails?

image

mjl- commented 1 month ago

@ally9335 the suppression list is indeed for messages submitted to mox for outgoing delivery. so that won't help. late reply, sorry, i didn't see this message before. currently, the best solution could still be to let a ruleset match on rcptto, and specify a custom smtp response.

ally9335 commented 1 month ago

currently, the best solution could still be to let a ruleset match on rcptto, and specify a custom smtp response.

Where is it specified? If it's described in the documentation, where? @mjl-