Difference between revisions of "Mutt"
Stonecrest (talk | contribs) m (typos) |
(→Mutt and Vim: reformatting text: see vim help 10.7) |
||
Line 199: | Line 199: | ||
To set a different temp directory, e.g. ~/.tmp, add a line to your .muttrc as follows: | To set a different temp directory, e.g. ~/.tmp, add a line to your .muttrc as follows: | ||
set tmpdir="~/.tmp" | set tmpdir="~/.tmp" | ||
− | + | To reformat a modified text see the Vim context help | |
+ | :h 10.7 |
Revision as of 10:23, 8 October 2007
Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end
- Mutt is a text-based mail client renowned for its powerful features. Mutt, though over a decade old, remains the mail client of choice for great number of power-users. Unfortunately, a default mutt install is plagued by complex keybindings, and a daunting amount of documentation. This guide will help the average user get mutt up and running, and begin customizing it to his/her taste.
Contents
Quick Start
What Mutt Does Not Do
Mutt is a Mail User Agent (MUA), and was written to view mail. It was not written to retrieve, send, or sort mail. It relies on external programs to do those tasks. For this wiki, we will be using offlineimap or getmail to retrieve our mail, procmail to sort our mail in the case of POP3, and msmtp to send our mail.
Setting up for IMAP
While IMAP-functionality is built into mutt, it does not download the Mail for offline-use. This section describes how to download your eMails with OfflineIMAP to a local folder which is then processed by mutt.
Setting up OfflineIMAP
First, enable the community-repository and install OfflineIMAP via a simple pacman -Sy offlineimap
. You now need to set it up for your special needs. Create the file ~/.offlineimaprc
and edit it with your favorite editor. I will now show you a sample-configuration. Edit according to your special needs.
[general] accounts = myaccount # change to whatever you want ui = Curses.Blinkenlights # Gives you a nice blinky output on the console so you know what's happening. # ui = Noninteractive.Quiet # If uncommented, this would show nothing at all. Great for cronjobs or background-processes [Account myaccount] localrepository = mylocal # Profile-Name for the local Mails for a given Account remoterepository = myremote # Profile-Name for the remote Mails for a given Account autorefresh = 5 # fetches your mails every 5 Minutes [Repository mylocal] type = Maildir # Way of storing Mails locally. Only Maildir is currently supported localfolders = ~/Mail # Place where the synced Mails should be [Repository myremote] type = IMAP # Type of remote Mailbox. Only IMAP is supported right now. remotehost = imap.myhost.com # Where to connect ssl = yes # Whether to use SSL or not # remoteport = 993 # Would specify a port if uncommented. That way, it just tries to use a default-port remoteuser = myremoteusername # Login-Name remotepass = myremotepassword # Login-Password. -- ACHTUNG! Of course, this is not too safe. Make sure that the file is readable only by you. Even better: use some of the suggestions in the OfflineIMAP-Manual to make it safer.
This is a minimal setup to get you going. For more advanced features, consult the OfflineIMAP-Homepage and check back at the annotated offlineimaprc.
You are now almost ready to run OfflineIMAP. Create the directory you have defined in the offlineimaprc, in this case via mkdir ~/Mail
. Then run offlineimap
. Your eMails will now be synced. If anything goes wrong, take a closer look at the Error-Message. OfflineIMAP is usually very verbose about problems.
Configuring mutt for MailDir
The beauty of MailDir is, that it is a generic and standardized format. Almost every MUA is able to handle MailDirs and mutts support is excellent. There are just a few simple things that you need to do to get mutt to use them. Open your muttrc with your favorite editor and add the following lines.
set mbox_type=Maildir set folder=$HOME/Mail set spoolfile=+/INBOX set header_cache=~/.hcache
This is a minimal Configuration that enables you to access your Maildir and checks for new local Mails in INBOX. This configuration also caches the headers of the eMails to speed up directory-listings. It might not be enabled in your build (but it sure is in the Arch-Package) Note that this does affect OfflineIMAP in any way. It always syncs the all directories on a Server. spoolfile
tells mutt which local directories to poll for new Mail. You might want to add more Spoolfiles (for example the Directories of Mailing-Lists) and maybe other things. But this is subject to the mutt-Manual and beyond the scope of this document.
That's it. Don't forget to adjust everything to your liking. Get cracking!
Setting up for POP mail
Retrieving Mail
First install getmail. It is in the [extra]
repository.
pacman -S getmail
Now create the directory ~/.getmail/
. Open the file ~/.getmail/getmailrc
in your favorite text editor.
Here is an example getmailrc
used with a gmail account.
[retriever] type = SimplePOP3SSLRetriever server = pop.gmail.com username = username@gmail.com port = 995 password = password [destination] type = Maildir path = ~/mail/
You can tweak this to your POP3 service's specification.
For this guide we will be storing our mail in the maildir
format. The two main mailbox formats are mbox
and maildir
. The main difference between the two is that mbox
is one file, with all of your mails and their headers stored in it, whereas a maildir
is a directory tree. Each mail is its own file, which will often speed things up.
A maildir
is just a folder with the folders cur
, new
and tmp
in it.
mkdir -p ~/mail/{cur,new,tmp}
Now, run getmail. If it works fine, you can create a cronjob for getmail to run every n hours/minutes. Type crontab -e
to edit cronjobs, and enter the following:
*/30 * * * * /usr/bin/getmail
That will run getmail
every 30 minutes.
Sorting Mail
Procmail is an extremely powerful sorting tool. For the purposes of this wiki, we will do some primitive sorting to get started.
First, install procmail. It is in the [current]
repository.
pacman -S procmail
You must edit your getmailrc to pass retrieved mail to procmail.
[destination] type = MDA_external path = /usr/bin/procmail
Now, open up .procmailrc
in your favorite editor. The following will sort all mail from the happy-kangaroos mailing list, and all mail from your lovey-dovey friend in their own maildirs.
MAILDIR=$HOME/mail DEFAULT=$MAILDIR/inbox/ LOGFILE=$MAILDIR/log :0: * ^To: happy-kangaroos@nicehost.com happy-kangaroos/ :0: * ^From: loveydovey@iheartyou.net lovey-dovey/
After you've saved your .procmailrc
, run getmail and see if procmail succeeds in sorting your mail into the appropriate directories.
Setting up for SMTP
Whether you use POP or IMAP to receive mail you will probably still send mail using SMTP.
Sending Mail
Msmtp is a very simple and easy to use smtp client. It is in the [extra]
repository.
pacman -S msmtp
Open up ~/.msmtprc
in your favorite editor. The following is an example of an .msmtprc
for a gmail account:
account default host smtp.gmail.com port 587 protocol smtp auth on from username@gmail.com user username@gmail.com password mypassword tls on tls_starttls on
This file needs to be read/write only to the user:
chmod 600 ~/.msmtprc
Starting with version 1.4.11 of msmtp, setting up TLS is a bit more involved. msmtp, TLS, and ArchLinux gives instructions on how to configure the certificate for msmtp.
Now mutt must be configured to use msmtp. Make a directory ~/.mutt/
, and open up ~/.mutt/muttrc
. The following should get you started viewing and sending mail.
set realname='Disgruntled Kangaroo' set sendmail="/usr/bin/msmtp" set edit_headers=yes set folder=~/mail set mbox=+mbox set spoolfile=+inbox set record=+sent set postponed=+drafts set mbox_type=Maildir mailboxes +inbox +lovey-dovey +happy-kangaroos
Now, startup mutt. You should see all the mail in ~/mail/inbox
. Press m
to compose mail (it will use the editor defined by your EDITOR
environment variable. If this variable is not set, type export EDITOR=/path/to/yourfavorite/editor
. For testing purposes, address the letter to yourself. After you have written the lovely letter, use your editor's save and exit command. You will return to mutt, which will show you information about your e-mail. Press y
to send it. If everything works, congratulations! You can use mutt! However, realizing the true power of mutt comes with much customizing.
Customizing Mutt
Guides to get you started with using & customizing mutt :
- My first mutt (maintained by Bruno Postle)
- The Woodnotes Guide to the Mutt Email Client (maintained by Randall Wood)
xterminus is pretty active in the mutt community. His personal configs can be found at his Code and Configs Page . If you have any mutt specific questions, feel free to ask in the irc channel.
Signature Block
Create a .signature in your home directory. Your signature will be appended at the end of your email.
Viewing URLs & Opening Firefox
Your should start by creating a ./mutt directory in $HOME if not done yet. There, create a file named macros. Insert the following:
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'
Then install urlview with
pacman -S urlview
Create a .urlview in $HOME and insert the following:
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):] COMMAND firefox %s
When you read an email on the pager, hitting ctrl+b will list all the urls from the email. Navigate up or down with arrow keys and hit enter on the desired url. Firefox will start and go to the selected site.
Mutt and Vim
To limit the width of text to 72 characters, edit your .vimrc file and add:
au BufRead /tmp/mutt-* set tw=72
so, this Vim behavior will occur only when you use it together with mutt.
To set a different temp directory, e.g. ~/.tmp, add a line to your .muttrc as follows:
set tmpdir="~/.tmp"
To reformat a modified text see the Vim context help
:h 10.7