» about » content » twitter » github »

Alpine Email Client

Justification

Note: this document used to cover the precursor to Alpine, Pine, but I have updated it as Pine is no longer being updated. Alpine is based on Pine, and is currently almost identical to use.

Alpine is an easy to use command-line mail user agent (MUA) created and offered for free by the University of Washington. There are several others like mutt and elm, but I preferred Alpine when I wanted a command-line client, because I used to mostly check my personal email from remote locations via ssh. These days, I mainly use Google Apps to check my email, but I still use Alpine's export feature to backup my imap folders, and I use it to manage my email archives.

Platforms

What operating systems does Alpine run on? - Just about anything that can run gcc including Windows and MAC OS X. You can find Alpine installed by default on many GNU/Linux distributions, and is available for many more.

Entry screen example

ALPINE 2.00   MAIN MENU              Folder: INBOX               61 Messages +
 
 
          ?     HELP               -  Get help using Aline
 
          C     COMPOSE MESSAGE    -  Compose and send a message
 
          I     MESSAGE INDEX      -  View messages in current folder
 
          L     FOLDER LIST        -  Select a folder to view
 
          A     ADDRESS BOOK       -  Update address book
 
          S     SETUP              -  Configure Alpine Options
 
          Q     QUIT               -  Leave the Alpine program

  
                  Copyright 2006-2008 University of Washington
                    [Folder "INBOX" opened with 61 messages]
? Help                     P PrevCmd                 R RelNotes
O OTHER CMDS > [ListFldrs] N NextCmd                 K KBLock
    

Composition screen example

ALPINE 2.00   MAIN MENU              Folder: INBOX               61 Messages +
 
From    : Roqetman 
To      : notarealaddress@notarealurl.com
Cc      :
Attchmnt:
Subject : An example email
 
Here's where I type my message...
 
Roqetman
This is my Signature
 
 
^G Get Help  ^X Send      ^R Read File ^Y Prev Pg   ^K Cut Text  ^O Postpone
^C Cancel    ^J Justify   ^W Where is  ^V Next Pg   ^U UnCut Text^T To Spell
    

Pico commands

Pico is Alpine's message composition editor (you can modify Alpine to use another editor if you wish). Pico is a stand-alone editor too; it is quite simple to use and has become a favorite of mine. Although I mostly use vim outside of the alpine environment, I have become quite comfortable using pico within that environment. Some of the commands will probably be quite familiar to emacs users. Most of the commands you need are displayed along the bottom of the screen.

jump to start of line : ctrl-a

jump to end of line : ctrl-e

page-down : ctrl-v

page-up : ctrl-y

jump to bottom : ctrl-w ctrl-v

jump to top : ctrl-w ctrl-y

set mark (for copy) : ctrl-^

cut line (or marked text) : ctrl-k

paste : ctrl-u

delete : ctrl-d

backspace : Backspace

delete : backspace (yup, you read that right, depends on your terminal settings)

wrap text : ctrl-j

search : ctrl-w

replace : (NOTE pico needs to be started with -b for this to work) ctrl-w ctrl-r

spell-check : ctrl-t (note that pico needs to be started with -s ispell for this to work), I add this line to my .profile: alias pico='pico -s ispell' so that this can be done automatically.

get cursor position - ctrl-c

insert an external file : ctrl-r

exit (will prompt to save) : ctrl-x

sort threads : $ h

delete/mark as read all messages : ; then a then a then *

Note if you accidentally "freeze" the screen by typing ctrl-s (a common error), then type ctrl-q to unfreeze it.

Additional configuration

Most of these settings are not required, but if you need to do any of these, add them to your .pinerc file, or make changes in your configuration from within pine.

# Sets the domain or host name for the user, overriding the system host or domain name:
user-domain=somewhere.com
 
# Can be set to yes or no. Anything but yes means no. If set to yes the first label in 
# the host name will be lopped off to get the domain name and the domain name will be 
# used for outgoing mail and such.  That is, if the host name is carson.u.example.edu 
# and this variable is set to yes, then u.example.edu will be used on outgoing mail. 
# Only meaningful if user-domain is NOT set.
use-only-domain-name=
 
