Sending mail from the command line using a gmail account

Configure Postfix for Gmail SMTP

Edit file /etc/postfix/main.cf:

sudo vi /etc/postfix/main.cf

and add in the following below the commented out relayhosts :

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_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:

smtp.gmail.com]:587 username@gmail.com:password

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” marco.ronchetti@gmail.com

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:

http://www.mactipper.com/2009/10/send-email-from-gmail-from-command-line.html

Advertisements
Posted in Admin

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: