I have a few scripts I'm running that are sending an email. I wanted to configure everything to be able to use simple mail() functions and have emails coming from my gmail account, without exposing my server. However, all of the guides I've seen end up with postfix adding a line exposing the hostname of the local server and my public IP address.
How can I configure postfix so that it looks like the email was sent directly from gmail, without relaying through another host? And I'd like to configure it on postfix end, rather than having to rewrite the script to go to gmail directly. mail() is just so convenient!
You can't.
To "hide" your local server you'll have to send the mail directly to Gmail on authenticated port 587, bypassing the local Postfix server.