Mutt

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Mutt and the translation is 69% complete.

mutt は テキストベースの、コマンドライン上で動作するメールユーザエージェント (MUA) です。mutt は現在も通用し、コンソールベースで、いまだに活発な開発下にあり、多くの活発な支援者 (とユーザ) がいるメールクライアントのひとつです。強力で、高度なカスタマイズが可能で、小さくまとまっており、かつ効率的です。

neomutt は mutt のフォークで、非常に似ており、この記事の大部分はそちらにも適用可能です。

はじめに

Mutt は元来ローカルの mbox メールスプール (例: /var/spool/mail/) からメールを読むためのものとして設計されましたが、今は Maildir 形式のフォルダ、POP3 サーバからのリモート取得、そして IMAP アカウントの完全な管理にフル対応しています。Mutt でできることの完全な説明については、Mutt のマニュアルをお読みください。

インストール

Starting your Mutt adventure simply requires you to emerge it. Unfortunately, Mutt has a lots of options, which enable or disable certain functionalities of Mutt. We now briefly discuss the most important USE flags that you may want to enable based on your intended usage of Mutt. Please note that enabling most of them won't harm your Mutt, but may make it do more than an experienced Mutt user would like.

Emerge

root #emerge --ask --verbose mail-client/mutt

USE フラグ

USE flags for mail-client/mutt A small but very powerful text-based mail client

