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
100 An excellent tutorial page is [my first mutt][mfm].
105 I finally had some time to play around and get Drexel mail and Gmail
106 working at the same time. The basic setup is the same as above, using
107 msmtp to send the mail and Mutt's built in IMAP capability to get it
110 First configure msmtp with:
113 # Mostly from Peter Garrett's examples
114 # https://lists.ubuntu.com/archives/ubuntu-users/2007-September/122698.html
115 # Accounts from Scott Robbins' `A Quick Guide to Mutt'
116 # http://home.nyc.rr.com/computertaijutsu/mutt.html
119 host smtp.mail.drexel.edu
120 from <drexel-from-address>@drexel.edu
122 user <drexel-username>
123 password <drexel-password>
125 #tls_trust_file /etc/ssl/certs/ca-certificates.crt
126 tls_trust_file /etc/pki/tls/cert.pem
130 from <gmail-from-address>@gmail.com
131 user <gmail-from-address>@gmail.com
132 password <gmail password>
136 tls_trust_file /etc/pki/tls/cert.pem
138 account default : drexel
140 This sets msmtp up so it can connect to either mail
141 server. `<drexel-username>` is your username (`abc123`),
142 `<drexel-from-address>` can be the same as `<drexel-username>`, but
143 you can use any address you've set up as an alias.
144 `<gmail-from-address>@gmail.com` is your full gmail email address. The
145 `tls_trust_file` line depends on your distribution. For Debian-based
146 distributions, use the `ca-certificates.crt` line; and for Red
147 Hat-based distributions, use the `cert.pem` line. I don't know where
148 the certificate information is stored for other distributions, but
149 googling about should find it.
151 Then configure mutt with
155 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com
157 source ~/.mutt/common
158 source ~/.mutt/drexel
160 # from http://wiki.mutt.org/?MuttGuide/UseIMAP
161 # account-hook to set up connection parameters (username, password, etc.)
162 # and folder hook for everything else.
163 account-hook . 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
164 account-hook imaps://<drexel-username>@imap.mail.drexel.edu \
165 'set imap_user=<drexel-username>@drexel.edu imap_pass="<drexel-password>"'
166 account-hook imaps://<gmail-username>@gmail.com@imap.gmail.com \
167 'set imap_user=<gmail-username>@gmail.com imap_pass="<gmail-password>"'
168 folder-hook imaps://<drexel-username>@imap.mail.drexel.edu 'source ~/.mutt/drexel'
169 folder-hook imaps://<gmail-username>@gmail.com@imap.gmail.com 'source ~/.mutt/gmail'
171 # switch FROM field so msmtp changes sending account
172 # http://home.nyc.rr.com/computertaijutsu/mutt.html
173 macro generic "<esc>1" ":set from='<drexel-from-address>@drexel.edu'"
174 macro generic "<esc>2" ":set from='<gmail-username>@gmail.com'"
175 # no send2-hook in version 1.4.2.2i
176 send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/local/bin/msmtp "'
177 send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/local/bin/msmtp -a gmail"'
178 #send-hook '~f <drexel-from-address>@drexel.edu' 'set sendmail="/usr/bin/msmtp "'
179 #send-hook '~f <gmail-username>@gmail.com' 'set sendmail="/usr/bin/msmtp -a gmail"'
181 set use_from=yes # required so msmtp knows which account to use to send mails
183 This sets up your two mailboxes (drexel and gmail) where you can
184 recieve mail. It also sets up methods for switching between the two
185 accounts. To ease in configuring the two accounts, we split most of
186 the configuration details into `~/.mutt/common`, `~/.mutt/drexel`, and
187 `~/.mutt/gmail`. Sourcing common brings in some configuration
188 commands shared by both accounts. The `drexel` and `gmail` files
189 contain account-specific configuration commands. All the password
190 information is in `.muttrc` and `.msmtprc` though, so be sure to
191 `chmod 600` them. Make sure you get the path to `msmtp` right for
192 your system (`which msmtp` should find it).
194 Note that I removed the `folder-hook . 'source ~/.mutt/drexel'` line
195 that had been in my previous version. This line was stupid and
196 switched back to my drexel settings whenever I left my Gmail inbox
197 (say for my Gmail `Sent Mail` box). Without it, Mutt has been
198 behaving much more intuitively.
200 The specific configuration files are:
202 The common configuration (these are all optional).
205 set realname="<your-realname>"
207 set move=no # stop asking to "move read messages to mbox"
209 set mail_check=600 # check for new mail every 10 minutes when user is active
210 set timeout=600 # check for new mail every 10 minutes when user is not active
212 set editor="/usr/bin/emacs -nw" # use emacs as the editor
213 set edit_headers # editable headers
220 # Drexel mail server addresses from
221 # http://www.drexel.edu/IRT/support/ConfigureEmail.html
222 # email server location
223 set spoolfile=imaps://<drexel-username>@imap.mail.drexel.edu:993/INBOX
224 set folder=imaps://<drexel-username>@imap.mail.drexel.edu:993/
226 # save copies of sent emails to the ${folder}Sent directory
227 # the '+' expands to $folders (like '~' to $HOME in the bash shell)
230 # use msmtp to send outgoing mail to the mailserver
231 # see ~/.msmtp for configuration
232 set sendmail=/usr/local/bin/msmtp
234 set from="<drexel-from-address>@drexel.edu"
240 # Gmail mail server addresses from
241 # http://mail.google.com/support/bin/answer.py?answer=78799
242 # email server location
243 set spoolfile=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/INBOX
244 set folder=imaps://<gmail-username>@gmail.com@imap.gmail.com:993/
246 # gmail does this automatically
249 # use msmtp to send outgoing mail to the mailserver
250 # see ~/.msmtp for configuration
251 set sendmail="/usr/local/bin/msmtp -a gmail"
253 set from="<gmail-username>@gmail.com"
255 Firing up `mutt` takes you to your Drexel inbox like you're used to.
256 You can change directories like your used to with `c`. You switch
257 accounts with `c TAB TAB`. The first tab lists all the mailboxes in
258 your Drexel account, and the second lists all of your available
259 accounts (mailboxes).
261 Strangely (I haven't figured out why yet), `c TAB` from gmail also
262 lists the *drexel* directories. No problem though, you can get a list
263 of gmail directories with `c +TAB TAB TAB` from gmail (I also don't
264 understand what the second `TAB` does).
266 Anyhow, that should get people started.
271 I just added my Comcast email account (a necessary administrative
272 evil) to the above configuration. Comcast doesn't supply an [[IMAP]]
273 interface, so we're forced to fall back on [[POP]]. Luckily, that
274 doesn't change much of the configuration, which consisted of creating
275 a `.mutt/comcast` file:
277 # Comcast information
279 # Comcast mail server addresses from
280 # http://www.comcast.com/customers/faq/FaqDetails.ashx?Id=2165
282 # http://www.comcast.com/customers/faq/FaqDetails.ashx?ID=2288
283 # email server location
284 set spoolfile=pops://<comcast-username>@mail.comcast.net:110/INBOX
285 set folder=pops://<comcast-username>@mail.comcast.net:110/
287 # gmail does this automatically
290 # use msmtp to send outgoing mail to the mailserver
291 # see ~/.msmtp for configuration
292 set sendmail="/usr/local/bin/msmtp -a gmail"
294 set from="<gmail-username>@gmail.com"
297 set pop_checkinterval="600"
299 Where the gmail stuff is because I'm sending mail using Gmail when I'm
300 looking at my Comcast account. This avoids using Comcast as much as
301 possible ;). Note that `<comcast-username>` is everything before the
302 `@` in your Comcast email address.
304 I then adjust my `.muttrc` file by adding Comcast to my list of
307 mailboxes imaps://<drexel-username>@imap.mail.drexel.edu imaps://<gmail-username>@gmail.com@imap.gmail.com pops://<comcast-username>@mail.comcast.net
309 in a single long line. I also added account and folder hooks:
311 account-hook pops://<comcast-username>@mail.comcast.net \
312 'set pop_user=<comcast-username> pop_pass="<comcast-password>"'
313 folder-hook imaps://<comcast-username>@imap.comcast.net 'source ~/.mutt/comcast'
315 And that seems to handle it…
320 [[PGP]] is a encryption and authentication system often used for
321 protecting email. The [[GnuPG]] implementation can be used with Mutt
322 to send secure, authenticated emails between capable parties.
324 Once you've got a key set up, determine the key ID for your pair with
326 $ gpg --list-keys --keyid-format 0xlong
327 /home/user/.gnupg/pubring.gpg
328 -----------------------------
329 pub 1024D/0xFC29BDCDF15F5BE8 2008-08-09 [expires: 2009-08-09]
332 Where `0xFC29BDCDF15F5BE8` is my long key ID (I don't understand the
333 difference between the long and short keys, but I figure the longer
334 one must be more specific, and since I only have to enter it once for
335 Mutt, I chose the longer key.)
337 Then, tell Mutt how to use `gpg`, adding
341 to your `.muttrc` file and creating `~/.mutt/pgp` as follows
342 (replacing my key ID with your own)
344 # from Justin R. Miller's
345 # `Everything You Need To Know To Start Using GnuPG with Mutt'
346 # http://codesorcery.net/old/mutt/mutt-gnupg-howto
348 set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
349 set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
350 set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
351 set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
352 set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
353 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"
354 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"
355 set pgp_import_command="gpg --no-verbose --import -v %f"
356 set pgp_export_command="gpg --no-verbose --export --armor %r"
357 set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
358 set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
359 set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
361 set pgp_sign_as=0xFC29BDCDF15F5BE8
362 set pgp_replyencrypt=yes
364 set pgp_good_sign="^gpg: Good signature from"
366 The above file autosigns all your sent emails (`set
367 pgp_autosign=yes`), but you can obviously turn that off if you would
368 like. To change signing/encryption on an email, use the `p` key from
369 the compose view (the screen shown after you have finished editing a
370 new e-mail; thank, you [Chad Perrin][compose-view-p]).
372 Browsing email with links
373 =========================
375 Usually mutt is pretty good about handling HTML in emails. When you
376 get emails that are obviously HTML, `v` will take you to the
377 attachment list (which should show the email as type `text/html`), and
378 enter will open the email in your browser ([[w3m]], right?).
380 Sometimes you get `text/plain` emails with URLs in them, or maybe the
381 above procedure just isn't working. In that case, add
383 macro pager \cb <pipe-entry>'w3m'<enter> 'Follow links in w3m'
385 somewhere in your mutt configuration files (thank you, [Bruno
386 Postle][links]). Then pressing `Ctrl-b` will pipe the email you're
387 looking at into w3m. Pressing `:` in w3m will scan the document for
388 URL-like strings and make them browsable.
390 Folder size in status bar
391 =========================
393 Add the folder size to the status bar by adding `%l` or `%L` to
394 `status_format` in your `~/.muttrc` file. For example
396 set status_format="-%r-Mutt: %f %L"
399 [Mutt]: http://www.mutt.org/
400 [MUA]: http://en.wikipedia.org/wiki/Email_client
401 [msmtp]: http://msmtp.sourceforge.net/
402 [mfm]: http://mutt.blackfish.org.uk/
403 [GnuPG]: http://www.gnupg.org/
404 [compose-view-p]: http://blogs.techrepublic.com.com/security/?p=413
405 [links]: http://mutt.blackfish.org.uk/following-links/