Skip to main content

Service From Terminal Of Ubuntu

Hello Friends ,


Now you can access your favorite mail service -gmail form terminal in a linux system with a command line interface. People may wonder why anyone would want to use gmail from the command line, when Google has created such a nice user friendly interface for its users. There are a lot of reasons why one would want to use a CLI (command-line interface) for sending mail. One of the main reasons being the power of shell scripting in a Linux machine. You can automate the entire process by writing small shell scripts and make life much easier. The other reason why I use the command line way is because it uses very less bandwidth. Due the recent D-DOS (Distributed Denial-of-Service) attack on the domain name system by a group of really talented Hackers my computer seemed to take ages to load even Facebook that was when the terminal way of sending mails came in handy.
Lets get started. I use Ubuntu (current version) I’m having issues with this method. If you have some other flavor of Linux you might have to port the commands to work on your system.

This is actually pretty easy, here's what you have to do:

1. Install ssmtp. For Ubuntu, open a terminal and paste the following command:


sudo apt-get install ssmtp


2. Edit the ssmtp config file. Press Alt + F2 and type:


gksu gedit /etc/ssmtp/ssmtp.conf

If you don't use Gedit, replace it with your favourite text editor (kate, etc).
And paste this inside the ssmtp.conf file:


root=YOUR_EMAIL@gmail.com
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=YOUR_GMAIL_USERNAME # (without @gmail.com)
AuthPass=YOUR_GMAIL_PASSWORD
FromLineOverride=YES
UseTLS=YES

And replace everything in capital letters with your credentials.


3. That's about it. There are multiple ways you can now send an email. Open a terminal and:

a)
echo "email content" | mail -s "email subject" email_address_to_send_email_to@somedomain.com

The above line is pretty much self explainatory so replace the text between the quotes with your email body and subject and do the same for email_address_to_send_email_to@somedomain.com - replace it with the email address you want to send the email to.

b)
ssmtp email_address_to_send_email_to@somedomain.com

Then enter the following lines in the terminal (pressing ENTER after each line):
To: email_address_to_send_email_to@somedomain.com
From: your_email@gmail.com
Subject: this is your email subject

And here you can write the content of the email

And to send the email, press: CTRL + D

This time I won't explain what to replace, I hope you got the idea. Please note that you must follow the exact format as above, with an empty line between the email subject and the content of the email.

c)
You can also send emails from a text file. Use the following command:


ssmtp email_address_to_send_email_to@somedomain.com < message.txt

Where message.txt must follow the exact same format like on point b) (above).

This has a lot of things it can be used for. You can set a cron job to email you different things at a given time, etc. I'm sure you can think of something you could use this for.

Important security note: as the password will be saved in plain text, I advise you not to use your main Gmail account. Instead, create one just for this.

Comments

  1. It will Helpful to do with this CLI(Command Line Interface)

    ReplyDelete

Post a Comment

Popular posts from this blog

Install Conky Manager in Ubuntu 14.04 and 14.10

Install Conky Manager in Ubuntu: Conky Manager is available in the developer’s PPA for Ubuntu 14.10, Ubuntu 14.04, Ubuntu 13.10 and Ubuntu 12.04. Press  Ctrl+Alt+T  to open terminal. When it opens, run the following commands one by one: sudo add-apt-repository ppa:teejee2008/ppa sudo apt-get update sudo apt-get install conky-manager You can also see from here http://www.webupd8.org/2014/06/conky-manager-gets-revamped-ui-new.html

Play Song From Terminal

1) sudo apt-get install sox For formating to mp3 and other extension we need decoder of Sox 2 ) sudo apt - get install libsox - fmt - mp3 Now go to the directory of your Music and give command as play *.mp3 it will play music and if you want to go to another song then press `ctrl + c`  To terminate press `ctrl+c+c` Thanks For seeing and i hope you like this  ENJOY ------------------------------------- Please if you like this Post so do not Forget to Comment and like 

Wallch 4.0 Added Clock Wallpaper in Ubuntu 14.04

Wallch  is free wallpaper utility for Linux, it offers user friendly graphical user interface. Developer introduced new feature live clock wallpaper in latest Wallch 4.0 version, which is also offered in  slidewall  wallpaper application. Wallch is open-source application, which allows anyone to download and modify code as per needs. It supports all major Linux desktops such as Unity, Gnome, LXDE, XFCE, and Mate. It doesn't simply change your desktop background with the wallpapers that you have in your hard disk, though. While it does that well by monitoring the folder that you have selected for new or deleted pictures, it has lots of features, like Picture of the day, Live Earth, Wallpaper Clocks and Live Website! Get Wallpaper from    VladStudio.com . >>> Wallch 4.0 only available for Ubuntu 14.04 Trusty Tahr/Linux Mint 17 To install Wallch 4.0 in Ubuntu 14.04 Trusty/Linux Mint 17 open Terminal (Press  Ctrl+Alt+T ) and copy the following commands in the Termi