I would like to have a spamassasin rule that by default disables all external Emails to groups with exclusion of only a few groups. Thus [email protected]
should not be able to [email protected]
.
While internal users should be able to those groups.
Only some group address should be possible for external usage
[email protected]
is allowed to email [email protected]
.
Entirely misdirected mail (or even, for the outside world, nonexisting addresses) is a separate concept from spam. This is generally not something you want to skew your spam filtering metrics - so let the mail server reject them.
For postfix, you probably want to utilize the fact that the right hand side of
access
maps can lead to another lookup:/etc/postfix/access_recipient.pcre
:/etc/postfix/maps/access_sender_internal.pcre
Note that the order of
smtpd_recipient_restrictions
matters here - if you were to order any whitelisting mechanism before the new access lookup, it would be circumvented. Note also that this filters based onsender
- if you for some reason accept external mail claiming to be originating from you, then filtering based onpermit_sasl_authenticated
orpermit_mynetworks
may be more appropriate, lest the otherwise restricted groups can be sent mail to if merely claiming to be an internal sender.