alpine-screenshot
alpine-iphone

另, 文末有我的Example, 可直接拿来快速上手.

谁在用

Marissa Mayer是这样用的:

March 8, 2006

Marissa Mayer prefers Pine to Gmail

[mayer]Marissa Mayer, VP, Search Products and User Experience at Google confesses to CNN Money that she doesn’t use Gmail for her business mail.

“I don’t feel overwhelmed with information. I really like it. I use Gmail for my personal e-mail – 15 to 20 e-mails a day – but on my work e-mail I get as many as 700 to 800 a day, so I need something really fast. I use an e-mail application called Pine, a Linux-based utility I started using in college. It’s a very simple text-based mailer in a crunchy little terminal window with Courier fonts. I do marathon e-mail catch-up sessions, sometimes on a Saturday or Sunday. I’ll just sit down and do e-mail for ten to 14 hours straight.” Pine is a mail program developed at the University of Washington. It has a lot of keyboard shortcuts and countless ways to sort, shuffle, and sift through your email.

Linus Torvalds:
From: Linus Torvalds <torvalds@linux-foundation.org>
Newsgroups: fa.linux.kernel
Subject: Re: [git pull][resend] Input updates for 2.6.22-rc7
Date: Fri, 06 Jul 2007 01:11:27 UTC
Message-ID: <fa.IgmANxZoEvqGUWkoZEe414vIYlQ@ifi.uio.no>

On Fri, 6 Jul 2007, Jesper Juhl wrote:
>
> > I'm constantly surprised by just how _many_ ways MUA's find to screw up.
>
> 'pine' actually seems to work pretty damn well once you disable the
> flowed-text "feature".

Yes. And 'alpine', it's modern version, does even better, but you also
need to make sure to disable "downgrade-multipart-to-text".

I've been using alpine for a while now, and it's nice to see it be utf-8
capable and able to handle other charsets well.

So as a former pine user, I can recommend upgrading.

		Linus
Hacker News 上有人这样评论:

Pine was the defacto email client for so many universities (including mine); these kids today don’t know what they were missing! It was a rare window of human Time On Earth where every single person at my massive nearly 100K-size college used Control-X to send every email.

优点

  • 历史悠久, 从Unix时代就一直在广泛使用, GNU/Nano 即是从 alpine 的前身 pine 中的默认编辑器 pico 派生的
  • 不折腾, 开箱即用, 调一下喜欢的配色即可
  • 所有配置都在一个 TUI 界面里集中配置
  • 不可定制快捷键, 但快捷键久经考验, 越用感觉越科学, 适合快捷键选择恐惧症的人使用
  • 对 IMAP 的支持比较科学
  • 与 BBS 的操作非常相似
  • 原生支持 S/MIME
  • 原生支持 LDAP 通讯录, 并支持 .addressbook 形式的本地通讯录, 且可以将其存储于远程 IMAP 目录内
  • 配置文件可以写入远程 IMAP 文件夹, 从而实现配置漫游
  • alpine 内部可以改 /etc/passwd 里的密码. 可以在 Server 上开设默认 Shell 为 alpine 的账户, 专门用于查收邮件
  • 支持锁屏, 特别适合开在 VPS 的 Tmux/Screen 上

不足

  • 不可定制快捷键, 例如不支持j,k上下 ( 但是体验一下互联网远古时代的习惯也挺好 ._. )
  • 原生不支持 GPG/OpenPGP, 但是可以通过 topal 软件支持
  • 默认不识别 GB18030 编码(但默认支持GBK和GB2312), 接收来自 QQ 邮箱的邮件可能会不识别. 但是我已经向上游提交了一个比较省事偷懒的Patch, 维护者正在进行修复
  • 不支持 LDAPs (636端口, SSL) 已经被我修好了, 见Patch
  • 不支持通过外部 IMAP 同步工具如 offlineimap 或 mbsync , 但貌似有人可以实现, 目前我没有跟进此事 已经支持Maildir, 见Maildir PatchExample
  • 部分由 Outlook 网页版邮箱发出的邮件以QP编码(一堆等号的那种), 中文识别起来貌似有问题

上手

由于其它的教程都已经年久失修, 而且University of Washington已经不维护alpine了.
目前项目是由 Eduardo Chappa chappa@gmx.com 个人在维护.
网址是http://alpine.freeiz.com/alpine/release/, 而且上面有不少教程.

在主界面依次按下 M S C 进入配置界面,

 imap.gmail.com:993/ssl/user=example@gmail.com

 smtp.gmail.com:587/tls/user=example@gmail.com

