How to Use Alpine in Linux to access Gmail in the command line

Source: Internet
Author: User
Tags imap gmail password

How to Use Alpine in Linux to access Gmail in the command line

For example, if you are a command line enthusiast, I am confident that you will use this powerful work environment to execute even a tool for a daily task and cheer for it, for example, from scheduling, managing finance, getting Facebook, Twitter, and other tasks. (LCTT Note: another premise for reading this article is that you can still access or know what Gmail is .)

In this post, I will show you another elegant and competent use case of Linux Command Line: Accessing Google's Gmail service. For this reason, we will use Alpine, an ncurses-Based Multi-Function Command Line mail client (do not confuse it with Alpine Linux ). We will configure Gmail IMAP and SMTP settings in Alphine to receive and send emails in the terminal environment through Google's mail server. At the end of this tutorial, you will find that you can use other email services in Alpine in just a few steps.

It is true that there are already many excellent GUI-based email clients, such as Thunderbird, Evolution, or even Web interfaces, so why are other people interested in using the mail client of the command line to collect Gmail? The answer is simple. If you need to quickly handle things and want to avoid wasting unnecessary system resources, or if you are working on a server with a streamlined installation and no console, it does not install the X service for graphic display, or the X service crashes on your desktop, and you need to urgently send some emails before solving this problem. In all of the above cases, Alpine can be used to meet your needs at any time.

In addition to simple editing, sending and receiving text Mail Information, Alpine can also encrypt, decrypt, and digitally sign mail information, as well as TLS (note: transport Layer Security, Transport Layer encryption) seamless integration.


Install Alpine on Linux

In Red Hat-based release versions, you can install Alpine as follows. You must first enable the EPEL software repository on RHEL or CentOS.

  1. # yum install alpine

In Debian, Ubuntu, or their derivative Release versions, you can do this:

  1. # aptitude install alpine

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

  1. # alpine

When you enable Alpine for the first time, it will create a mail folder (~/mail) And display the main interface, as shown in the following video: YOUTUBU video-

Its user interface has the following modules:

Feel free to browse and operate Alpine. You can always press 'q' at any time to return to the command prompt interface. Note that all the character interfaces have operation-related help.

Before proceeding, we will create a default configuration file for Alpine. To do this, close Alpine and execute the following command in the command line:

  1. # alpine -conf > /etc/pine.conf


Configure Alpine to use the Gmail account

When you install Alpine and spend at least a few minutes getting familiar with its interface and menu, the following is the time to actually configure it to use an existing Gmail account.

Before performing the following steps in Alpine, you must first enable the IMAP protocol in your Gmail settings on your Web mail interface. Once IMAP is enabled in your Gmail account, perform the following steps to enable the Gmail information reading function in Alpine.

First, start Alpine.

Set by 's', and then press 'l' to selectcollectionListsOption to define different folder categories to help you better organize your emails:

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

  • Nickname: enter any name you want to write;
  • Server: protected]

You canPathAndViewLeave it blank.

Then pressCtrl+XEnter your Gmail password when prompted:

If everything goes smoothly as expected, a new folder named after your nickname appears. You can find your Gmail mailbox here:

To verify the mail, you can compare the mail box "Gmail Sent" displayed in Alpine with the mail box displayed on the Web interface:

By default, it will automatically check new emails or prompts every 150 seconds. You can/etc/pine.confAnd you can modify many other settings. This configuration file has detailed and clear annotations. For example, to set the interval for checking new emails to 10 seconds, you need to set it as follows:

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

Finally, we need to configure an SMTP server to send emails through Alpine. Go back to the previously explained Alpine setting interface, and then press 'C' to set a Google SMTP server address. You need to edit it as follows:SMTP Server(Used to send an email) This line of content:


When you press 'e' to exit the settings page, you will be reminded to save the changes. Once you save the changes, you can use Alpine to send emails immediately! To this end, go to the main menuComposeOption, and then start to operate your Gmail from the command line.



In this post, we discussed how to access Gmail through a lightweight and powerful command line mail client named Alpine in the terminal environment. Alpine is a free Software released under the Apache Software License 2.0 protocol, which is compatible with the GPL protocol. Alpine is proud to be not only friendly to new users, but also to make those experienced System Administrators think it is powerful. I hope that after you read this article, you will realize how correct my last argument is.

You are welcome to use the input box below to leave your comments or questions. I look forward to your feedback!

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.