As a regular Ubuntu user, you might be well aware of the power of the commvà line. In this article, we will explore how you can use Gmail from within your Terminal in order lớn send emails, by configuring the msmtp client. Well, tin nhắn has a pretty useful và catchy interface, so why do we want khổng lồ opt for this commvà line approach?
Why use the Terminal for Sending Emails?
If you are a Terminal-savvy person, you wouldn’t want to leave sầu the comfort of the command line and go somewhere else lớn vì chưng any of your daily technical activities. There is always a way khổng lồ vị almost all of our stuff right inside the Terminal. So, why should sending emails be any different! Using the Terminal makes certain tasks more efficient & even faster. The comm& line tools vị not use too many resources and thus khung great alternatives to the widely used graphical applications, especially if you are stuchồng up with older hardware. Sending emails from the Terminal becomes especially handy when you can write shell scripts to lớn skết thúc emails & automate the whole process.We have sầu run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.Please follow these steps, one by one, in order khổng lồ install and configure msmtp so that you can skết thúc emails from your Terminal:
Step 1: xuất hiện the Terminal application
mở cửa the Terminal application either by using the Ctrl+Alt+T shortcut or by accessing it through the Application Launcher tìm kiếm as follows:
Step 2: Update the repository index
The next step is to update your system’s repository index through the following command:$ subởi vì apt-get updateThis helps you in installing the latest available version of a software from the Internet. Please note that only an authorized user can add, remove & configure software on Ubuntu.
You are reading: Thomashabets/cmdg: command line gmail client
Step 3: Install Msmtp client
Now you are ready to lớn install the msmtp client from the Terminal; you can vì chưng so by running the following comm& as sudo:$ subởi apt-get install msmtp-mtaThe system might ask you the password for suvày and also provide you with a Y/n option to lớn continue the installation.
Enter Y và then hit enter; the software will be installed on your system. The process may, however, take some time depending on your Internet tốc độ.
Step 4: Configure msmtp for gmail
Now is the time to lớn configure msmtp by telling it our tin nhắn credentials, the port to use, the host, and some other authorization and connection details:Advertisementmở cửa a tệp tin named msmtprc in one of your favorite text editors. I am using the famous Nano editor to open the file as follows:$ nano ~/.msmtprcThen, copy the following code in the empty file:#Gmail accountdefaults#change the location of the log file lớn any desired location.logtệp tin ~/msmtp.logaccount gmailauth onhost smtp.gmail.comfrom >auth ontls ontls_trust_file /etc/ssl/certs/ca-certificates.crtuser >password port 587#phối gmail as your default mail hệ thống.account default : gmailTip: Instead of typing the entire code in your file, you can copy it from here and paste in the Terminal by using the Ctrl+Shift+V, or by using the Paste option from the right-click thực đơn.Now, exit the file through the Ctrl+X shortcut & save the file on the “Save sầu modified buffer?” prompt by typing Y and then hitting Enter.Saving your password in text format is any of your files is never a good idea. So, you can secure the tệp tin by running the following command:$ chhack 600 .msmtprc
Step 5: Install heirloom-mailx
At this point, we have configured our computer lớn talk to lớn the remote Gmail hệ thống. What we need to bởi now is, phối up a command-line interface that will let us compose emails khổng lồ be sent. Mailx is the program that will let us do all this, and here is how we can install it:$ suvì apt-get install heirloom-mailxThe system might ask you the password for subởi & also provide you with a Y/n option to lớn continue the installation. Enter Y & then hit enter; the software will be installed on your system. The process may, however, take some time depending on your Internet tốc độ.Important: If you are not able lớn find the package in your already added repositories, open the sources.danh mục tệp tin as follows:$ nano /etc/apt/sources.listThen, add the following line to lớn add the rusty-security main universe repository from where we will install the mailx utility.deb http://security.ubuntu.com/ubuntu trusty-security main universeAlso, vị not forget to lớn run the following command before performing the installation:$ subởi vì apt-get update
Step 6: Configure Mailx
xuất hiện a tệp tin named .mailrc through one of your favorite text editors.$ nano ~/.mailrcThen, add the following lines in that file and save it.mix sendmail=”/usr/bin/msmtp”phối message-sendmail-extra-arguments=”-a gmail”
Step 7: Sover an Email through the Terminal