So all you want is to send a mail message from the command line or a script via the gmail SMTP server, yes?
Well, I can't help you to get postfix or sendmail working, but if you install msmtp, that'll send the mail for you. ssmtp would do the job too, but that would replace postfix which you might not want to do, but it does work with gmail.
For msmtp, you just need a ~/.msmtprc set up like this:
Put your details in, of course.
# tls_trust_file /etc/ssl/cert.pem
account default : gmail
set message-sendmail-extra-arguments="-a gmail"
After that just use the mailx command (might have to install heirloom-mailx for that) in the normal way, `mail -s "subject" person@address < message.txt`