How to setup intermediate SMTP mail server / relay to filter outgoing emails

filteringsmtpwhitelist

I want to block all outgoing emails except to few whitelisted domains. what are the best ways to go about it?

Can I put an intermediate Intranet server which will do filtering based on whitelist and forward requests to actual SMTP server if its allowed?

update:
this one is similar but can't figure out actual details.
How to properly filter outgoing e-mail?

this looks interesting:
https://serverfault.com/a/122772

Update: is it possible to forward same user credentials from relay to actual SMTP server?

Best Answer

Yes. Yes you can - or at least someone can. With the lack of detailed information about your existing setup, that's the most detailed answer I can give you.

/Edit : The only thing you set in the local email client is which SMTP server to send mail through. Create your hypothetical new server and configure your clients to use it. Safelist/blocklist is all done on your new server.

/Edit again, based on your new question. is it possible to forward same user credentials from relay to actual SMTP server?

Could you please describe more fully the problem you're trying to solve, and the constraints you're working under? You haven't even bothered to tell us what MTA you're using or planning to use, and what type of authentication.