Perspectives

…On Ideas, Startups, Technology, Internet, India and Myself.

Setting up Gmail to work from Command line on Ubuntu

with 3 comments

After some looking around, particularly this post on Ubuntu email with Mailx (which is incomplete, if you follow all the instructions, you will realise that the certificate he is talking about does not exist in the tgz that you download) and a few others, I got my mailx to work with my gmail account.

I guess you can try setting up an MTA such as exim and use sendmail or even mail, but that seemed quite complicated and I wanted to send out a mail from my shell script as quickly as possible.

Here are the steps involved which I wrote up as a little shell script:

Update: The Script got messed up when I ported the blog from Blogspot to wordpress.

#! /bin/sh

sudo apt-get install ca-certificatessudo update-ca-certificates
sudo apt-get install msmtp mailx
echo "# config options: http://msmtp.sourceforge.net/doc/msmtp.html
#A-user-configuration-file
defaults
logfile /tmp/msmtp.log

# gmail account
account gmail
auth on
host smtp.gmail.com
port 587
user EMAIL
password PASSWORD
from EMAIL
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# set default account to use (not necessary with single account)
account default : gmail" > ~/.msmtprc
chmod 600
~/.msmtprc
echo "# set smtp for nail
set from=\"EMAIL (YOUR NAME)\"
set sendmail=\"/usr/bin/msmtp\"
set message-sendmail-extra-arguments=\"-a gmail\"" > ~/.mailrc

echo "Edit CAPTIALS in .msmtprc and .mailrc and run a test message like this:
"echo "echo Message | mailx -s \"this is subject\" user@email.com\n"

Enjoy!

Related posts:

  1. finally.. Moblogging on blogger
  2. Write in LJ and read in Blogspot
  3. Write in LJ and read in Blogspot
  4. Why Adsense wont work…

Written by shivku

July 3rd, 2009 at 4:23 am

3 Responses to 'Setting up Gmail to work from Command line on Ubuntu'

Subscribe to comments with RSS or TrackBack to 'Setting up Gmail to work from Command line on Ubuntu'.

  1. Interesting! But you can already configure Gmail so many email clients on Ubuntu, why use command line (academic interest?)?

    Ajay Reddy

    29 Sep 09 at 7:42 AM

  2. Who knows where to download XRumer 5.0 Palladium?
    Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

    Anonymous

    20 Nov 09 at 11:59 AM

  3. tony

    21 Nov 09 at 12:11 AM

Leave a Reply