Sending mail from the command line using a gmail account

Configure Postfix for Gmail SMTP

Edit file /etc/postfix/

sudo vi /etc/postfix/

and add in the following below the commented out relayhosts :

relayhost = []:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Generate sasl_password if not already exists

sudo vi /etc/postfix/sasl_passwd

and  enter the following:]:587

Run the following commands

chown root /etc/postfix/sasl_passwd

sudo chmod 400 /etc/postfix/sasl_passwd

sudo postmap /etc/postfix/sasl_passwd

pbpaste | sudo tee -a /etc/postfix/cacert.pem

sudo postfix reload

And you are done….

Send e-mail:

Now, you should be able to send emails from within the command line:

mail -s “nuovotest”

btw, if you find that your Postfix mail system is not running, you can start it with

sudo launchctl start org.postfix.master

These info were taken primarily from a now unreachable web page:

Posted in Admin

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: