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 You configure Mutt with the file `~/.muttrc`. To set it up with the
22 Drexel email system, I looked up the server addresses, and created the
26 set imap_user='<your-username>@drexel.edu'
27 set imap_pass='<your-password>'
28 set from="<your-username>@drexel.edu"
29 set use_from=yes # required so msmtp knows which account to use to send mails
31 # setting your realname is optional, but drexel addresses can be cryptic...
32 set realname="<your-realname>"
34 # email server location
35 set spoolfile=imaps://<your-username>@imap.mail.drexel.edu:993/INBOX
36 set folder=imaps://<your-username>@imap.mail.drexel.edu:993/
38 # use msmtp for sending mail
39 set sendmail=/usr/bin/msmtp # Debian-style system path, yours may be different
41 # save copies of sent email to the ${folder}Sent directory
42 # the '+' expands to $folders (like '~' to $HOME in bash)
45 set mail_check=600 # check for new mail every 10 minutes when user is active
46 set timeout=600 # check for new mail every 10 min. when user is not active
48 set editor="/usr/bin/emacs -nw" # use emacs for writing emails
49 set edit_headers # allow editing headers while you're in emacs
51 Since this file contains your password, you should not allow other
56 This still isn't terribly secure, so you could remove the password
57 line entirely, in which case Mutt prompts you for it when it tries to
58 log in (just like webmail does).
60 The `mail_check` and `timeout` settings set up how often Mutt checks
61 for new mail, which I've set to be pretty slow. You can type `$` to
62 sync, whenever you want to send outgoing mail or check for new mail.
64 Googling `.muttrc` should turn up tons of other goodies, or try `man
67 You also have to configure msmtp with a `~/.msmtprc` file:
70 host smtp.mail.drexel.edu
71 from <your-username>@drexel.edu
73 # use STMP authentication
76 password <your-password>
80 tls_trust_file /etc/ssl/certs/ca-certificates.crt
82 To find information on a given SMTP server from the command line, use
84 $ msmtp --host=smtp.some.domain --server-info
86 The same security issues with plain text passwords apply to
87 `.msmtprc`, so `chmod 600` it, or possibly remove your password
93 There's list of basic shortcuts across the top of the Mutt screen.
94 Most importantly, `?:Help`, which will give a list of all the current
95 shortcuts. An excellent tutorial page is [my first mutt][mfm].
97 Multiple IMAP accounts
98 ======================
100 I finally had some time to play around and get Drexel mail and Gmail
101 working at the same time. The basic setup is the same as above, using
102 msmtp to send the mail and Mutt's built in IMAP capability to get it
105 First configure msmtp with:
108 # Mostly from Peter Garrett's examples
109 # https://lists.ubuntu.com/archives/ubuntu-users/2007-September/122698.html
110 # Accounts from Scott Robbins' `A Quick Guide to Mutt'
111 # http://home.nyc.rr.com/computertaijutsu/mutt.html
114 host smtp.mail.drexel.edu
115 from <drexel-from-address>@drexel.edu
117 user <drexel-username>
118 password <drexel-password>
120 tls_trust_file /etc/ssl/certs/ca-certificates.crt
121 #tls_trust_file /etc/pki/tls/cert.pem
125 from <gmail-from-address>@gmail.com
126 user <gmail-from-address>@gmail.com
127 password <gmail password>
131 tls_trust_file /etc/pki/tls/cert.pem
133 account default : drexel
135 This sets msmtp up so it can connect to either mail
136 server. `<drexel-username>` is your username (`abc123`),
137 `<drexel-from-address>` can be the same as `<drexel-username>`, but
138 you can use any address you've set up as an alias.
139 `<gmail-from-address>@gmail.com` is your full gmail email address. The
140 `tls_trust_file` line depends on your distribution. For Gentoo and
141 Debian-based distributions, use the `ca-certificates.crt` line; and
142 for Red Hat-based distributions, use the `cert.pem` line. I don't
143 know where the certificate information is stored for other
144 distributions, but googling about should find it.
150 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com
152 source ~/.mutt/common
153 source ~/.mutt/drexel
155 # from http://wiki.mutt.org/?MuttGuide/UseIMAP
156 # account-hook to set up connection parameters (username, password, etc.)
157 # and folder hook for everything else.
158 account-hook . 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
159 account-hook imaps://<drexel-username>@imap.mail.drexel.edu \
160 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
161 account-hook imaps://<gmail-username>@gmail.com@imap.gmail.com \
162 'set imap_user=<gmail-username>@gmail.com imap_pass="<gmail-password>"'
163 folder-hook imaps://<drexel-username>@imap.mail.drexel.edu 'source ~/.mutt/drexel'
164 folder-hook imaps://<gmail-username>@gmail.com@imap.gmail.com 'source ~/.mutt/gmail'
166 # switch FROM field so msmtp changes sending account
167 # http://home.nyc.rr.com/computertaijutsu/mutt.html
168 macro generic "<esc>1" ":set from='<drexel-from-address>@drexel.edu'"
169 macro generic "<esc>2" ":set from='<gmail-username>@gmail.com'"
170 # no send2-hook in version 1.4.2.2i
171 send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/local/bin/msmtp "'
172 send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/local/bin/msmtp -a gmail"'
173 #send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/bin/msmtp "'
174 #send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/bin/msmtp -a gmail"'
176 set use_from=yes # required so msmtp knows which account to use to send mails
178 This sets up your two mailboxes (`drexel` and `gmail`) where you can
179 receive mail. It also sets up methods for switching between the two
180 accounts. To ease in configuring the two accounts, we split most of
181 the configuration details into `~/.mutt/common`, `~/.mutt/drexel`, and
182 `~/.mutt/gmail`. Sourcing common brings in some configuration
183 commands shared by both accounts. The `drexel` and `gmail` files
184 contain account-specific configuration commands. All the password
185 information is in `.muttrc` and `.msmtprc` though, so be sure to
186 `chmod 600` them. Make sure you get the path to `msmtp` right for
187 your system (`which msmtp` should find it).
189 Note that I removed the `folder-hook . 'source ~/.mutt/drexel'` line
190 that had been in my previous version. This line was stupid and
191 switched back to my drexel settings whenever I left my Gmail inbox
192 (say for my Gmail `Sent Mail` box). Without it, Mutt has been
193 behaving much more intuitively.
195 The specific configuration files are:
197 The common configuration (these are all optional):
200 set realname="<your-realname>"
202 set move=no # stop asking to "move read messages to mbox"
204 set mail_check=600 # check for new mail every 10 minutes when user is active
205 set timeout=600 # check for new mail every 10 minutes when user is not active
207 set editor="/usr/bin/emacs -nw" # use emacs as the editor
208 set edit_headers # editable headers
215 # Drexel mail server addresses from
216 # http://www.drexel.edu/IRT/support/ConfigureEmail.html
217 # email server location
218 set spoolfile=imaps://<drexel-username>@imap.mail.drexel.edu:993/INBOX
219 set folder=imaps://<drexel-username>@imap.mail.drexel.edu:993/
221 # save copies of sent emails to the ${folder}Sent directory
222 # the '+' expands to $folders (like '~' to $HOME in the bash shell)
225 # use msmtp to send outgoing mail to the mailserver
226 # see ~/.msmtp for configuration
227 set sendmail=/usr/local/bin/msmtp
229 set from="<drexel-from-address>@drexel.edu"
235 # Gmail mail server addresses from
236 # http://mail.google.com/support/bin/answer.py?answer=78799
237 # email server location
238 set spoolfile=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/INBOX
239 set folder=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/
241 # gmail does this automatically
244 # use msmtp to send outgoing mail to the mailserver
245 # see ~/.msmtp for configuration
246 set sendmail="/usr/local/bin/msmtp -a gmail"
248 set from="<gmail-username>@gmail.com"
250 Firing up `mutt` takes you to your Drexel inbox like you're used to.
251 You can change directories like your used to with `c`. You switch
252 accounts with `c TAB TAB`. The first tab lists all the mailboxes in
253 your Drexel account, and the second lists all of your available
254 accounts (mailboxes).
256 Strangely (I haven't figured out why yet), `c TAB` from `gmail` also
257 lists the *drexel* directories. No problem though, you can get a list
258 of gmail directories with `c +TAB TAB TAB` from `gmail` (I also don't
259 understand what the second `TAB` does).
261 Anyhow, that should get people started.
266 I just added my Comcast email account (a necessary administrative
267 evil) to the above configuration. Comcast doesn't supply an [[IMAP]]
268 interface, so we're forced to fall back on [[POP]]. Luckily, that
269 doesn't change much of the configuration, which consisted of creating
270 a `.mutt/comcast` file:
272 # Comcast information
274 # Comcast mail server addresses from
275 # http://www.comcast.com/customers/faq/FaqDetails.ashx?Id=2165
277 # http://www.comcast.com/customers/faq/FaqDetails.ashx?ID=2288
278 # email server location
279 set spoolfile=pops://<comcast-username>@mail.comcast.net:110/INBOX
280 set folder=pops://<comcast-username>@mail.comcast.net:110/
282 # gmail does this automatically
285 # use msmtp to send outgoing mail to the mailserver
286 # see ~/.msmtp for configuration
287 set sendmail="/usr/local/bin/msmtp -a gmail"
289 set from="<gmail-username>@gmail.com"
292 set pop_checkinterval="600"
294 Where the gmail stuff is because I'm sending mail using Gmail when I'm
295 looking at my Comcast account. This avoids using Comcast as much as
296 possible ;). Note that `<comcast-username>` is everything before the
297 `@` in your Comcast email address.
299 I then adjust my `.muttrc` file by adding Comcast to my list of
302 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com pops://<comcast-username>@mail.comcast.net
304 in a single long line. I also added account and folder hooks:
306 account-hook pops://<comcast-username>@mail.comcast.net \
307 'set pop_user=<comcast-username> pop_pass="<comcast-password>"'
308 folder-hook imaps://<comcast-username>@imap.comcast.net 'source ~/.mutt/comcast'
310 And that seems to handle it…
315 [[PGP]] is a encryption and authentication system often used for
316 protecting email. The [[GnuPG]] implementation can be used with Mutt
317 to send secure, authenticated emails between capable parties.
319 Once you've got a key set up, determine the key ID for your pair with
321 $ gpg --list-keys --keyid-format 0xlong
322 /home/user/.gnupg/pubring.gpg
323 -----------------------------
324 pub 1024D/0xFC29BDCDF15F5BE8 2008-08-09 [expires: 2009-08-09]
327 Where `0xFC29BDCDF15F5BE8` is my long key ID (long IDs are short IDs
328 prefixed with additional fingerprint information). I use the long ID
329 here because it is more specific and I only have to enter it once for
332 Tell Mutt how to use `gpg` by adding
336 to your `.muttrc` file and creating `~/.mutt/pgp` as follows
337 (replacing my key ID with your own)
339 # from Justin R. Miller's
340 # `Everything You Need To Know To Start Using GnuPG with Mutt'
341 # http://codesorcery.net/old/mutt/mutt-gnupg-howto
343 set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
344 set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
345 set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
346 set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
347 set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
348 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"
349 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"
350 set pgp_import_command="gpg --no-verbose --import -v %f"
351 set pgp_export_command="gpg --no-verbose --export --armor %r"
352 set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
353 set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
354 set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
356 set pgp_sign_as=0xFC29BDCDF15F5BE8
357 set pgp_replyencrypt=yes
359 set pgp_good_sign="^gpg: Good signature from"
361 The above file autosigns all your sent emails (`set
362 pgp_autosign=yes`), but you can obviously turn that off if you would
363 like. To change signing/encryption on an email, use the `p` key from
364 the compose view (the screen shown after you have finished editing a
365 new e-mail; thank, you [Chad Perrin][compose-view-p]).
367 Browsing email with links
368 =========================
370 Usually Mutt is pretty good about handling HTML in emails. When you
371 get emails that are obviously HTML, `v` will take you to the
372 attachment list (which should show the email as type `text/html`), and
373 enter will open the email in your browser (via [[mailcap]]).
375 Sometimes you get `text/plain` emails with URLs in them, or maybe the
376 above procedure just isn't working. In that case, add
378 macro pager \cb <pipe-entry>'w3m'<enter> 'Follow links in w3m'
380 somewhere in your mutt configuration files (thank you, [Bruno
381 Postle][links]). Then pressing `Ctrl-b` will pipe the email you're
382 looking at into [w3m][]. Pressing `:` in w3m will scan the document
383 for URL-like strings and make them browsable.
385 Folder size in status bar
386 =========================
388 Add the folder size to the status bar by adding `%l` or `%L` to
389 `status_format` in your `~/.muttrc` file. For example
391 set status_format="-%r-Mutt: %f %L"
394 [Mutt]: http://www.mutt.org/
395 [MUA]: http://en.wikipedia.org/wiki/Email_client
396 [msmtp]: http://msmtp.sourceforge.net/
397 [mfm]: http://mutt.blackfish.org.uk/
398 [GnuPG]: http://www.gnupg.org/
399 [compose-view-p]: http://blogs.techrepublic.com.com/security/?p=413
400 [links]: http://mutt.blackfish.org.uk/following-links/
401 [w3m]: http://w3m.sourceforge.net/