设置默认发送者: (否则它可能会尝试以你的 Linux 用户名@邮箱域名来尝试发送)

 Customized Headers = From: 那谁 <example@gmail.com>

完!

仍然不开心的话, 可以调整一下配色: 依次按下 M S K.

新闻组

参考 http://www.washington.edu/pine/faq/news.html

M S C 添加 NNTP 服务器为: news.gmane.org

然后到 L 里, 在 News Collection 里按 A, 添加订阅

如:

  • gmane.announce
  • gmane.linux

可以在配置里, 指定一下最大拉取的新闻数量, 免得过多崩掉

NNTP Range                        = 2000

Tips

  • 在任意输入框内按下 Ctrl + G 可以查看帮助, 帮助在手, 天下我有.
  • S 键: 存储并从原邮箱删除邮件
  • 搜索: W
  • Ctrl + L 刷新屏幕, 同时会检查收件箱
  • A 键: 切换 HTML/PlainText 显示
  • 多选: 按冒号 : 键, 然后按 A (Apply) 键应用
  • ; 键可以按条件选择, 然后再按 A 来做操作
  • 颜色配置中HEADER COLORS里按 A 键, 可以加入如From Cc等字段进行颜色配置
  • 空格键下翻, 减号 - 上翻
  • < 键退回到上一级, 但发现不按 Shift 键效果一样
  • 显示新邮件数量: 把以下三个都勾上 Enable Incoming Folders Collection Enable Incoming Folders Checking Incoming Checking Includes Total, 然后在 List 中把想要看的目录按 A 键加进来.
  • 用搜索引擎搜索问题的时候, alpine的结果可能会比较少, 可以用pine做为关键词
  • 可以使用外部的编辑器如 vim, 按 Ctrl + _ 来切换成外部编辑器. ( 不按 Shift 键也可以)
  • | 键可以把邮件的内容 pipe 到另一个程序
  • 可以结合终端 ASCII 看图软件 cacaview (位于 caca-utils 包里), 来预览邮件附件的照片. 可以把你的终端字符使劲缩小, 从而达到提高分辨率的效果
  • Inbox Zero 原则: 养成定时清空 Inbox 的好习惯
  • 觉得提示声音吵, 可以[X] Suppress Status Message Beeping
  • 要设置一下alternate address, 在里面添加自己的邮箱地址(如scateu@example.com), 这样一方面会使+标记生效, 另一方面, Reply to all的时候就不会在Cc里面有自己了.
  • 转发HTML格式的邮件时, 如果想保留格式, 可以先按V, 显示附件, 在HTML的附件上按F来进行转发.

更多的 Tips , 可以参考 http://alpine.freeiz.com/alpine/alpine-info/tips/index.html

我当前的一些小调整

default-fcc={imap.gmail.com:993/ssl/user=example@gmail.com}Sent
feature-list=enable-background-sending,
       enable-delivery-status-notification,
       convert-dates-to-localtime,
       compose-cancel-confirm-uses-yes,
       no-enable-alternate-editor-implicitly,
       enable-8bit-esmtp-negotiation,
       combined-folder-display,
       expanded-view-of-folders,
       vertical-folder-list,
       prefer-plain-text,
       combined-subdirectory-display,
       no-try-alternative-authentication-driver-first,
       enable-lame-list-mode,
       no-quell-imap-envelope-update,
       no-expose-hidden-config,
       no-enable-verbose-smtp-posting,
       quell-user-lookup-in-passwd-file,
       allow-changing-from,
       single-column-folder-list,
       quell-empty-directories,
       incoming-checking-includes-total,
       enable-incoming-folders-checking,
       enable-incoming-folders,
       no-incoming-checking-uses-recent

customized-hdrs=From: Your Name <example@gmail.com>

editor=vim

disable-these-authenticators=EXTERNAL #阿里云邮专用
color-style=force-xterm-256color

小Bug们

阿里云邮的 IMAP 认证问题

已知阿里云邮的 IMAP 服务器的CAPABILITY输出有问题, 导致 alpine 去尝试使用 AUTHENTICATE EXTERNAL 认证方式, 从而失败.

对策

调出 alpine 的隐藏配置[X] Expose Hidden Config, 把EXTERNAL加到禁用列表里.

 # List of SASL authenticators to disable.
 disable-these-authenticators=EXTERNAL

我当时用于调试的主要命令有:

 $ openssl s_client -connect imap.gmail.com:993 -crlf
  0 CAPABILITY
  1 LOGIN

 $ alpine -d4
 $ less ~/.pine-debug
阿里云邮的 SMTP 问题

发送时出现:

 >Mail not sent. Sending error: 440 mail from account doesn't conform with authentication (Auth Account:<

