Linux: Access Gmail from the Command Line with Alpine

If you're a command line lover, I'm pretty sure you'll use this powerful work environment to perform even a daily task and cheer for the tools, such as tasks ranging from scheduling and managing finances to accessing Facebook, Twitter, and more . (LCTT Annotation: Another prerequisite for reading this article is if you still have access to Gmail or know what Gmail is.)

 

In this thread, I'll show you another nifty and neat use case for the Linux command line: accessing Google's Gmail service , for which we'll use Alpine, a versatile command-line mail client based on ncurses (don't and Alpine Linux confusion). We'll configure Gmail's IMAP and SMTP settings in Alphine to receive and send mail in a terminal environment via Google's mail servers. At the end of this tutorial, you will find that you can use other mail services in Alpine in just a few steps.

 

Granted, there are plenty of excellent GUI-based mail clients out there, such as Thunderbird, Evolution, or even a web interface, so why would anyone be interested in using a command-line mail client for things like Gmail? The answer is simple. Suppose you need to get things done quickly and want to avoid wasting unnecessary system resources; or you're working on a thin-install consoleless server that doesn't have the X service installed for graphics; or the X service is on your 's desktop crashes, and you need to eagerly send some emails before fixing that. In all of the above situations, Alpine can come in handy and meet your needs at any time.

 

In addition to simple functions such as editing, sending and receiving text-based email messages, Alpine can also encrypt, decrypt and digitally sign email messages, as well as seamlessly integrate with TLS (Note: Transport Layer Security, Transport Layer Encryption).

 

Install Alpine on Linux

On Red Hat based distributions, Alpine can be installed as follows. Note that on RHEL or CentOS, you need to enable the EPEL repositories first.

# yum install alpine

 

On Debian, Ubuntu or their derivative distributions, you can do this:

# aptitude install alpine

 

After the installation is complete, you can run the following command to start the mail client:

# alpine

 

When you start Alpine for the first time, it will create a mail folder (~/mail) in the current user's home directory and bring up the main interface, as shown in the video below: YOUTUBU Video - https:/ /www.youtube.com/watch?v=fZuqyHOYhd8

 

Its user interface has the following modules:

Linux: Access Gmail from the Command Line with Alpine

Feel free to browse and play around to familiarize yourself with Alpine. You can always go back to the command prompt interface at any time by typing 'Q'. Note that all character screens have help related to operations below them.

 

Before going any further, we will create a default configuration file for Alpine. To do this, close Alpine and execute the following command on the command line:

# alpine -conf > /etc/pine.conf

 

 

Configuring Alpine to use a Gmail account

After you've installed Alpine and spent at least a few minutes getting acquainted with its interface and menus, it's time to actually configure it to use an existing Gmail account.

 

Before performing the steps below in Alpine, remember to first enable the IMAP protocol in your Gmail settings via your webmail interface. Once IMAP is enabled in your Gmail account, follow the steps below to enable reading Gmail messages in Alpine.

First, start Alpine.

 

Press 'S' to set, then press 'L' to select the collectionLists option to define different folder categories to help you organize your mail better:

Linux: Access Gmail from the Command Line with Alpine

Press 'A' to create a new folder and fill in the necessary information:

 

You can leave Path and View blank.

Then press Ctrl+X and enter your Gmail password when prompted:

Linux: Access Gmail from the Command Line with Alpine

If all goes well as expected, a new folder will appear named after the nickname you filled in earlier. You should be able to find your Gmail mailbox here:

Linux: Access Gmail from the Command Line with Alpine

To verify, you can compare the "Gmail Sent" mailbox displayed in Alpine with the mailbox under the web interface:

Linux: Access Gmail from the Command Line with Alpine

By default, every 150 seconds, it will automatically check for new mail or alerts, you can change this value in the file /etc/pine.conf, and you can also modify many other settings. This configuration file has detailed and clear comments. For example, to set the interval for checking for new mail to 10 seconds, you would set it like this:

# The approximate number of seconds between checks for new mail
mail-check-interval=10

 

Finally, we need to configure an SMTP server to send mail through Alpine. Go back to the Alpine settings screen explained earlier, and press 'C' to set a Google SMTP server address, you need to edit the SMTP Server (for sending mail) line like this:

smtp.gmail.com:587/tls/[email protected]

 

When you press 'E' to leave the settings screen, you will be prompted to save your changes. Once you've saved your changes, you'll be ready to send emails through Alpine! To do so, go to the Compose option in the main menu and start working with your Gmail from the command line.

 

Summarize

In this post, we discussed how to access Gmail in a terminal environment through a lightweight and powerful command-line mail client called Alpine. Alpine is a free software released under the Apache Software License 2.0, which is compatible with the GPL. Alpine prides itself on being not only novice friendly, but also powerful enough for seasoned sysadmins. I hope that after you read this article, you realize how true my last statement is.

 

Other picture references:

Linux: Access Gmail from the Command Line with Alpine
Linux: Access Gmail from the Command Line with Alpine
Linux: Access Gmail from the Command Line with Alpine

 

More references:

https://www.sjwrc.com/guides/alpine-and-gmail/

How can I use Thunderbird local folders in Alpine mail client?

Linux commands that beginners must master

8 Practical Techniques Programmers Learn Over the Weekend

 

 

This article is reprinted from: Linux: Access Gmail from the command line with Alpine

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326572433&siteId=291194637