Categorized | Computers

Using Alpine to Check Your Email/Gmail in Linux Terminal

Posted on 02 November 2009 by Jason Grimme

In further effort to learn how to do things the most complicated way possible on Linux, I wanted to be able to access my Gmail account when using SSH to log onto my computer from anywhere.

First Method: Using Lynx

The first method I thought of to access my Gmail was to use Lynx, a text only web-browser. Using Lynx would allow you to read nearly all web-based email accounts. This method is easy and works great, but it can be frustrating to navigate a web page in Lynx.

Second Method: Perl and cURL

This first and rather simple method uses cURL to grab an Atom XML feed of your Gmail inbox. It then pipes that to Perl to parse and display them in Terminal.

1
2
3
# Author: Dipin Krishna
# Replace username with your gmail username (including @gmail.com)
$ curl -u username --silent "https://mail.google.com/mail/feed/atom" | perl -ne 'print "\t" if //; print "$2\n" if /<(title|name)>(.*)<\/\1>/;'

Third Method: Alpine Messaging System

Alpine Messaging System is a terminal-based program written by the University of Washington that includes IMAP support. With IMAP, we can browse folders, delete, and compose. This is the best solution for having terminal access to your email.

Note: You will have to enable IMAP support in your Gmail account. Settings -> Forwarding and POP/IMAP -> Enable IMAP.

1
sudo apt-get install Alpine

Start Alpine and you will be presented with the main menu.
To set Alpine up with your Gmail information, press M (Main) -> S (Setup) -> C -> (Config).

Personal Name: (Your name)
User Domain: gmail.com
SMTP Server: smtp.gmail.com:587/tls
Inbox Path: {imap.gmail.com/ssl/user=username@gmail.com}inbox

Now if you navigate back to the main menu and press L (Folder List), you should see a ‘Mail’ folder. Select the ‘Mail’ folder and then the ‘INBOX’ folder, and you will be asked for your password. Once you enter that, you will be able to read your inbox.

This is great until you realize that if you have use Gmail filters to push emails in labels, you can’t see them in the inbox view. To support the labeling system, we must add a collection list.
Go back to the menu and press S (Setup) -> L (Collection List) -> A (Add) and enter the following.

Nickname: Labels ( or whatever you want)
Server: imap.gmail.com/ssl/user=username@gmail.com
Path: (empty)
View: (empty)

Now when you go to your folder list, you will see your new view with all of your labels. You can view each one individually.

One last thing that I did was create another view with ALL of my emails, regardless of the labels. To do this:
Go back to the menu and press S (Setup) -> L (Collection List) -> A (Add) and enter the following.

Nickname: All Emails ( or whatever you want)
Server: imap.gmail.com/ssl/user=username@gmail.com
Path: [Gmail]/
View: (empty)

That is all today on Alpine, but perhaps I will find some more interesting features and share them as well! Please let me know if you do.

Tags | ,

One Response to “Using Alpine to Check Your Email/Gmail in Linux Terminal”

  1. Sean says:

    Great tutorial/guide. Was wanting to do just this, and I sure came to the right place =P. Concise and easy to follow.

    Thanks


Leave a Reply

Security Code:

-->