+hcache Enable header cache, one database backend needs to be enabled
+imap Add support for IMAP (Internet Mail Application Protocol)
+lmdb Enable dev-db/lmdb database backend for header caching
+sasl Add support for the Simple Authentication and Security Layer
+smtp Enable support for direct SMTP delivery
+ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
autocrypt Enable autocrypt.org support
berkdb Enable sys-libs/db database backend for header caching
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gdbm Enable sys-libs/gdbm database backend for header caching
gnutls Prefer net-libs/gnutls as SSL/TLS provider (ineffective with USE=-ssl)
gpgme Build gpgme backend to support S/MIME, PGP/MIME and traditional/inline PGP
gsasl Use GNU SASL via virtual/gsasl instead of Cyrus SASL (requires USE=sasl)
idn Enable support for Internationalized Domain Names
kerberos Add kerberos support
mbox Add support for mbox (/var/spool/mail) style mail spools
nls Add Native Language Support (using gettext - GNU locale utilities)
pgp-classic Build classic_pgp backend to support PGP/MIME and traditional/inline PGP
pop Enable support for POP3 mailboxes
prefix Defines if a Gentoo Prefix offset installation is used
qdbm Add support for the qdbm (Quick Database Manager) library
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
slang Add support for the slang text display library (it's like ncurses, but different)
smime-classic Build classic_smime backend to support S/MIME
tokyocabinet Enable dev-db/tokyocabinet database backend for header caching
vanilla Do not add extra patches which change default behaviour; DO NOT USE THIS ON A GLOBAL SCALE as the severity of the meaning changes drastically

IMAP

imap USE フラグはおそらく Mutt で有効化すべき最重要機能でしょう。これを有効化するのには利点しかありません。IMAP は、複数のクライアントから同時に異なる場所からでもアクセスできるように e メールを保管するための最も便利な方法なので、多くの e メールプロバイダは、Gmail 等のフリーメールでさえも、IMAP を使用しています。IMAP はすべてのメールをサーバに保持するので、Mutt は見たいメッセージをただダウンロードするだけです。

ヘッダキャッシュバックエンド

メッセージを読むのと並んで、メールボックスに何があるのかを確認するために、一覧表示するのもよく行われるでしょう。この情報のために、Mutt はメッセージヘッダをダウンロードする必要があります。フォルダを頻繁に切り換えたり、フォルダが大量の e メールを含んでいる場合、メッセージヘッダを何度も何度もダウンロードするのは時間がかかります。これは単純に無駄なので、Mutt はメッセージの最重要部分を保持するいわゆるヘッダキャッシュ (USE フラグ hcache) を使用して、フォルダを開く時間を大幅に短縮します。このヘッダキャッシュは db ライブラリによって支えられていて、db ライブラリには 5 種類が存在します: berkdbgdbmlmdbqdbm、そして tokyocabinet です。特にこだわりが無いなら、Mutt と使うと最速な lmdb を選んでください。hcache バックエンドのための db ライブラリ USE フラグは最大 1 つまでしか有効化できません。後で異なる db ライブラリとともに Mutt を再 emerge すれば、Mutt はフォルダを開いたときにキャッシュを自動的に再ビルドします。

メールの送信

IMAP はメールを読むのに重要な一方で、メールを送信するのにはメールサーバが必要です。Mutt はローカルの (send)mail 送信を使ってメールを配信することができますが、多くの場合、移動するユーザ (例: ラップトップユーザ) にとっては良い解決策ではありません。Mutt には、smtp USE フラグによる SMTP サポートを備えていて、これはデフォルトで有効化されています。Mutt の SMTP サポートを利用することで、選択したメールサーバを介して、必要ならアカウントを認証したうえで、メールを送信することができます。通常は、これは e メールプロバイダから与えられた SMTP サーバです。

セキュアなプロトコル

IMAP と SMTP プロトコルはいずれも、暗号化された通信路を通してデータを送信します。imapsmtp の一方または両方の USE フラグを有効化する場合は、ssl または gnutls USE フラグを有効化するのがよいでしょう。それぞれ OpenSSL または GNUTLS の実装を利用して、セキュアな変種 (imaps および smtps) を Mutt の対応プロトコルリストに追加します。ほとんどの読者は OpenSSL と GNUTLS の選択に特にこだわりはないでしょうから、ssl で進めてください。こちらはおそらくすでにシステムのグローバル USE フラグリストに含まれているでしょう。e メールを送信するときに認証するつもりであれば、sasl USE フラグも含めておいてください。sasl USE フラグは e メール送信時の認証のために必要です。

暗号化

Even with secure IMAPS and SMTPS protocols, it is best practice to sign and/or encrypt email messages. Mutt supports traditional OpenPGP and S/MIME. Both of these are supported using the gpgme wrapper. The easiest way to setup support for signed and encrypted messages is using the gpgme USE flag. Documentation and experiences in this area can be confusing to say the least. When enabling gpgme USE flag, ensure the backend has been properly setup in the configuration (see below).

設定

After you emerge Mutt with some choice USE flags, the only necessary next step is to create a .muttrc file. muttrc's are to be found in many places on the web and in Mutt's documentation. In /usr/share/doc/mutt-<version>/samples some muttrc samples from the official distribution can be found. A very minimal .muttrc for an IMAP based account with SMTP mail delivery is shown below. It also enables signing emails via gpg using the gpgme backend.

ファイル

.muttrc

ファイル ~/.muttrcA .muttrc example file
# character set on sent messages
set send_charset="utf-8"
# if there is no character set given on incoming messages, it is probably windows
set assumed_charset="iso-8859-1"
  
# make sure Vim knows Mutt is a mail client and that a UTF-8 encoded message will be composed
set editor="vim -c 'set syntax=mail ft=mail enc=utf-8'"
  
# just scroll one line instead of full page
set menu_scroll=yes
  
# we want to see some MIME types inline, see below this code listing for explanation
auto_view application/msword
auto_view application/pdf
  
# make default search pattern to search in To, Cc and Subject
set simple_search="~f %s | ~C %s | ~s %s"
  
# threading preferences, sort by threads
set sort=threads
set strict_threads=yes
  
# show spam score (from SpamAssassin only) when reading a message
spam "X-Spam-Score: ([0-9\\.]+).*" "SA: %1"
set pager_format = " %C - %[%H:%M] %.20v, %s%* %?H? [%H] ?"
  
# do not show all headers, just a few
ignore          *
unignore        From To Cc Bcc Date Subject
# and in this order
unhdr_order     *
hdr_order       From: To: Cc: Bcc: Date: Subject:
  
# brighten up stuff with colors, for more coloring examples see:
# http://aperiodic.net/phil/configs/mutt/colors
color normal      white          black
color hdrdefault  green          default
color quoted      green          default
color quoted1     yellow         default
color quoted2     red            default
color signature   cyan           default
color indicator   brightyellow   red
color error       brightred      default
color status      brightwhite    blue
color tree        brightmagenta  black
color tilde       blue           default
color attachment  brightyellow   default
color markers     brightred      default
color message     white          black
color search      brightwhite    magenta
color bold        brightyellow   default
# if you don't like the black progress bar at the bottom of the screen,
# comment out the following line
color progress    white          black
  
# personality settings
set realname = "Larry the cow"
set from = "larry@mail.server"
alternates "larry@mail.server|larry.the.cow@mail.server"
# this file must exist, and contains your signature, comment it out if
# you don't want a signature to be used
set signature = ~/.signature
  
# aliases (sort of address book)
source ~/.aliases
  
# IMAP connection settings
set mail_check=60
set imap_keepalive=300
  
# IMAP account settings
set folder=imaps://larry@imap.mail.server/
set spoolfile=imaps://larry@imap.mail.server/
set record=imaps://larry@imap.mail.server/Sent
set postponed=imaps://larry@imap.mail.server/Drafts
  
# use headercache for IMAP (make sure this is a directory for better performance!)
set header_cache=/var/tmp/.mutt
 
# uncomment this to enable the sidebar feature
#set sidebar_visible = yes
set sidebar_width = 15
set sidebar_folder_indent = yes
set sidebar_short_path = yes
 
# make the progress updates not that expensive, this will update the bar every 300ms
set read_inc = 1
set time_inc = 300
 
# only if you compiled Mutt with USE=gpgme, enable the gpgme backend
set crypt_use_gpgme = yes
# you can set this to hide gpg's verification output and only rely on Mutt's status flag
#set crypt_display_signature = no
# enable signing of emails by default
set pgp_autosign = yes
set pgp_sign_as = 0xXXXXXXXX   # your gpg keyid here
set pgp_replyencrypt = yes
 
# mailboxes we want to monitor for new mail
mailboxes "="
mailboxes "=Lists"
  
# mailing lists for a Gentoo user (these are regexps!)
subscribe "gentoo-.*@gentoo\\.org"
  
# SMTP mailing configuration (for sending mail)
set smtp_url=smtp://larry@mail.server/
メモ
It is a good practice to review all of the settings from the example configuration file above. There are many more configuration options, and some preferences may not be to your liking. Keep this in mind if Mutt doesn't function exactly the way you like when you are first setting it up.

The example .muttrc above sets up an IMAP account, uses an SMTP server to send mail, stores its cache in /var/tmp/.mutt, reads the known address aliases (think of it as an address book) from ~/.aliases and appends the signature from ~/.signature when composing new mail. For some IMAP servers it may be necessary to change the spool, record and postponed directories, as the folders Sent and Drafts may be under a folder called INBOX. Simply trying this out with Mutt is the simplest way to figure this out.

Once the .muttrc is setup, you are ready to launch Mutt by just running mutt. If you entered a valid IMAP server URL, Mutt will prompt for a password and afterwards load all messages. Note that the first time entering your mailbox may take a while if you have quite some messages, since Mutt's header cache is still empty. If this succeeds you're in your IMAP mailbox ready to go.

Navigation is intuitive, as is reading messages by just pressing the Enter key or Space bar. Mutt is quite Vim alike in that it uses key strokes to perform most of its actions. You best read Mutt's manual to become familiar with all existing functions (or press ? in Mutt) and what key they are bound to, or better, what key you like it to be bound to. Some essential keys are m (for message) to start composing a new message, q for quit, r for reply, s for save and p for print.

.mailcap

One of the features that Mutt has that is still not in today's most savvy email clients is the ability to display attachments inline through some viewer. The auto_view directive in the .muttrc file tells Mutt which attachments (based on their MIME-type) it should view inline. To figure out how to do that, Mutt uses mailcap files to lookup how to display a certain MIME-type. Usually the system wide mailcap file isn't sufficient here, so you better start a ~/.mailcap file to put items in there for copiousoutput that Mutt can display inline.

In the example .muttrc above auto_view is enabled for application/msword and application/pdf files. These two show the extreme usefulness of this capability, because it means meeting notes sent as doc file now are perfectly fine readable without having to save the attachment and open it in LibreOffice. Instead the text just shows up in the message reader, that is, if you have a matching entry in your ~/.mailcap file.

ファイル ~/.mailcap.mailcap ファイルの例
application/msword; antiword '%s'; copiousoutput; description=Word Document;
nametemplate=%s.doc
application/pdf; pdftotext '%s' -; copiousoutput; description=PDF Document;
nametemplate=%s.pdf

The above .mailcap example tells Mutt what to do to "view" msword and pdf files. For the former it should run a program called antiword, for the latter the program pdftotext (emerge app-text/poppler). You can go wild with these to for example display rendered HTML (give app-text/vilistextum a try), render vcards, or show ASCII representation of attached images. All you need to do is define how to call the program in your .mailcap, and tell Mutt to try to view it inline using the auto_view directive.

おわりに

Mutt is a very versatile console email client. If you like the concept, Mutt can be altered to behave in nearly any way through its configuration. Search the web to find others explaining how they did "it", or find one of the many patches that exist to make Mutt do even more. Gentoo applies a couple of very popular patches to Mutt, so make sure to check mutt -v if you want something more to make sure it is not yet already at your disposal. While learning Mutt is not necessarily easy, once it is in your fingers, it can make your mail experience much faster and efficient than with other clients. Searching for example is quite powerful if you know how to hit the right flags and know which regular expression narrows your search down. Enjoy Mutting!

関連項目


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Fabian Groffen (grobian)
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.