Send e-mails from the Linux Terminal using Google Mail

This is just one of those things where you never know when you might need it, add it to your collection. Once setup it’s quite simple and quick to send an e-mail using the the Gnome-Terminal (or equivalent) in Linux.

Gnome-Terminal

So to begin, first we’re going to open the Terminal and install sendemail:

sudo apt-get install sendemail

We also need to install some other packages it relies on:

sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl perl

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz

Unpack it:

tar zxvf sendEmail-v1.55.tar.gz

Copy it to /usr/local/bin/

sudo cp sendEmail-v1.55/sendEmail /usr/local/bin

Apply the correct Permissions:

sudo chmod +x /usr/local/bin/sendEmail

Send the e-mail:

sendEmail -f fromaddress@gmail.com -t toaddress@example.co.uk
-u any title you like -m “this is the message”
-s smtp.gmail.com
-o tls=yes
-xu gmailusername -xp gmailpassword

Note: gmailusername doesn’t include the @gmail.com


Tags: , , , ,


9 Responses to “Send e-mails from the Linux Terminal using Google Mail”

  1. Create Virus says:

    Thanks a lot man !

  2. Mojo says:

    This is the opposite of useful.
    But thanks anyway, seems cool.

  3. scooterman says:

    I just couldn’t resist practicing using the terminal commands by installing this! Sounds crazy, but I’m a noobie and need all the practice and help I can find.

  4. Bruce Schaller says:

    This is cool because it makes it so easy to send emails in a script!

  5. iggdawg says:

    @mojo – It’s not useful for the unwashed masses. But it’s great for things like automated tasks that you want feedback on in a given condition. Or even better for things like Nagios (if you don’t know, pretend I didn’t mention it). For example, this line in cron is pretty handy:

    @reboot root /bin/echo “Oh craps, I think I rebooted” | /usr/bin/mail -s “cron” (insert target email address here)

    Every time my box reboots, I get notified and can attend to it. Just one of the many great uses.

  6. [...] This is where I completly drop myself in it, I wrote an article a little while ago which implyed that this was useful. I now see the error of my ways now, it is quite simply sending an e-mail through the Terminal. To see my article and how to do it go to: http://www.turtleblog.co.uk/2009/04/send-e-mail-from-terminal-using-gmail/ [...]

  7. Vivek Thakar says:

    How can I attach files using the same program.

  8. Edd Turtle says:

    … I’m not sure you can… hmm, maybe I’ll look into it :D

  9. INVONDILI says:

    Looks like you are a true professional. Did ya study about the theme? hrhr


Leave a Comment