I think you need to use smtpd restrictions.
Snippet of my configuration:
There is a wide range of checks you can do depending on your configuration. There is a restriction set for each phase of SMTP workflow. Check more at http://www.postfix.org/postconf.5.html.
You should define restrictions for all phases, that is
smtpd_client_restrictions. In Postfix 2.10+ there is a new
smtpd_relay_restrictions option that may be perfectly suited for you.
Note that if you want your own mail to be relayed through your SMTP server, you need to be identifiable somehow - e.g. be in
$mynetworks, you use authentication.
Mine configuration also use blackhost lists, greylisting and authentication.
Basically, your SMTP restrictions should allow:
- your networks (localhost, intranet etc.; see
- authenticated users (users logged in using SMTP login, you can relay mail for them to outside servers; see
- e-mails that are delivered to you (= you are "final destination" for them; see
- optionally all other e-mail domains you are relaying e-mails for; e.g. when your server is not the final destination for some domain but is e.g. front-end proxy, you should check the recipient against a whitelist and transport it to nexthop destination.
All other e-mail, that is sent by unauthorized user from anywhere to outside servers, means open relay.