调试过程:

 $ alpine -d4
 $ cat .pine-debug1

发现MAIL FROM字段有问题:

 IMAP DEBUG 03:14:17 8/22: MAIL FROM:<scateu@alibaba-inc.com> BODY=8BITMIME
 IMAP DEBUG 03:14:17 8/22: 440 mail from account doesn't conform with authentication (Auth Account:wangkang.wk@alibaba-inc.com|M

对策

于是手动加上

Customized Headers                = From: 王康(五达) <wangkang.wk@alibaba-inc.com>
阿里云邮 Save 邮件的时候会把下一封删除掉

Save 的时候经常会出现一个D, 然后很可怕的把下一封邮件也删除了. 疑似是Bug

对策

[X]  Save Will Not Delete                                                  
Gmail 无法 Undelete

https://productforums.google.com/forum/#!topic/gmail/EX3FKvJFu1w

Deleting from IMAP for Gmail is like archiving. Email disappear from Inbox and goes to All Mail folder. Mail is not really deleted.  So Alphine will not find email in Trash folder to undelete.


If you want deleted mail to go to IMAP Trash folder, Go to Gmail webmail Settings.
In Labs tab, turn on Advanced IMAP controls.
In IMAP settings for Auto-Expunge, set to "Do not automatically expunge messages"
In Labels tab, hide the All Mail folder in IMAP).

Then you can do a delete and mail will go to Trash folder.
QQ邮箱

1. QQ邮箱不支持RLIST指令

参考这篇讨论

IMAP DEBUG 23:46:01 4/5: 00000007 RLIST "" %
IMAP DEBUG 23:46:03 4/5: 00000007 BAD ÃüÁîÎÞЧ»òÕß²»Ö§³Ö

于是, 要在Disable These Authenticators里面, 加上对LOGIN的禁用 这样才能在LIST里面看到所有目录

但是! 这样SMTP的时候, 会提示无法进行Authentication…. shit

2. QQ需要装手机安全中心

需要新建一个应用程序密码登录

打印

Mac OS X: M S Plpr, 然后按%打印即可.

可以把配置改为以下这样, 加上边距:

printer=lpr-a4 [] lpr -o media=A4 -o page-left=36 -o page-right=36 -o page-top=36 -o page-bottom=36
personal-print-command=lpr-a4 [] lpr -o media=A4 -o page-left=36 -o page-right=36 -o page-top=36 -o page-bottom=36

iOS 上使用

文章开头的照片, 是在iPhone上ssh到自己的服务器使用alpine.

键盘的搜索关键字”iPhone 侧滑 蓝牙 键盘”, 大约90块钱.

Terminal我对比了一下: (iOS)

  • Prompt 收费, 漂亮, 开发活跃度高, 但中文支持有点问题
  • vssh 收费, 中文支持没问题, 基于Putty的代码, 开发活跃度低
  • serverauditor 免费, 中文支持貌似有问题

所以我现在iPhone上买了Prompt和vssh

另外, 以上均不支持mosh.mit.edu提供的mosh.

据说Prompt正在支持mosh, 但是由于mosh是GPL的, 而Prompt不想开源

而安卓上有客户端支持, 这对于在地铁上信号经常断很有用

不过服务器上的alpine是跑在tmux里的, 断了再连一下也还能忍

在地铁上试了一下, 一个大妹子见状对她男朋友大喊一声:”快看啊有码农在地铁上写代码啊! “

还是挺不错的.

Patch及示例

我的一些Patch以及Example见: https://github.com/scateu/alpine-patches

另外, 为Mac OS X提供了集成上述3个Patch的Homebrew文件. 暂时先这样用好了, 等上游版本稳定了, 争取把上游的brew formula改掉.

或者直接这样子: (2017-03-20 更新: 换行和LDAPS两个Patch已经集成到上游的2.21里)

$ brew install https://github.com/scateu/alpine-patches/raw/master/brew/alpine.rb  --with-maildir-patch --with-gb18030-patch

示例配置: (自行把里面的TODO字样改掉)

Debian中导入Patch的方法

$ sudo apt-get build-dep alpine
$ apt-get source alpine
$ cd alpine-2.10+dfsg
$ patch -p1 < 0001-Add-a-require-ldapssl-on-connection-switch-to
-suppor.patch

同理把其它两个导入,待Patch成功之后:

$ dpkg-buildpackage -us -uc

会生成对应的.deb包
最后

$ cd ..
$ sudo dpkg -i alpine_2.10+dfsg-1_amd64.deb

Windows 版本

