How do I configure the Postfix mail submission agent to only allow emails to be sent out from a user on localhost , but allow the Postfix mail transfer agent to receive mail from anywhere?
The simplest way is to make sure you have only localhost defined in
mynetworks = 127.0.0.0/8, [::1]/128
smtpd_recipient_restrictions is set as:
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
This will allow hosts defined in
mynetworks (localhost, as above) to send anywhere, while everything else is rejected unless it's destined for your box or otherwise explicitly allowed (relay domains, virtual domains, or whatever other configurations you're allowing.)