# List of SMTP servers for sending mail. If blank: Unix Pine uses sendmail.
smtp-server=smtp.MyISPSMTPServerNAme.com:587/novalidate-cert/user=d12345678-roq--man
#smtp-server=SMTP.MyISPSMTPServerNAme.com:888

# Path of (local or remote) INBOX, e.g. ={mail.somewhere.edu}inbox
# Normal Unix default is the local INBOX (usually /usr/spool/mail/$USER).
# the following sb left blank if your mail is delivered locally, however, here
# is an example if you want to connect to an imap server for your inbox
inbox-path={imap.MyISPSMTPServerNAme.com/novalidate-cert/user=roq--man@somewhere.edu}INBOX
 
# roles (to change the "from" in the header (this should all be on a single line)):
patterns-roles=LIT:pattern="/NICK=gmail/FROM=/SENDER=/FLDTYPE=EMAIL"
action="/ROLE=1/FROM=roq /REPL=Roq /
SIG=.sig.gmail/SMTP=smtp.gmail.com\/user=roq--man@gmail.com\/ssl\/
novalidate-cert/RTYPE=YES/FTYPE=YES/CTYPE=NO"
 
# NNTP server for posting news. Also sets news-collections for news reading.
nntp-server=news-server.MyISPSMTPServerNAme
 
# if you don't want Alpine to create new "sent-mail" folders at the start of each month:
last-time-prune-questioned=999.99
 
# List of features; see Alpine's Setup/options menu for the current set.
# e.g. feature-list= select-without-confirm, signature-at-bottom
# Default condition for all of the features is no-.
feature-list=include-text-in-reply,
        quit-without-confirm,
        expunge-without-confirm,
        expunge-without-confirm-everywhere,
        select-without-confirm,
        preserve-start-stop-characters,
        enable-full-header-cmd,
        signature-at-bottom,
        strip-from-sigdashes-on-reply,
        enable-sigdashes,
        single-column-folder-list,
        enable-aggregate-command-set,
        enable-flag-cmd,
        expanded-view-of-addressbooks,
        no-combined-addrbook-display,
        disable-sender,
        no-scramble-message-id,
        alternate-role-menu
 
#
# My favorite color preferences...
#
 
# Controls display of color
color-style=force-ansi-16color
# Choose: black, blue, green, cyan, red, magenta, yellow, or white.
normal-foreground-color=white
normal-background-color=black
reverse-foreground-color=black
reverse-background-color=white
title-foreground-color=black
title-background-color=cyan
status-foreground-color=yellow
status-background-color=black
keylabel-foreground-color=
keylabel-background-color=
keyname-foreground-color=
keyname-background-color=
selectable-item-foreground-color=
selectable-item-background-color=
quote1-foreground-color=yellow
quote1-background-color=black
quote2-foreground-color=
quote2-background-color=
quote3-foreground-color=
quote3-background-color=
signature-foreground-color=
signature-background-color=
prompt-foreground-color=
prompt-background-color=
index-to-me-foreground-color=yellow
index-to-me-background-color=black
index-important-foreground-color=
index-important-background-color=
index-deleted-foreground-color=magenta
index-deleted-background-color=black
index-answered-foreground-color=cyan
index-answered-background-color=black
index-new-foreground-color=red
index-new-background-color=black
index-recent-foreground-color=green
index-recent-background-color=black
index-unseen-foreground-color=red
index-unseen-background-color=black
 
# When viewing messages, these are the header colors
viewer-hdr-colors=/HDR=From/FG=yellow/BG=black,
        /HDR=Subject/FG=green/BG=black,
        /HDR=Date/FG=yellow/BG=black,
        /HDR=X-Troll/FG=red/BG=black,
        /HDR=Importance/FG=red/BG=black/VAL=High
    

mbox

Alpine stores it's mail in mbox format, and gets it mail from /var/spool/mail/username. However, if you want your inbox to be in your local (home) directory, then from your home directory (~/) type: touch mbox, and then when you next start Pine, it'll move mail into that inbox. I sometimes prefer it this way for backup purposes. Please note that this *only* applies to the inbox; the rest of your mail is stored in your ~/mail folder. Also, if you are using an imap server for your inbox, then disregard this.

How Do I...

Search through all emails in a folder : Type the following (explanation follows): ; then t then a then your search text; this is what they stand for: ; - select, t - text, a - all message text, (note that this configuration option must be set for this to work: enable-aggregate-command-set).

