There are plenty of checks you can put in place inside
main.cf which allow you to do exactly what you want. Some may be in place, others may not. For example Debian and Ubuntu often seem to have sensible defaults, whereas RHEL etc often do not.
In a canonical
main.cf you would usually have
mydestination to be a comma separated list of domain names allowed as destination domains. Furthermore you'd probably only allow accepting certain things such as relaying by setting
mynetworks to a list of IP addresses and subnets (CIDR). And then, to put everything together based on (among other things) those two values you set
smtpd_recipient_restrictions, e.g. here an excerpt:
The order of the restrictions does matter. You can see how we already restrict taking in messages before we permit for
You best course of action is likely to read the excellent documentation, e.g. here about the topic you seem most concerned about.