https://github.com/scateu/alpine-patches/releases

在Windows上的编译指南可以参考我的另一篇指南.

附: Pine发布时的邮件

PINE ELECTRONIC MAIL
It's somewhat out of the bag, but just to make it official...

Cheers!

Michael Seibel
Networks and Distributed Computing              mi...@cac.washington.edu
University of Washington, Seattle               (206) 543 - 0359

-------------------------


                         PINE ELECTRONIC MAIL

BACKGROUND

Pine is a mailer developed by the University of Washington Office of
Computing and Communications. It has been designed for ease-of-use and
with the novice computer user in mind. It is based on Internet mail
protocols (e.g. RFC-822, SMTP, IMAP, and MIME) and currently runs on a
variety of UNIX platforms.

The guiding principles for achieving ease-of-use in Pine were: careful
limitation of features, one-character mnemonic commands, always-present
command menus, immediate user feedback, and high tolerance for user
mistakes. It is intended that Pine can be learned by exploration rather
than reading manuals.  Feedback from the University of Washington
community and a growing number of Internet sites has been encouraging.

A stand-alone version of Pico, Pine's message composition editor, is also
available. It is a very simple and easy to use text editor with text
justification and a spelling checker.


FEATURES

   - Mail index showing a message summary which includes the status,
     sender, size, date and subject of messages.

   - View and process mail with the following commands:  forward, reply,
     save, export, print, delete, capture address and search.

   - Address book for saving long complex addresses and personal
     distribution lists under a nickname.

   - Multiple folders and folder management screen for filing messages.

   - Message composer with easy-to-use editor and spelling checker.
     The message composer also assists entering and formatting
     addresses and provides direct access to the address book.

   - Online help specific to each screen and context.

   - Supports access to remote mail repositories via the IMAP2 protocol
     defined in RFC-1176.

NEAR-TERM PLANS

   - Integral SMTP support for easy installation on Unix workstations.
     (This is desirable when Pine is used as an IMAP client of a shared
     mail server, since it obviates the need for installing and configuring
     sendmail on each workstation.)

   - Support for multi-part mail conforming to proposed MIME Internet
     standard, allowing sending of sounds, graphics such as GIF and
     TIFF files, and binary files such as spreadsheets.

   - Permit a user-specified editor for message composition.

   - Port Pine to MS-DOS  (Stanford's Mailstrom is recommended for Macs.)

AVAILABILITY

Pine and Pico, including source code, are freely available via anonymous
FTP from ftp.cac.washington.edu on the Internet. Other provisions for
distribution have not been made. From the Internet, you may try out Pine
and leave comments by telneting to "demo.cac.washington.edu" and logging
in as "pinedemo". To join the Pine mailing list for announcements send a
request to "pine-inf...@cac.washington.edu".

Pine is very portable and runs on a variety of UNIX machines including
DECstations, NeXTs, VAX's and Suns. Pine was originally based on Elm,
but it has evolved much since, ("Pine Is No-longer Elm").

For further information send e-mail to pi...@cac.washington.edu. Pine is
the work of Mike Seibel, Mark Crispin, and Laurence Lundblade at the
University of Washington.

92.3.24

参考链接

HTML渲染

使用w3m来阅读带有表格的HTML内容: 见邮件列表
- |先pipe到w3m -T text/html , 再加上Ctrl-Y的Free Output模式

或者在.mailcap里写上:

text/html; w3m -T text/html '%s'; needsterminal

然后遇到HTML渲染问题, 就按V显示附件, 在HTML的附件上回车, 这样比较直接.

缺点

  • 这样会导致邮件里面自己的URL, 也会被强制用w3m来打开, 原来是可以用firefox打开的. 即使设置了URL-viewers也不行.
    • 其实你本来不写这个mailcap, HTML附件用Firefox打开也行, 只不过中文有问题. 而且你也没机会改编码, 因为邮件的HTML文件是被临时放到了/tmp/里面, 打开Firefox的瞬间就被删除了. 只能先export
      • 貌似在Firefox里, 把Text-encoding Auto-detect设置成Japanese就好了
  • 按q退出w3m之后, 还需要按回车(再等一小会)或Ctrl-C快速退回来

好处

  • w3m是可以显示图片哒!

Contribution

Version 2.21 includes several new features and bug fixes.

  • Unix-Alpine: Connect securely to a LDAP server on a secure port. Based on a contribution by Wang Kang.
  • HTML messages that contain UTF-8 may wrap at the wrong position, making Alpine not display the correct character at the position that wrapping is done. Reported by Wang Kang.

Android

经过努力和一些PatchTermux上已经收录了了Alpine。