Archive my imap folders : From the folder view, type e (for export) then select a local location and the whole folder will be copied locally (this does not affect the original).

Collect email from a Microsoft Exchange Server in Cygwin Pine : modify this line: inbox-path={EXCHANGESERVERNAME}inbox

Mark an email as New, Deleted, Answered, or Important : Type * followed by the appropriate letter (note that this configuration option must be set for this to work: enable-flag-cmd).

For roles, hide the X-X-Sender header that states the primary email address (for privacy reasons) : Main, Setup, Config and set both these features: disable-sender and scramble-message-id.

Save my password : (note, this requires that Alpine was compiled with the password option set (./configure --with-local-password-cache-method --with-passfile=.alpinepwd), then you would create an empty file called .alpinepwd (by doing something like touch .alpinepwd followed by chmod 600 .alpinepwd. The next time you type your password to receive or send email, Alpine will ask you if you want to save it; answering y will save it (encrypted) to .alpinepwd.

Get my local mail sent to my imap inbox : add the #move directive to the inbox-path line in your .pinerc file, for example: inbox-path=#move /var/spool/mail/roq--man {imap.MyISPSMTPServerNAme.com/novalidate-cert/user=roq--man@somewhere.edu}INBOX

VPN Mail

Collecting and sending mail with an MS Exchange server, a VPN, fetchmail and Alpine

Setting up a VPN is documented here.

I created seperate .fetchmailrc and .pinerc configuration files, for this example, I'll call them .fetchmailrc.work and .pinerc.work

Modifications for .pinerc.work:

# Over-rides your full name from Unix password file. Required for PC-Pine.
personal-name=My Full Name
 
# List of SMTP servers for sending mail. If blank: Unix Pine uses sendmail.
smtp-server=ExchangeServerIPAddress
 
# Patterns and their actions are stored here.
patterns-roles=LIT:pattern="/NICK=work/FLDTYPE=ANY" action="/ROLE=1/FROM=
My Full Name /RTYPE=NC/FTYPE=NC/CTYPE=NC"
 
# Over-rides default path for signature file. Default is ~/.signature
signature-file=.sig.work
    

Modifications for .fetchmailrc.work:

set postmaster "roqetman"
set bouncemail
set properties ""
poll ExchangeServerIPAddress with proto POP3
       user 'MyWorkLogin' there with password 'MyWorkPassword' is roqetman here
options stripcr warnings 3600
 mda '/usr/bin/procmail -d %T'
    antispam 571 550 501 554
    

Method (you can put part of this this in a script):

sudo /etc/rc.d/vpnclient_init start
vpnclient connect clientname
ctrl-z
bg
cp .fetchmailrc .fetchmailrc.home
cp .fetchmailrc.work .fetchmailrc
fetchmail -k
cp .fetchmailrc.home .fetchmailrc
pine -p .pinerc.work
vpnclient disconnect
sudo /etc/rc.d/vpnclient_init stop
    

Alpine and Gmail

As Gmail offers POP and SMTP access, I sometimes like to collect and send email using their services. I wrote a document detailing the collection of POP Gmail using fetchmail here. You can simply create a new role to send via gmail (see above .pinerc configuration), or you can create a whole new .pinerc file like this:

The seperate .pinerc configuration file I created for this example is called .pinerc.gmail

Modifications for .pinerc.gmail:

# List of SMTP servers for sending mail. If blank: Unix Alpine uses sendmail.
smtp-server=smtp.gmail.com/user=MyUsername@gmail.com/ssl/novalidate-cert
 
# Patterns and their actions are stored here.
patterns=LIT:pattern="/NICK=gmail/FLDTYPE=ANY" action="/ROLE=1/FROM=
My Name /RTYPE=NC/FTYPE=NC/CTYPE=NC"
 
# Over-rides default path for signature file. Default is ~/.signature
signature-file=.sig.gmail
    

To run pine using this configuration file use: pine -p .pinerc.gmail

Here's an addendum...

Gmail now offers the ability to send email as another address, so you can use it as your home smtp server if you like.

Under the "settings" tab in Gmail select the "Accounts" tab. Click on "Add another email address" in the "Send mail as:" section. Enter your name in the "Name:" field, and the email address you'd like to send messages from in the "Email address:" field. Click on "Next Step" and then click "Send Verification" to complete the process. Gmail will send a verification message to your other email address to confirm that you'd like to add it to your Gmail account.

Then, leaving the rest of your .pinerc.gmail file as is, modify this section:

# Patterns and their actions are stored here.
patterns=LIT:pattern="/NICK=gmail/FLDTYPE=ANY" action="/ROLE=1/FROM=
My Name /RTYPE=NC/FTYPE=NC/CTYPE=NC"
    

There you go, now you can send email via Alpine and Gmail and have it seem like it came from the email address of your choice.

When using Alpine with Gmail - How to get "delete" to move mail to the Trash folder

I originally got the info for this from here

  • In Gmail:

    1. Under settings, Labs, enable "Advanced IMAP Controls"

    2. Under settings, Forwarding and POP/IMAP, enable IMAP (if you haven't already), set Auto-Expunge to "Do not automatically expunge messages" and set "When a message is expunged from the last visible IMAP folder" to Move the message to the Trash.

    3. Next, you need to make the "All Mail" label invisible to Alpine (it will still be visible in the Gmail interface). To do this, go to settings, Labels, and uncheck the checkbox for "All Mail".

    That's it. Now when you delete an email in Alpine, it will be moved to the Gmail Trash folder.

    Alpine and MS Attachments

    An easy way to read MS Word and Excel attachments is to install catdoc and xls2csv then create a file called .mailcap in your home directory and paste the following into this file:

    application/msword;catdoc %s |less;needsterminal
    application/VND.MS-EXCEL;xls2csv %s |less;needsterminal
        

    Now when you get an email with an MS Word or Excel attachment, you can "view" it, and you'll see the text of the attachment. There are more mailcap examples here.

    Running Alpine on a USB key on Windows and Linux

    A while back, my server crashed due to a power-supply failure. While I waited for a replacement I decided to see if I could temporarily migrate my mail onto a USB key and access it both from work (on Windows XP) and home (on Ubuntu Linux). It was actually very easy to set up.

    I had 2 criterias:

  • It had to run on both platforms.

  • It had to be secure.

    Here are the steps to take to do this...

    Download and install TrueCrypt on both Windows and Linux as TrueCrypt's documentation suggests.

    Install PC-Alpine on Windows and Alpine on Linux (they can be uninstalled after the binary copies in the next few step if you want).

    Create a TrueCrypt volume on the USB key and mount it on Windows.

    Copy the files from C:\Program Files\Alpine into the TrueCrypt mounted volume.

    Create a shortcut or a .bat file in the mounted volume that will run Alpine with a specific configuration file, for example:

    M:\alpine.exe -p pinerc_windows

    Unmount the volume in Windows and mount it in Linux.

    Copy the 2 binaries alpine and pico from their installed location (type which alpine to find where that is) into the TrueCrypt mounted volume.

    Create a batch file in in the mounted volume that will run Alpine with a specific configuration file, for example:

    ./alpine -p pinerc_linux

    The reason that there are 2 configuration files is that the paths to the mail are slightly different. Here were my only differences:

  • Windows (I always use M: as my mounted volume in Windows):

    default-fcc=sent-mail
    default-saved-msg-folder=saved-messages
    folder-collections=Mail M:\mail\[],
    address-book=.addressbook
        

  • Linux:

    folder-collections=Mail /media/truecrypt1/mail/[],
        

    You may want to adjust a few other settings (these were the only modifications I made to my .pinerc file that I had copied from my Linux server), but this worked fine for me until I got my server replaced (I decided to go for a plug-computer, but that's a story for another time).

    Links

    Helpful links for those interested in using Alpine...

    alpine's new home : http://sourceforge.net/projects/re-alpine/

    alpine's original home : http://www.washington.edu/alpine/

    Changing Your From Header in Pine : http://www.best.com/~ii/internet/messaging/pine/changing_from/#gory

    Power Pine : http://ii.best.vwh.net/internet/messaging/pine/pc/

    information condensed from the newsgroup comp.mail.pine : http://www.zrox.net/Mail/Pine/pip.txt

    The Pine Usenet Newsgroup : (now seldom used, but the archives are still useful) comp.mail.pine (you can ask Alpine questions here too).

  • © Roqet 2018 :: 2018-05-11 17:07:10