1 [[!meta date="2009-02-04 13:06:00"]]
3 [Mutt][] is a simple, configurable mail user agent [MUA][]/email
4 client. I got tired of using webmail to check my email, so I got Mutt
5 set up on my computer instead. Mutt is intended to be an email
6 browser, so most versions don't have built in [[SMTP]] support. For a
7 simple setup, you can use an external SMTP client like [msmtp][],
8 which is how we'll do it in the examples below.
13 For Debian-type distros (e.g. Debian, Ubuntu, …), you can install Mutt
16 $ apt-get install mutt msmtp
21 Mutt is a very flexible beast, and in the past I've used some of the
22 more complicated setups described below. However, I eventually broke
23 down and got a domain name, after which it made more sense to setup a
24 local [[Postfix]] server, and have Mutt interact with this local
25 server. I'll keep the IMAP/POP examples below because they might be
26 useful for those of you that don't want to run your own mail server
32 You configure Mutt with the file `~/.muttrc`. To set it up with the
33 Drexel email system, I looked up the server addresses, and created the
37 set imap_user='<your-username>@drexel.edu'
38 set imap_pass='<your-password>'
39 set from='<your-username>@drexel.edu'
40 set use_from=yes # required so msmtp knows which account to use to send mails
42 # setting your realname is optional, but drexel addresses can be cryptic...
43 set realname='<your-realname>'
45 # email server location
46 set spoolfile=imaps://<your-username>@imap.mail.drexel.edu:993/INBOX
47 set folder=imaps://<your-username>@imap.mail.drexel.edu:993/
49 # use msmtp for sending mail
50 set sendmail=/usr/bin/msmtp # Debian-style system path, yours may be different
52 # save copies of sent email to the ${folder}Sent directory
53 # the '+' expands to $folders (like '~' to $HOME in bash)
56 set mail_check=600 # check for new mail every 10 minutes when user is active
57 set timeout=600 # check for new mail every 10 min. when user is not active
59 set editor='/usr/bin/emacs -nw' # use emacs for writing emails
60 set edit_headers # allow editing headers while you're in emacs
62 Since this file contains your password, you should not allow other
67 This still isn't terribly secure, so you could remove the password
68 line entirely, in which case Mutt prompts you for it when it tries to
69 log in (just like webmail does).
71 The `mail_check` and `timeout` settings set up how often Mutt checks
72 for new mail, which I've set to be pretty slow. You can type `$` to
73 sync, whenever you want to send outgoing mail or check for new mail.
75 Googling `.muttrc` should turn up tons of other goodies, or try `man
78 You also have to configure msmtp with a `~/.msmtprc` file:
81 host smtp.mail.drexel.edu
82 from <your-username>@drexel.edu
84 # use STMP authentication
87 password <your-password>
91 tls_trust_file /etc/ssl/certs/ca-certificates.crt
93 To find information on a given SMTP server from the command line, use
95 $ msmtp --host=smtp.some.domain --server-info
97 The same security issues with plain text passwords apply to
98 `.msmtprc`, so `chmod 600` it, or possibly remove your password
104 There's list of basic shortcuts across the top of the Mutt screen.
105 Most importantly, `?:Help`, which will give a list of all the current
106 shortcuts. An excellent tutorial page is [my first mutt][mfm].
108 Multiple IMAP accounts
109 ======================
111 I finally had some time to play around and get Drexel mail and Gmail
112 working at the same time. The basic setup is the same as above, using
113 msmtp to send the mail and Mutt's built in IMAP capability to get it
116 First configure msmtp with:
119 # Mostly from Peter Garrett's examples
120 # https://lists.ubuntu.com/archives/ubuntu-users/2007-September/122698.html
121 # Accounts from Scott Robbins' `A Quick Guide to Mutt'
122 # http://home.nyc.rr.com/computertaijutsu/mutt.html
125 host smtp.mail.drexel.edu
126 from <drexel-from-address>@drexel.edu
128 user <drexel-username>
129 password <drexel-password>
131 tls_trust_file /etc/ssl/certs/ca-certificates.crt
132 #tls_trust_file /etc/pki/tls/cert.pem
136 from <gmail-from-address>@gmail.com
137 user <gmail-from-address>@gmail.com
138 password <gmail password>
142 tls_trust_file /etc/pki/tls/cert.pem
144 account default : drexel
146 This sets msmtp up so it can connect to either mail
147 server. `<drexel-username>` is your username (`abc123`),
148 `<drexel-from-address>` can be the same as `<drexel-username>`, but
149 you can use any address you've set up as an alias.
150 `<gmail-from-address>@gmail.com` is your full gmail email address. The
151 `tls_trust_file` line depends on your distribution. For Gentoo and
152 Debian-based distributions, use the `ca-certificates.crt` line; and
153 for Red Hat-based distributions, use the `cert.pem` line. I don't
154 know where the certificate information is stored for other
155 distributions, but googling about should find it.
161 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com
163 source ~/.mutt/common
164 source ~/.mutt/drexel
166 # from http://wiki.mutt.org/?MuttGuide/UseIMAP
167 # account-hook to set up connection parameters (username, password, etc.)
168 # and folder hook for everything else.
169 account-hook . 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
170 account-hook imaps://<drexel-username>@imap.mail.drexel.edu \
171 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
172 account-hook imaps://<gmail-username>@gmail.com@imap.gmail.com \
173 'set imap_user=<gmail-username>@gmail.com imap_pass="<gmail-password>"'
174 folder-hook imaps://<drexel-username>@imap.mail.drexel.edu 'source ~/.mutt/drexel'
175 folder-hook imaps://<gmail-username>@gmail.com@imap.gmail.com 'source ~/.mutt/gmail'
177 # switch FROM field so msmtp changes sending account
178 # http://home.nyc.rr.com/computertaijutsu/mutt.html
179 macro generic '<esc>1' ":set from='<drexel-from-address>@drexel.edu'"
180 macro generic '<esc>2' ":set from='<gmail-username>@gmail.com'"
181 # no send2-hook in version 1.4.2.2i
182 send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/local/bin/msmtp "'
183 send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/local/bin/msmtp -a gmail"'
184 #send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/bin/msmtp "'
185 #send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/bin/msmtp -a gmail"'
187 set use_from=yes # required so msmtp knows which account to use to send mails
189 This sets up your two mailboxes (`drexel` and `gmail`) where you can
190 receive mail. It also sets up methods for switching between the two
191 accounts. To ease in configuring the two accounts, we split most of
192 the configuration details into `~/.mutt/common`, `~/.mutt/drexel`, and
193 `~/.mutt/gmail`. Sourcing common brings in some configuration
194 commands shared by both accounts. The `drexel` and `gmail` files
195 contain account-specific configuration commands. All the password
196 information is in `.muttrc` and `.msmtprc` though, so be sure to
197 `chmod 600` them. Make sure you get the path to `msmtp` right for
198 your system (`which msmtp` should find it).
200 Note that I removed the `folder-hook . 'source ~/.mutt/drexel'` line
201 that had been in my previous version. This line was stupid and
202 switched back to my drexel settings whenever I left my Gmail inbox
203 (say for my Gmail `Sent Mail` box). Without it, Mutt has been
204 behaving much more intuitively.
206 The specific configuration files are:
208 The common configuration (these are all optional):
211 set realname='<your-realname>'
213 set move=no # stop asking to "move read messages to mbox"
215 set mail_check=600 # check for new mail every 10 minutes when user is active
216 set timeout=600 # check for new mail every 10 minutes when user is not active
218 set editor='/usr/bin/emacs -nw' # use emacs as the editor
219 set edit_headers # editable headers
226 # Drexel mail server addresses extracted from
227 # https://askdrexel.drexel.edu/app/answers/detail/a_id/2786
228 # email server location
229 set spoolfile=imaps://<drexel-username>@imap.mail.drexel.edu:993/INBOX
230 set folder=imaps://<drexel-username>@imap.mail.drexel.edu:993/
232 # save copies of sent emails to the ${folder}Sent directory
233 # the '+' expands to $folders (like '~' to $HOME in the bash shell)
236 # use msmtp to send outgoing mail to the mailserver
237 # see ~/.msmtp for configuration
238 set sendmail=/usr/local/bin/msmtp
240 set from='<drexel-from-address>@drexel.edu'
246 # Gmail mail server addresses from
247 # http://mail.google.com/support/bin/answer.py?answer=78799
248 # email server location
249 set spoolfile=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/INBOX
250 set folder=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/
252 # gmail does this automatically
255 # use msmtp to send outgoing mail to the mailserver
256 # see ~/.msmtp for configuration
257 set sendmail='/usr/local/bin/msmtp -a gmail'
259 set from='<gmail-username>@gmail.com'
261 Firing up `mutt` takes you to your Drexel inbox like you're used to.
262 You can change directories like your used to with `c`. You switch
263 accounts with `c TAB TAB`. The first tab lists all the mailboxes in
264 your Drexel account, and the second lists all of your available
265 accounts (mailboxes).
267 Strangely (I haven't figured out why yet), `c TAB` from `gmail` also
268 lists the *drexel* directories. No problem though, you can get a list
269 of gmail directories with `c +TAB TAB TAB` from `gmail` (I also don't
270 understand what the second `TAB` does).
272 Anyhow, that should get people started.
277 I just added my Comcast email account (a necessary administrative
278 evil) to the above configuration. Comcast doesn't supply an [[IMAP]]
279 interface, so we're forced to fall back on [[POP]]. Luckily, that
280 doesn't change much of the configuration, which consisted of creating
281 a `.mutt/comcast` file:
283 # Comcast information
285 # Comcast mail server addresses from
286 # http://www.comcast.com/customers/faq/FaqDetails.ashx?Id=2165
288 # http://www.comcast.com/customers/faq/FaqDetails.ashx?ID=2288
289 # email server location
290 set spoolfile=pops://<comcast-username>@mail.comcast.net:110/INBOX
291 set folder=pops://<comcast-username>@mail.comcast.net:110/
293 # gmail does this automatically
296 # use msmtp to send outgoing mail to the mailserver
297 # see ~/.msmtp for configuration
298 set sendmail='/usr/local/bin/msmtp -a gmail'
300 set from='<gmail-username>@gmail.com'
303 set pop_checkinterval=600
305 Where the gmail stuff is because I'm sending mail using Gmail when I'm
306 looking at my Comcast account. This avoids using Comcast as much as
307 possible ;). Note that `<comcast-username>` is everything before the
308 `@` in your Comcast email address.
310 I then adjust my `.muttrc` file by adding Comcast to my list of
313 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com pops://<comcast-username>@mail.comcast.net
315 in a single long line. I also added account and folder hooks:
317 account-hook pops://<comcast-username>@mail.comcast.net \
318 'set pop_user=<comcast-username> pop_pass="<comcast-password>"'
319 folder-hook imaps://<comcast-username>@imap.comcast.net 'source ~/.mutt/comcast'
321 And that seems to handle it…
326 [[PGP]] is a encryption and authentication system often used for
327 protecting email. The [[GnuPG]] implementation can be used with Mutt
328 to send secure, authenticated emails between capable parties.
330 Once you've got a key set up, determine the key ID for your pair with
332 $ gpg --list-keys --keyid-format 0xlong
333 /home/user/.gnupg/pubring.gpg
334 -----------------------------
335 pub 1024D/0xFC29BDCDF15F5BE8 2008-08-09 [expires: 2009-08-09]
338 Where `0xFC29BDCDF15F5BE8` is my long key ID (long IDs are short IDs
339 prefixed with additional fingerprint information). I use the long ID
340 here because it is more specific and I only have to enter it once for
343 Tell Mutt how to use `gpg` by adding
347 to your `.muttrc` file and creating `~/.mutt/pgp` as follows
348 (replacing my key ID with your own)
350 # from Justin R. Miller's
351 # `Everything You Need To Know To Start Using GnuPG with Mutt'
352 # http://codesorcery.net/old/mutt/mutt-gnupg-howto
354 set pgp_decode_command='gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f'
355 set pgp_verify_command='gpg --no-verbose --batch --output - --verify %s %f'
356 set pgp_decrypt_command='gpg --passphrase-fd 0 --no-verbose --batch --output - %f'
357 set pgp_sign_command='gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f'
358 set pgp_clearsign_command='gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f'
359 set pgp_encrypt_only_command='/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0xFC29BDCDF15F5BE8 -- -r %r -- %f'
360 set pgp_encrypt_sign_command='/usr/lib/mutt/pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0xFC29BDCDF15F5BE8 -- -r %r -- %f'
361 set pgp_import_command='gpg --no-verbose --import -v %f'
362 set pgp_export_command='gpg --no-verbose --export --armor %r'
363 set pgp_verify_key_command='gpg --no-verbose --batch --fingerprint --check-sigs %r'
364 set pgp_list_pubring_command='gpg --no-verbose --batch --with-colons --list-keys %r'
365 set pgp_list_secring_command='gpg --no-verbose --batch --with-colons --list-secret-keys %r'
367 set pgp_sign_as=0xFC29BDCDF15F5BE8
368 set pgp_replyencrypt=yes
370 set pgp_good_sign='^gpg: Good signature from'
372 The above file autosigns all your sent emails (`set
373 pgp_autosign=yes`), but you can obviously turn that off if you would
374 like. To change signing/encryption on an email, use the `p` key from
375 the compose view (the screen shown after you have finished editing a
376 new e-mail; thank, you [Chad Perrin][compose-view-p]).
378 Browsing email with links
379 =========================
381 Usually Mutt is pretty good about handling HTML in emails. When you
382 get emails that are obviously HTML, `v` will take you to the
383 attachment list (which should show the email as type `text/html`), and
384 enter will open the email in your browser (via [[mailcap]]).
386 Sometimes you get `text/plain` emails with URLs in them, or maybe the
387 above procedure just isn't working. In that case, add
389 macro pager \cb <pipe-entry>'w3m'<enter> 'Follow links in w3m'
391 somewhere in your mutt configuration files (thank you, [Bruno
392 Postle][links]). Then pressing `Ctrl-b` will pipe the email you're
393 looking at into [w3m][]. Pressing `:` in w3m will scan the document
394 for URL-like strings and make them browsable.
396 Folder size in status bar
397 =========================
399 Add the folder size to the status bar by adding `%l` or `%L` to
400 `status_format` in your `~/.muttrc` file. For example
402 set status_format='-%r-Mutt: %f %L'
405 [Mutt]: http://www.mutt.org/
406 [MUA]: http://en.wikipedia.org/wiki/Email_client
407 [msmtp]: http://msmtp.sourceforge.net/
408 [mfm]: http://mutt.blackfish.org.uk/
409 [GnuPG]: http://www.gnupg.org/
410 [compose-view-p]: http://blogs.techrepublic.com.com/security/?p=413
411 [links]: http://mutt.blackfish.org.uk/following-links/
412 [w3m]: http://w3m.sourceforge.net/