In order to send mail from a localhost, you would need to enable the smtp server as a host.
First you would have to edit the main.cf file to add in the relayhost
sudo vim /etc/postfix/main.cf
//Add the below code to after the commented relayhost code
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
Next you would have to generate a sasl_password if it doesn’t exist
sudo vim /etc/postfix/sasl_passwd
add in the below to sasl_passwd
Lastly restart the postfix
sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master
You might want to consider using
sudo su - since root access is required for all the above operations.
Credit given to Anuj Gakhar.
Although the article was for Lion, it works for Yosemite too.