The Mutt E-Mail Client Michael Elkins version 2.2.13 (00d56288) (2024-03-09) Abstract "All mail clients suck. This one just sucks less." -- me, circa 1995 __________________________________________________________________ Table_of_Contents 1. Introduction 1. Mutt Home Page 2. Mailing Lists 3. Getting Mutt 4. Mutt Online Resources 5. Contributing to Mutt 6. Typographical Conventions 7. Copyright 2. Getting Started 1. Core Concepts 2. Screens and Menus 2.1. Index 2.2. Pager 2.3. File Browser 2.4. Sidebar 2.5. Help 2.6. Compose Menu 2.7. Alias Menu 2.8. Attachment Menu 2.9. List Menu 3. Moving Around in Menus 4. Editing Input Fields 4.1. Introduction 4.2. History 5. Reading Mail 5.1. The Message Index 5.2. The Pager 5.3. Threaded Mode 5.4. Miscellaneous Functions 6. Sending Mail 6.1. Introduction 6.2. Editing the Message Header 6.3. Sending Cryptographically Signed/Encrypted Messages 6.4. Sending Format=Flowed Messages 6.5. Background Editing 7. Forwarding and Bouncing Mail 8. Postponing Mail 9. Encryption and Signing 9.1. OpenPGP Configuration 9.2. S/MIME Configuration 3. Configuration 1. Location of Initialization Files 2. Starter Muttrc 3. Syntax of Initialization Files 4. Address Groups 5. Defining/Using Aliases 6. Changing the Default Key Bindings 6.1. Terminal Keybindings 6.2. Enter versus Return 7. Changing the current working directory 8. Defining Aliases for Character Sets 9. Setting Variables Based Upon Mailbox 10. Keyboard Macros 11. Using Color and Mono Video Attributes 12. Message Header Display 12.1. Header Display 12.2. Selecting Headers 12.3. Ordering Displayed Headers 13. Alternative Addresses 14. Mailing Lists 15. Using Multiple Spool Mailboxes 16. Monitoring Incoming Mail 17. User-Defined Headers 18. Specify Default Save Mailbox 19. Specify Default Fcc: Mailbox When Composing 20. Specify Default Save Filename and Default Fcc: Mailbox at Once 21. Change Settings Based Upon Message Recipients 22. Change Settings Before Formatting a Message 23. Choosing the Cryptographic Key of the Recipient 24. Dynamically Changing $index_format using Patterns 25. Adding Key Sequences to the Keyboard Buffer 26. Executing Functions 27. Message Scoring 28. Spam Detection 29. Setting and Querying Variables 29.1. Variable Types 29.2. Commands 29.3. User-Defined Variables 29.4. Type Conversions 30. Reading Initialization Commands From Another File 31. Removing Hooks 32. Format Strings 32.1. Basic usage 32.2. Conditionals 32.3. Filters 32.4. Padding 32.5. Bytes size display 33. Control allowed header fields in a mailto: URL 4. Advanced Usage 1. Character Set Handling 2. Regular Expressions 3. Patterns: Searching, Limiting and Tagging 3.1. Pattern Modifier 3.2. Simple Searches 3.3. Nesting and Boolean Operators 3.4. Searching by Date 4. Marking Messages 5. Using Tags 6. Using Hooks 6.1. Message Matching in Hooks 6.2. Mailbox Matching in Hooks 7. Managing the Environment 8. External Address Queries 9. Mailbox Formats 10. Mailbox Shortcuts 11. Handling Mailing Lists 12. Display Munging 13. New Mail Detection 13.1. How New Mail Detection Works 13.2. Polling For New Mail 13.3. Monitoring New Mail 13.4. Calculating Mailbox Message Counts 14. Editing Threads 14.1. Linking Threads 14.2. Breaking Threads 15. Delivery Status Notification (DSN) Support 16. Start a WWW Browser on URLs 17. Echoing Text 18. Message Composition Flow 19. Batch Composition Flow 20. Using MuttLisp (EXPERIMENTAL) 20.1. Running a command generated by MuttLisp 20.2. Interpolating MuttLisp in a Command Argument 20.3. MuttLisp Syntax 20.4. MuttLisp Functions 20.5. Examples 21. Miscellany 5. Mutt's MIME Support 1. Using MIME in Mutt 1.1. MIME Overview 1.2. Viewing MIME Messages in the Pager 1.3. The Attachment Menu 1.4. The Compose Menu 2. MIME Type Configuration with mime.types 3. MIME Viewer Configuration with Mailcap 3.1. The Basics of the Mailcap File 3.2. Secure Use of Mailcap 3.3. Advanced Mailcap Usage 3.4. Example Mailcap Files 4. MIME Autoview 5. MIME Multipart/Alternative 6. Attachment Searching and Counting 7. MIME Lookup 6. Optional Features 1. General Notes 1.1. Enabling/Disabling Features 1.2. URL Syntax 2. SSL/TLS Support 2.1. STARTTLS 2.2. Tunnel 3. POP3 Support 4. IMAP Support 4.1. The IMAP Folder Browser 4.2. Authentication 5. SMTP Support 6. OAUTHBEARER Support 6.1. XOAUTH2 Support 7. Managing Multiple Accounts 8. Local Caching 8.1. Header Caching 8.2. Body Caching 8.3. Cache Directories 8.4. Maintenance 9. Exact Address Generation 10. Sending Anonymous Messages via Mixmaster 11. Sidebar 11.1. Introduction 11.2. Variables 11.3. Functions 11.4. Commands 11.5. Colors 11.6. Sort 11.7. See Also 12. Compressed Folders Feature 12.1. Introduction 12.2. Commands 13. Autocrypt 13.1. Requirements 13.2. First Run 13.3. Compose Menu 13.4. Account Management 13.5. Alternative Key and Keyring Strategies 7. Security Considerations 1. Passwords 2. Temporary Files 3. Information Leaks 3.1. mailto:-style Links 4. External Applications 8. Performance Tuning 1. Reading and Writing Mailboxes 2. Reading Messages from Remote Folders 3. Searching and Limiting 9. Reference 1. Command-Line Options 2. Configuration Commands 3. Configuration Variables 4. Functions 4.1. Generic Menu 4.2. Index Menu 4.3. Pager Menu 4.4. Alias Menu 4.5. Query Menu 4.6. Attachment Menu 4.7. Compose Menu 4.8. Postpone Menu 4.9. Browser Menu 4.10. Pgp Menu 4.11. Smime Menu 4.12. Mixmaster Menu 4.13. Editor Menu 4.14. Autocrypt Account Menu 4.15. List Menu 10. Miscellany 1. Acknowledgements 2. About This Document List_of_Tables 1.1. Typographical conventions for special terms 2.1. Most common navigation keys in entry-based menus 2.2. Most common navigation keys in page-based menus 2.3. Most common line editor keys 2.4. Most common message index keys 2.5. Message status flags 2.6. Message recipient flags 2.7. Most common pager keys 2.8. ANSI escape sequences 2.9. Color sequences 2.10. Most common thread mode keys 2.11. Special Thread Characters 2.12. Most common mail sending keys 2.13. Most common compose menu keys 2.14. PGP key menu flags 3.1. Symbolic key names 4.1. POSIX regular expression character classes 4.2. Regular expression repetition operators 4.3. GNU regular expression extensions 4.4. Pattern modifiers 4.5. Simple search keywords 4.6. Date units 4.7. Relative date units 4.8. Mailbox shortcuts 5.1. Supported MIME types 6.1. Sidebar Variables 6.2. Sidebar Functions 6.3. Sidebar Colors 6.4. Sidebar Sort 6.5. Not all Hooks are Required 9.1. Command line options 9.2. Default Generic Menu Bindings 9.3. Default Index Menu Bindings 9.4. Default Pager Menu Bindings 9.5. Default Alias Menu Bindings 9.6. Default Query Menu Bindings 9.7. Default Attachment Menu Bindings 9.8. Default Compose Menu Bindings 9.9. Default Postpone Menu Bindings 9.10. Default Browser Menu Bindings 9.11. Default Pgp Menu Bindings 9.12. Default Smime Menu Bindings 9.13. Default Mixmaster Menu Bindings 9.14. Default Editor Menu Bindings 9.15. Default Autocrypt Account Menu Bindings 9.16. Default List Menu Bindings List_of_Examples 3.1. Multiple configuration commands per line 3.2. Commenting configuration files 3.3. Escaping quotes in configuration files 3.4. Splitting long configuration commands over several lines 3.5. Using external command's output in configuration files 3.6. Preventing the output of backticks from being parsed 3.7. Using environment variables in configuration files 3.8. Using MuttLisp expressions 3.9. Configuring external alias files 3.10. Setting sort method based on mailbox name 3.11. Header weeding 3.12. Configuring header display order 3.13. Defining custom headers 3.14. Using %-expandos in save-hook 3.15. Embedding push in folder-hook 3.16. Configuring spam detection 3.17. Using user-defined variables for config file readability 3.18. Using user-defined variables for backing up other config option values 3.19. Deferring user-defined variable expansion to runtime 3.20. Type conversions using variables 3.21. Using external filters in format strings 4.1. Matching all addresses in address lists 4.2. Matching restricted to aliases 4.3. Matching any defined alias 4.4. Using boolean operators in patterns 4.5. Specifying a "default" hook 4.6. Subject Munging 5.1. mime.types 5.2. Attachment counting 6.1. URLs 6.2. Managing multiple accounts 6.3. Example of open-hook 6.4. Example of close-hook 6.5. Example of append-hook Chapter 1. Introduction Table_of_Contents 1. Mutt Home Page 2. Mailing Lists 3. Getting Mutt 4. Mutt Online Resources 5. Contributing to Mutt 6. Typographical Conventions 7. Copyright Mutt is a small but very powerful text-based MIME mail client. Mutt is highly configurable, and is well suited to the mail power user with advanced features like key bindings, keyboard macros, mail threading, regular expression searches and a powerful pattern matching language for selecting groups of messages. 1. Mutt Home Page The official homepage can be found at http://www.mutt.org/. 2. Mailing Lists To subscribe to one of the following mailing lists, send a message with the word subscribe in the body to list-name-request@mutt.org. * -- low traffic list for announcements * -- help, bug reports and feature requests * -- development mailing list All messages posted to mutt-announce are automatically forwarded to mutt-users, so you do not need to be subscribed to both lists. 3. Getting Mutt Mutt releases can be downloaded from ftp://ftp.mutt.org/pub/mutt/. For a list of mirror sites, please refer to http://www.mutt.org/download.html. For version control access, please refer to the Mutt development site. 4. Mutt Online Resources Bug Tracking System The official Mutt bug tracking system can be found at https://gitlab.com/muttmua/mutt/issues Wiki An (unofficial) wiki can be found at https://gitlab.com/muttmua/mutt/wikis/home. IRC For the IRC user community, visit channel #mutt on irc.libera.chat. USENET For USENET, see the newsgroup comp.mail.mutt. 5. Contributing to Mutt There are various ways to contribute to the Mutt project. Especially for new users it may be helpful to meet other new and experienced users to chat about Mutt, talk about problems and share tricks. Since translations of Mutt into other languages are highly appreciated, the Mutt developers always look for skilled translators that help improve and continue to maintain stale translations. For contributing code patches for new features and bug fixes, please refer to the developer pages at https://gitlab.com/muttmua/mutt for more details. 6. Typographical Conventions This section lists typographical conventions followed throughout this manual. See table Table 1.1, "Typographical conventions for special terms" for typographical conventions for special terms. Table_1.1._Typographical_conventions_for_special_terms Item Refers to... printf(3) UNIX manual pages, execute man 3 printf named keys named Mutt function ^G Control+G key combination $mail_check Mutt configuration option $HOME environment variable Examples are presented as: mutt -v Within command synopsis, curly brackets ("{}") denote a set of options of which one is mandatory, square brackets ("[]") denote optional arguments, three dots denote that the argument may be repeated arbitrary times. 7. Copyright Mutt is Copyright (c) 1996-2023 Michael R. Elkins and others. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chapter 2. Getting Started Table_of_Contents 1. Core Concepts 2. Screens and Menus 2.1. Index 2.2. Pager 2.3. File Browser 2.4. Sidebar 2.5. Help 2.6. Compose Menu 2.7. Alias Menu 2.8. Attachment Menu 2.9. List Menu 3. Moving Around in Menus 4. Editing Input Fields 4.1. Introduction 4.2. History 5. Reading Mail 5.1. The Message Index 5.2. The Pager 5.3. Threaded Mode 5.4. Miscellaneous Functions 6. Sending Mail 6.1. Introduction 6.2. Editing the Message Header 6.3. Sending Cryptographically Signed/Encrypted Messages 6.4. Sending Format=Flowed Messages 6.5. Background Editing 7. Forwarding and Bouncing Mail 8. Postponing Mail 9. Encryption and Signing 9.1. OpenPGP Configuration 9.2. S/MIME Configuration This section is intended as a brief overview of how to use Mutt. There are many other features which are described elsewhere in the manual. There is even more information available in the Mutt FAQ and various web pages. See the Mutt homepage for more details. The keybindings described in this section are the defaults as distributed. Your local system administrator may have altered the defaults for your site. You can always type "?" in any menu to display the current bindings. The first thing you need to do is invoke Mutt, simply by typing mutt at the command line. There are various command-line options, see either the Mutt man page or the reference. 1. Core Concepts Mutt is a text-based application which interacts with users through different menus which are mostly line-/entry-based or page-based. A line-based menu is the so-called "index" menu (listing all messages of the currently opened folder) or the "alias" menu (allowing you to select recipients from a list). Examples for page-based menus are the "pager" (showing one message at a time) or the "help" menu listing all available key bindings. The user interface consists of a context sensitive help line at the top, the menu's contents followed by a context sensitive status line and finally the command line. The command line is used to display informational and error messages as well as for prompts and for entering interactive commands. Mutt is configured through variables which, if the user wants to permanently use a non-default value, are written to configuration files. Mutt supports a rich config file syntax to make even complex configuration files readable and commentable. Because Mutt allows for customizing almost all key bindings, there are so-called "functions" which can be executed manually (using the command line) or in macros. Macros allow the user to bind a sequence of commands to a single key or a short key sequence instead of repeating a sequence of actions over and over. Many commands (such as saving or copying a message to another folder) can be applied to a single message or a set of messages (so-called "tagged" messages). To help selecting messages, Mutt provides a rich set of message patterns (such as recipients, sender, body contents, date sent/received, etc.) which can be combined into complex expressions using the boolean and and or operations as well as negating. These patterns can also be used to (for example) search for messages or to limit the index to show only matching messages. Mutt supports a "hook" concept which allows the user to execute arbitrary configuration commands and functions in certain situations such as entering a folder, starting a new message or replying to an existing one. These hooks can be used to highly customize Mutt's behavior including managing multiple identities, customizing the display for a folder or even implementing auto-archiving based on a per-folder basis and much more. Besides an interactive mode, Mutt can also be used as a command-line tool to send messages. It also supports a mailx(1)-compatible interface, see Table 9.1, "Command line options" for a complete list of command-line options. 2. Screens and Menus 2.1. Index The index is the screen that you usually see first when you start Mutt. It gives an overview over your emails in the currently opened mailbox. By default, this is your system mailbox. The information you see in the index is a list of emails, each with its number on the left, its flags (new email, important email, email that has been forwarded or replied to, tagged email, ...), the date when email was sent, its sender, the email size, and the subject. Additionally, the index also shows thread hierarchies: when you reply to an email, and the other person replies back, you can see the other person's email in a "sub-tree" below. This is especially useful for personal email between a group of people or when you've subscribed to mailing lists. 2.2. Pager The pager is responsible for showing the email content. On the top of the pager you have an overview over the most important email headers like the sender, the recipient, the subject, and much more information. How much information you actually see depends on your configuration, which we'll describe below. Below the headers, you see the email body which usually contains the message. If the email contains any attachments, you will see more information about them below the email body, or, if the attachments are text files, you can view them directly in the pager. To give the user a good overview, it is possible to configure Mutt to show different things in the pager with different colors. Virtually everything that can be described with a regular expression can be colored, e.g. URLs, email addresses or smileys. 2.3. File Browser The file browser is the interface to the local or remote file system. When selecting a mailbox to open, the browser allows custom sorting of items, limiting the items shown by a regular expression and a freely adjustable format of what to display in which way. It also allows for easy navigation through the file system when selecting file(s) to attach to a message, select multiple files to attach and many more. Some mail systems can nest mail folders inside other mail folders. The normal open entry commands in mutt will open the mail folder and you can't see the sub-folders. If you instead use the function it will go into the directory and not open it as a mail directory. 2.4. Sidebar The Sidebar shows a list of all your mailboxes. The list can be turned on and off, it can be themed and the list style can be configured. 2.5. Help The help screen is meant to offer a quick help to the user. It lists the current configuration of key bindings and their associated commands including a short description, and currently unbound functions that still need to be associated with a key binding (or alternatively, they can be called via the Mutt command prompt). 2.6. Compose Menu The compose menu features a split screen containing the information which really matter before actually sending a message by mail: who gets the message as what (recipients and who gets what kind of copy). Additionally, users may set security options like deciding whether to sign, encrypt or sign and encrypt a message with/for what keys. Also, it's used to attach messages, to re-edit any attachment including the message itself. 2.7. Alias Menu The alias menu is used to help users finding the recipients of messages. For users who need to contact many people, there's no need to remember addresses or names completely because it allows for searching, too. The alias mechanism and thus the alias menu also features grouping several addresses by a shorter nickname, the actual alias, so that users don't have to select each single recipient manually. 2.8. Attachment Menu As will be later discussed in detail, Mutt features a good and stable MIME implementation, that is, it supports sending and receiving messages of arbitrary MIME types. The attachment menu displays a message's structure in detail: what content parts are attached to which parent part (which gives a true tree structure), which type is of what type and what size. Single parts may saved, deleted or modified to offer great and easy access to message's internals. 2.9. List Menu The list menu assists with operations on mailing lists. RFC 2369 defines several interactions with mailing lists and list memberships that can be specified within the email message: subscribe, unsubscribe, contact the list owner, etc. When you invoke the list menu, these interactions are made accessible as menu options. 3. Moving Around in Menus The most important navigation keys common to line- or entry-based menus are shown in Table 2.1, "Most common navigation keys in entry-based menus" and in Table 2.2, "Most common navigation keys in page-based menus" for page-based menus. Table_2.1._Most_common_navigation_keys_in_entry-based_menus Key Function Description j or move to the next entry k or move to the previous entry z or go to the next page Z or go to the previous page = or jump to the first entry * or jump to the last entry q exit the current menu ? list all keybindings for the current menu Table_2.2._Most_common_navigation_keys_in_page-based_menus Key Function Description J or scroll down one line scroll up one line K, or move to the next page - or move the previous page move to the top move to the bottom 4. Editing Input Fields 4.1. Introduction Mutt has a built-in line editor for inputting text, e.g. email addresses or filenames. The keys used to manipulate text input are very similar to those of Emacs. See Table 2.3, "Most common line editor keys" for a full reference of available functions, their default key bindings, and short descriptions. Table_2.3._Most_common_line_editor_keys Key Function Description ^A or move to the start of the line ^B or move back one char Esc B move back one word ^D or delete the char under the cursor ^E or move to the end of the line ^F or move forward one char Esc F move forward one word complete filename, alias, or label ^T complete address with query ^K delete to the end of the line Esc d delete to the end of the word ^W kill the word in front of the cursor ^U delete entire line ^V quote the next typed key recall previous string from history recall next string from history ^R use current input to search history kill the char in front of the cursor Esc u convert word to upper case Esc l convert word to lower case Esc c capitalize the word ^G n/a abort n/a finish editing ^G is the generic "abort" key in Mutt. In addition to the line editor, it can also be used to abort prompts. Generally, typing ^G at a confirmation prompt or line editor should abort the entire action. You can remap the editor functions using the bind command. For example, to make the key delete the character in front of the cursor rather than under, you could use: bind editor backspace 4.2. History Mutt maintains a history for the built-in editor. The number of items is controlled by the $history variable and can be made persistent using an external file specified using $history_file and $save_history. You may cycle through them at an editor prompt by using the and/or commands. Mutt will remember the currently entered text as you cycle through history, and will wrap around to the initial entry line. Mutt maintains several distinct history lists, one for each of the following categories: * .muttrc commands * addresses and aliases * shell commands * filenames * mailboxes * patterns * everything else Mutt automatically filters out consecutively repeated items from the history. If $history_remove_dups is set, all repeated items are removed from the history. It also mimics the behavior of some shells by ignoring items starting with a space. The latter feature can be useful in macros to not clobber the history's valuable entries with unwanted entries. 5. Reading Mail Similar to many other mail clients, there are two modes in which mail is read in Mutt. The first is a list of messages in the mailbox, which is called the "index" menu in Mutt. The second mode is the display of the message contents. This is called the "pager." The next few sections describe the functions provided in each of these modes. 5.1. The Message Index Common keys used to navigate through and manage messages in the index are shown in Table 2.4, "Most common message index keys". How messages are presented in the index menu can be customized using the $index_format variable. Table_2.4._Most_common_message_index_keys Key Description c change to a different mailbox Esc c change to a folder in read-only mode C copy the current message to another mailbox Esc C decode a message and copy it to a folder Esc s decode a message and save it to a folder D delete messages matching a pattern d delete the current message F mark as important l show messages matching a pattern N mark message as new o change the current sort method O reverse sort the mailbox q save changes and exit s save-message T tag messages matching a pattern t toggle the tag on a message Esc t toggle tag on entire message thread U undelete messages matching a pattern u undelete-message v view-attachments x abort changes and exit display-message jump to the next new or unread message @ show the author's full e-mail address $ save changes to mailbox / search Esc / search-reverse ^L clear and redraw the screen ^T untag messages matching a pattern In addition to who sent the message and the subject, a short summary of the disposition of each message is printed beside the message number. Zero or more of the "flags" in Table 2.5, "Message status flags" may appear, some of which can be turned on or off using these functions: and bound by default to "w" and "W" respectively. Furthermore, the flags in Table 2.6, "Message recipient flags" reflect who the message is addressed to. They can be customized with the $to_chars variable. Table_2.5._Message_status_flags Flag Description D message is deleted (is marked for deletion) d message has attachments marked for deletion K contains a PGP public key N message is new O message is old P message is PGP encrypted r message has been replied to S message is signed, and the signature is successfully verified s message is signed ! message is flagged * message is tagged n thread contains new messages (only if collapsed) o thread contains old messages (only if collapsed) Table_2.6._Message_recipient_flags Flag Description + message is to you and you only T message is to you, but also to or CC'ed to others C message is CC'ed to you F message is from you L message is sent to a subscribed mailing list 5.2. The Pager By default, Mutt uses its built-in pager to display the contents of messages (an external pager such as less(1) can be configured, see $pager variable). The pager is very similar to the Unix program less(1) though not nearly as featureful. Table_2.7._Most_common_pager_keys Key Description go down one line display the next page (or next message if at the end of a message) - go back to the previous page n search for next match S skip beyond quoted text T toggle display of quoted text ? show keybindings / regular expression search Esc / backward regular expression search \ toggle highlighting of search matches ^ jump to the top of the message In addition to key bindings in Table 2.7, "Most common pager keys", many of the functions from the index menu are also available in the pager, such as or (this is one advantage over using an external pager to view messages). Also, the internal pager supports a couple other advanced features. For one, it will accept and translate the "standard" nroff sequences for bold and underline. These sequences are a series of either the letter, backspace ("^H"), the letter again for bold or the letter, backspace, "_" for denoting underline. Mutt will attempt to display these in bold and underline respectively if your terminal supports them. If not, you can use the bold and underline color objects to specify a color or mono attribute for them. Additionally, the internal pager supports the ANSI escape sequences for character attributes. Mutt translates them into the correct color and character settings. The sequences Mutt supports are: \e[Ps;Ps;..Ps;m where Ps can be one of the codes shown in Table 2.8, "ANSI escape sequences". Table_2.8._ANSI_escape_sequences Escape code Description 0 All attributes off 1 Bold on 4 Underline on 5 Blink on 7 Reverse video on 3 Foreground color is (see Table 2.9, "Color sequences") 4 Background color is (see Table 2.9, "Color sequences") 38;5; Foreground color is an 8-bit 48;5; Background color is an 8-bit Table_2.9._Color_sequences Color code Color 0 Black 1 Red 2 Green 3 Yellow 4 Blue 5 Magenta 6 Cyan 7 White Mutt uses these attributes for handling text/enriched messages, and they can also be used by an external autoview script for highlighting purposes. Note If you change the colors for your display, for example by changing the color associated with color2 for your xterm, then that color will be used instead of green. Note Note that the search commands in the pager take regular expressions, which are not quite the same as the more complex patterns used by the search command in the index. This is because patterns are used to select messages by criteria whereas the pager already displays a selected message. 5.3. Threaded Mode So-called "threads" provide a hierarchy of messages where replies are linked to their parent message(s). This organizational form is extremely useful in mailing lists where different parts of the discussion diverge. Mutt displays threads as a tree structure. In Mutt, when a mailbox is sorted by threads, there are a few additional functions available in the index and pager modes as shown in Table 2.10, "Most common thread mode keys". Table_2.10._Most_common_thread_mode_keys Key Function Description ^D delete all messages in the current thread ^U undelete all messages in the current thread ^N jump to the start of the next thread ^P jump to the start of the previous thread ^R mark the current thread as read Esc d delete all messages in the current subthread Esc u undelete all messages in the current subthread Esc n jump to the start of the next subthread Esc p jump to the start of the previous subthread Esc r mark the current subthread as read Esc t toggle the tag on the current thread Esc v toggle collapse for the current thread Esc V toggle collapse for all threads P jump to parent message in thread In the index, the subject of threaded children messages will be prepended with thread tree characters. By default, the subject itself will not be duplicated unless $hide_thread_subject is unset. Special characters will be added to the thread tree as detailed in Table 2.11, "Special Thread Characters". Table_2.11._Special_Thread_Characters Character Description Notes & hidden message see $hide_limited and $hide_top_limited ? missing message see $hide_missing and $hide_top_missing * pseudo thread see $strict_threads; not displayed when $narrow_tree is set = duplicate thread see $duplicate_threads; not displayed when $narrow_tree is set Collapsing a thread displays only the first message in the thread and hides the others. This is useful when threads contain so many messages that you can only see a handful of threads on the screen. See %M in $index_format. For example, you could use "%?M?(#%03M)&(%4l)?" in $index_format to optionally display the number of hidden messages if the thread is collapsed. The %??&? syntax is explained in detail in format string conditionals. Technically, every reply should contain a list of its parent messages in the thread tree, but not all do. In these cases, Mutt groups them by subject which can be controlled using the $strict_threads variable. 5.4. Miscellaneous Functions In addition, the index and pager menus have these interesting functions: Calculate statistics for all monitored mailboxes declared using the mailboxes command. It will calculate statistics despite $mail_check_stats being unset. (default: a) Creates a new alias based upon the current message (or prompts for a new one). Once editing is complete, an alias command is added to the file specified by the $alias_file variable for future use Note Mutt does not read the $alias_file upon startup so you must explicitly source the file. (default: Esc P) This function will search the current message for content signed or encrypted with PGP the "traditional" way, that is, without proper MIME tagging. Technically, this function will temporarily change the MIME content types of the body parts containing PGP data; this is similar to the function's effect. (default: e) This command (available in the index and pager) allows you to edit the raw current message as it's present in the mail folder. After you have finished editing, the changed message will be appended to the current folder, and the original message will be marked for deletion; if the message is unchanged it won't be replaced. (default: ^E on the attachment menu, and in the pager and index menus; ^T on the compose menu) This command is used to temporarily edit an attachment's content type to fix, for instance, bogus character set parameters. When invoked from the index or from the pager, you'll have the opportunity to edit the top-level attachment's content type. On the attachment menu, you can change any attachment's content type. These changes are not persistent, and get lost upon changing folders. Note that this command is also available on the compose menu. There, it's used to fine-tune the properties of attachments you are going to send. (default: ":") This command is used to execute any command you would normally put in a configuration file. A common use is to check the settings of variables, or in conjunction with macros to change settings on the fly. (default: ^K) This command extracts PGP public keys from the current or tagged message(s) and adds them to your PGP public key ring. (default: ^F) This command wipes the passphrase(s) from memory. It is useful, if you misspelled the passphrase. (default: L) Reply to the current or tagged message(s) by extracting any addresses which match the regular expressions given by the lists or subscribe commands, but also honor any Mail-Followup-To header(s) if the $honor_followup_to configuration variable is set. In addition, the List-Post header field is examined for mailto: URLs specifying a mailing list address. Using this when replying to messages posted to mailing lists helps avoid duplicate copies being sent to the author of the message you are replying to. (default: |) Asks for an external Unix command and pipes the current or tagged message(s) to it. The variables $pipe_decode, $pipe_decode_weed, $pipe_split, $pipe_sep and $wait_key control the exact behavior of this function. (default: Esc e) Mutt takes the current message as a template for a new message. This function is best described as "recall from arbitrary folders". It can conveniently be used to forward MIME messages while preserving the original mail structure. Note that the amount of headers included here depends on the value of the $weed variable. This function is also available from the attachment menu. You can use this to easily resend a message which was included with a bounce message as a message/rfc822 body part. (default: !) Asks for an external Unix command and executes it. The $wait_key can be used to control whether Mutt will wait for a key to be pressed when the command returns (presumably to let the user read the output of the command), based on the return status of the named command. If no command is given, an interactive shell is executed. (default: H) This function will skip past the headers of the current message. (default: S) This function will go to the next line of non-quoted text which comes after a line of quoted text in the internal pager. (default: T) The pager uses the $quote_regexp variable to detect quoted text when displaying the body of the message. This function toggles the display of the quoted material in the message. It is particularly useful when being interested in just the response and there is a large amount of quoted text in the way. 6. Sending Mail 6.1. Introduction The bindings shown in Table 2.12, "Most common mail sending keys" are available in the index and pager to start a new message. Table_2.12._Most_common_mail_sending_keys Key Function Description m compose a new message r reply to sender g reply to all recipients reply to all recipients preserving To/Cc L reply to mailing list address f forward message b bounce (remail) message Esc k mail a PGP public key to someone Bouncing a message sends the message as-is to the recipient you specify. Forwarding a message allows you to add comments or modify the message you are forwarding. These items are discussed in greater detail in the next section "Forwarding and Bouncing Mail." Mutt will then enter the compose menu and prompt you for the recipients to place on the "To:" header field when you hit m to start a new message. Next, it will ask you for the "Subject:" field for the message, providing a default if you are replying to or forwarding a message. You again have the chance to adjust recipients, subject, and security settings right before actually sending the message. See also $askcc, $askbcc, $autoedit, $bounce, $fast_reply, and $include for changing how and if Mutt asks these questions. When replying, Mutt fills these fields with proper values depending on the reply type. The types of replying supported are: Simple reply Reply to the author directly. Group reply Reply to the author; cc all other recipients; consults alternates and excludes you. Group Chat reply Reply to the author and other recipients in the To list; cc other recipients in the Cc list; consults alternates and excludes you. List reply Reply to all mailing list addresses found, either specified via configuration or auto-detected. See Section 14, "Mailing Lists" for details. After getting recipients for new messages, forwards or replies, Mutt will then automatically start your $editor on the message body. If the $edit_headers variable is set, the headers will be at the top of the message in your editor; the message body should start on a new line after the existing blank line at the end of headers. Any messages you are replying to will be added in sort order to the message, with appropriate $attribution, $indent_string and $post_indent_string. When forwarding a message, if the $mime_forward variable is unset, a copy of the forwarded message will be included. If you have specified a $signature, it will be appended to the message. Once you have finished editing the body of your mail message, you are returned to the compose menu providing the functions shown in Table 2.13, "Most common compose menu keys" to modify, send or postpone the message. Table_2.13._Most_common_compose_menu_keys Key Function Description a attach a file A attach message(s) to the message Esc k attach a PGP public key d edit description on attachment D detach a file t edit the To field Esc f edit the From field r edit the Reply-To field c edit the Cc field b edit the Bcc field y send the message s edit the Subject S select S/MIME options f specify an "Fcc" mailbox p select PGP options P postpone this message until later q quit (abort) sending the message w write the message to a folder i check spelling (if available on your system) ^F wipe passphrase(s) from memory The compose menu is also used to edit the attachments for a message which can be either files or other messages. The function to will prompt you for a folder to attach messages from. You can now tag messages in that folder and they will be attached to the message you are sending. Note Note that certain operations like composing a new mail, replying, forwarding, etc. are not permitted when you are in that folder. The %r in $status_format will change to a "A" to indicate that you are in attach-message mode. After exiting the compose menu via , the message will be sent. If configured and enabled, this can happen via mixmaster or $smtp_url. Otherwise $sendmail will be invoked. Prior to version 1.13, Mutt enabled $write_bcc by default, assuming the MTA would automatically remove a Bcc: header as part of delivery. Starting with 1.13, the option is unset by default, but no longer affects the fcc copy of the message. 6.2. Editing the Message Header When editing the header because of $edit_headers being set, there are a several pseudo headers available which will not be included in sent messages but trigger special Mutt behavior. 6.2.1. Fcc: Pseudo Header If you specify Fcc: filename as a header, Mutt will pick up filename just as if you had used the function in the compose menu. It can later be changed from the compose menu. 6.2.2. Attach: Pseudo Header You can also attach files to your message by specifying Attach: filename [ description ] where filename is the file to attach and description is an optional string to use as the description of the attached file. Spaces in filenames have to be escaped using backslash ("\"). The file can be removed as well as more added from the compose menu. 6.2.3. Pgp: Pseudo Header If you want to use PGP, you can specify Pgp: [ E | S | S ] "E" selects encryption, "S" selects signing and "S" selects signing with the given key, setting $pgp_sign_as for the duration of the message composition session. The selection can later be changed in the compose menu. 6.2.4. In-Reply-To: Header When replying to messages, the In-Reply-To: header contains the Message-Id of the message(s) you reply to. If you remove or modify its value, Mutt will not generate a References: field, which allows you to create a new message thread, for example to create a new message to a mailing list without having to enter the mailing list's address. If you intend to start a new thread by replying, please make really sure you remove the In-Reply-To: header in your editor. Otherwise, though you'll produce a technically valid reply, some netiquette guardians will be annoyed by this so-called "thread hijacking". 6.3. Sending Cryptographically Signed/Encrypted Messages If you have told Mutt to PGP or S/MIME encrypt a message, it will guide you through a key selection process when you try to send the message. Mutt will not ask you any questions about keys which have a certified user ID matching one of the message recipients' mail addresses. However, there may be situations in which there are several keys, weakly certified user ID fields, or where no matching keys can be found. In these cases, you are dropped into a menu with a list of keys from which you can select one. When you quit this menu, or Mutt can't find any matching keys, you are prompted for a user ID. You can, as usually, abort this prompt using ^G. When you do so, Mutt will return to the compose screen. Once you have successfully finished the key selection, the message will be encrypted using the selected public keys when sent out. To ensure you can view encrypted messages you have sent, you may wish to set $pgp_self_encrypt and $pgp_default_key for PGP, or $smime_self_encrypt and $smime_default_key for S/MIME. Most fields of the entries in the key selection menu (see also $pgp_entry_format) have obvious meanings. But some explanations on the capabilities, flags, and validity fields are in order. The flags sequence ("%f") will expand to one of the flags in Table 2.14, "PGP key menu flags". Table_2.14._PGP_key_menu_flags Flag Description R The key has been revoked and can't be used. X The key is expired and can't be used. d You have marked the key as disabled. c There are unknown critical self-signature packets. The capabilities field ("%c") expands to a two-character sequence representing a key's capabilities. The first character gives the key's encryption capabilities: A minus sign ("-") means that the key cannot be used for encryption. A dot (".") means that it's marked as a signature key in one of the user IDs, but may also be used for encryption. The letter "e" indicates that this key can be used for encryption. The second character indicates the key's signing capabilities. Once again, a "-" implies "not for signing", "." implies that the key is marked as an encryption key in one of the user-ids, and "s" denotes a key which can be used for signing. Finally, the validity field ("%t") indicates how well-certified a user-id is. A question mark ("?") indicates undefined validity, a minus character ("-") marks an untrusted association, a space character means a partially trusted association, and a plus character ("+") indicates complete validity. 6.4. Sending Format=Flowed Messages 6.4.1. Concept format=flowed-style messages (or f=f for short) are text/plain messages that consist of paragraphs which a receiver's mail client may reformat to its own needs which mostly means to customize line lengths regardless of what the sender sent. Technically this is achieved by letting lines of a "flowable" paragraph end in spaces except for the last line. While for text-mode clients like Mutt it's the best way to assume only a standard 80x25 character cell terminal, it may be desired to let the receiver decide completely how to view a message. 6.4.2. Mutt Support Mutt only supports setting the required format=flowed MIME parameter on outgoing messages if the $text_flowed variable is set, specifically it does not add the trailing spaces. After editing, Mutt properly space-stuffs the message. Space-stuffing is required by RfC3676 defining format=flowed and means to prepend a space to: * all lines starting with a space * lines starting with the word "From" followed by space * all lines starting with ">" which is not intended to be a quote character Note Mutt only supports space-stuffing for the first two types of lines but not for the third: It is impossible to safely detect whether a leading > character starts a quote or not. All leading spaces are to be removed by receiving clients to restore the original message prior to further processing. 6.4.3. Editor Considerations As Mutt provides no additional features to compose f=f messages, it's completely up to the user and his editor to produce proper messages. Please consider your editor's documentation if you intend to send f=f messages. For example, vim provides the w flag for its formatoptions setting to assist in creating f=f messages, see :help fo-table for details. 6.4.4. Reformatting Mutt has some support for reformatting when viewing and replying to format=flowed messages. In order to take advantage of these, $reflow_text must be set. * Paragraphs are automatically reflowed and wrapped at a width specified by $reflow_wrap. * In its original format, the quoting style of format=flowed messages can be difficult to read, and doesn't intermix well with non-flowed replies. Setting $reflow_space_quotes adds spaces after each level of quoting when in the pager and replying in a non-flowed format (i.e. with $text_flowed unset). * If $reflow_space_quotes is unset, mutt will still add one trailing space after all the quotes in the pager (but not when replying). 6.5. Background Editing If $editor is set to a graphical editor, or a script such as contrib/bgedit-screen-tmux.sh if running inside GNU Screen or tmux, you can run the editor in the background by setting $background_edit. If set, Mutt will display a landing page while the editor runs. When the editor exits, message composition will resume automatically. Alternatively, you can from the landing page, which will return you to the message index. This allows viewing other messages, changing mailboxes, even starting a new message composition session - all while the first editor session is still running. Backgrounded message composition sessions can be viewed via in the index and pager, by default bound to "B". If there is only a single backgrounded session, which has already exited, that session will automatically resume. Otherwise the list will be displayed, and a particular session can be selected. $background_format controls the format string used for the menu. In case the open mailbox is changed while a reply is backgrounded, Mutt keeps track of the original mailbox. After sending, Mutt will attempt to reopen the original mailbox, if needed, and set reply flags appropriately. This won't affect your currently open mailbox, but may make setting flags a bit slower due to the need to reopen the original mailbox behind the scenes. One complication with backgrounded compose sessions is the config changes caused by send, reply, and folder hooks. These can get triggered by a new message composition session, or by changing folders during a backgrounded session. To help lessen these problems, Mutt takes a snapshot of certain configuration variables and stores them with each editing session when it is backgrounded. When the session is resumed, those stored settings will temporarily be restored, and removed again when the session finishes (or is backgrounded again). Mutt will save all boolean and quadoption configuration variables, the current folder (which will be used for ^ mailbox shortcut expansion), along with: $folder, $record, $postponed, $envelope_from_address, $from, $sendmail, $smtp_url, $pgp_sign_as, $smime_sign_as, and $smime_encrypt_with. It's not feasible to backup all variables, but if you believe we've missed an important setting, please let the developers know. To help prevent forgetting about backgrounded sessions, $background_confirm_quit will prompt before exiting, in addition to $quit. Additionally, the %B expando in $status_format displays the number of backgrounded compose sessions. Background editing is available for most, but not all, message composition in Mutt. Sending from the command line disables background editing, because there is no index to return to. 7. Forwarding and Bouncing Mail Bouncing and forwarding let you send an existing message to recipients that you specify. Bouncing a message sends a verbatim copy of a message to alternative addresses as if they were the message's original recipients specified in the Bcc header. Forwarding a message, on the other hand, allows you to modify the message before it is resent (for example, by adding your own comments). Bouncing is done using the function and forwarding using the function bound to "b" and "f" respectively. Forwarding can be done by including the original message in the new message's body (surrounded by indicating lines: see $forward_attribution_intro and $forward_attribution_trailer) or including it as a MIME attachment, depending on the value of the $mime_forward variable. Decoding of attachments, like in the pager, can be controlled by the $forward_decode and $mime_forward_decode variables, respectively. The desired forwarding format may depend on the content, therefore $mime_forward is a quadoption which, for example, can be set to "ask-no". Mutt's default ($mime_forward="no" and $forward_decode="yes") is to use standard inline forwarding. In that mode all text-decodable parts are included in the new message body. Other attachments from the original email can also be attached to the new message, based on the quadoption $forward_attachments. The inclusion of headers is controlled by the current setting of the $weed variable, unless $mime_forward is set. The subject of the email is controlled by $forward_format. Editing the message to forward follows the same procedure as sending or replying to a message does, but can be disabled via the quadoption $forward_edit. 8. Postponing Mail At times it is desirable to delay sending a message that you have already begun to compose. When the function is used in the compose menu, the body of your message and attachments are stored in the mailbox specified by the $postponed variable. This means that you can recall the message even if you exit Mutt and then restart it at a later time. Once a message is postponed, there are several ways to resume it. From the command line you can use the "-p" option, or if you compose a new message from the index or pager you will be prompted if postponed messages exist. If multiple messages are currently postponed, the postponed menu will pop up and you can select which message you would like to resume. Note If you postpone a reply to a message, the reply setting of the message is only updated when you actually finish the message and send it. Also, you must be in the same folder with the message you replied to for the status of the message to be updated. See also the $postpone quad-option. 9. Encryption and Signing Mutt supports encrypting and signing emails when used interactively. In batch mode, cryptographic operations are disabled, so these options can't be used to sign an email sent via a cron job, for instance. OpenPGP and S/MIME are enabled in one of two ways: "classic mode" or GPGME. The former invokes external programs to perform the various operations; it is better tested and more flexible, but requires some configuration. The latter uses the GnuPG project's GPGME library. To enable "classic mode", ensure GPGME is disabled and use the gpg.rc or smime.rc files that come with mutt. These are typically installed under /usr/local/share/doc/mutt/samples/. Source them, either directly or by copying them to your .mutt directory and sourcing them. Sourcing them directly from /usr/local/share/doc/mutt/samples/ has the benefit of automatically using fixes and security improvements to the command invocations, and is recommended. unset crypt_use_gpgme source /usr/local/share/doc/mutt/samples/gpg.rc source /usr/local/share/doc/mutt/samples/smime.rc To use GPGME instead, simply ensure the option is enabled in your .muttrc: set crypt_use_gpgme 9.1. OpenPGP Configuration The two most important settings are $pgp_default_key and $pgp_sign_as. To perform encryption, you must set the first variable. If you have a separate signing key, or only have a signing key, then set the second. Most people will only need to set $pgp_default_key. Starting with version 2.1.0, GnuPG automatically uses an agent to prompt for your passphrase. If you are using a version older than that, you'll need to ensure an agent is running (alternatively, you can unset $pgp_use_gpg_agent and Mutt will prompt you for your passphrase). The agent in turn uses a pinentry program to display the prompt. There are many different kinds of pinentry programs that can be used: qt, gtk2, gnome3, fltk, and curses. However, Mutt does not work properly with the tty pinentry program. Please ensure you have one of the GUI or curses pinentry programs installed and configured to be the default for your system. 9.2. S/MIME Configuration As with OpenPGP, the two most important settings are $smime_default_key and $smime_sign_as. To perform encryption and decryption, you must set the first variable. If you have a separate signing key, or only have a signing key, then set the second. Most people will only need to set $smime_default_key. In "classic mode", keys and certificates are managed by the smime_keys program that comes with Mutt. By default they are stored under ~/.smime/. (This is set by the smime.rc file with $smime_certificates and $smime_keys.) To initialize this directory, use the command "smime_keys init" from a shell prompt. The program can be then be used to import and list certificates. You may also want to periodically run "smime_keys refresh" to update status flags for your certificates. Chapter 3. Configuration Table_of_Contents 1. Location of Initialization Files 2. Starter Muttrc 3. Syntax of Initialization Files 4. Address Groups 5. Defining/Using Aliases 6. Changing the Default Key Bindings 6.1. Terminal Keybindings 6.2. Enter versus Return 7. Changing the current working directory 8. Defining Aliases for Character Sets 9. Setting Variables Based Upon Mailbox 10. Keyboard Macros 11. Using Color and Mono Video Attributes 12. Message Header Display 12.1. Header Display 12.2. Selecting Headers 12.3. Ordering Displayed Headers 13. Alternative Addresses 14. Mailing Lists 15. Using Multiple Spool Mailboxes 16. Monitoring Incoming Mail 17. User-Defined Headers 18. Specify Default Save Mailbox 19. Specify Default Fcc: Mailbox When Composing 20. Specify Default Save Filename and Default Fcc: Mailbox at Once 21. Change Settings Based Upon Message Recipients 22. Change Settings Before Formatting a Message 23. Choosing the Cryptographic Key of the Recipient 24. Dynamically Changing $index_format using Patterns 25. Adding Key Sequences to the Keyboard Buffer 26. Executing Functions 27. Message Scoring 28. Spam Detection 29. Setting and Querying Variables 29.1. Variable Types 29.2. Commands 29.3. User-Defined Variables 29.4. Type Conversions 30. Reading Initialization Commands From Another File 31. Removing Hooks 32. Format Strings 32.1. Basic usage 32.2. Conditionals 32.3. Filters 32.4. Padding 32.5. Bytes size display 33. Control allowed header fields in a mailto: URL 1. Location of Initialization Files While the default configuration (or "preferences") make Mutt usable right out of the box, it is often desirable to tailor Mutt to suit your own tastes. When Mutt is first invoked, it will attempt to read the "system" configuration file (defaults set by your local system administrator), unless the "-n" command line option is specified. This file is typically /usr/local/share/mutt/Muttrc or /etc/Muttrc. Mutt will next look for a file named .muttrc in your home directory. If this file does not exist and your home directory has a subdirectory named .mutt, Mutt tries to load a file named .mutt/muttrc. If still not found, Mutt will try $XDG_CONFIG_HOME/mutt/muttrc. .muttrc is the file where you will usually place your commands to configure Mutt. In addition, Mutt supports version specific configuration files that are parsed instead of the default files as explained above. For instance, if your system has a Muttrc-0.88 file in the system configuration directory, and you are running version 0.88 of Mutt, this file will be sourced instead of the Muttrc file. The same is true of the user configuration file, if you have a file .muttrc-0.88.6 in your home directory, when you run Mutt version 0.88.6, it will source this file instead of the default .muttrc file. The version number is the same which is visible using the "-v" command line switch or using the show-version key (default: V) from the index menu. 2. Starter Muttrc Mutt is highly configurable because it's meant to be customized to your needs and preferences. However, this configurability can make it difficult when just getting started. A few sample muttrc files come with mutt, under doc/mutt/samples/. Among them, sample.muttrc-starter is a basic example config with a few suggested settings and pointers to useful programs. 3. Syntax of Initialization Files An initialization file consists of a series of commands. Each line of the file may contain one or more commands. When multiple commands are used, they must be separated by a semicolon (";"). Example_3.1._Multiple_configuration_commands_per_line set realname='Mutt user' ; ignore x- The hash mark, or pound sign ("#"), is used as a "comment" character. You can use it to annotate your initialization file. All text after the comment character to the end of the line is ignored. Example_3.2._Commenting_configuration_files my_hdr X-Disclaimer: Why are you listening to me? # This is a comment Single quotes ("'") and double quotes (""") can be used to quote strings which contain spaces or other special characters. The difference between the two types of quotes is similar to that of many popular shell programs, namely that a single quote is used to specify a literal string (one that is not interpreted for shell variables or quoting with a backslash [see next paragraph]), while double quotes indicate a string for which should be evaluated. For example, backticks are evaluated inside of double quotes, but not for single quotes. "\" quotes the next character, just as in shells such as bash and zsh. For example, if want to put quotes """ inside of a string, you can use "\" to force the next character to be a literal instead of interpreted character. Example_3.3._Escaping_quotes_in_configuration_files set realname="Michael \"MuttDude\" Elkins" "\\" means to insert a literal "\" into the line. "\n" and "\r" have their usual C meanings of linefeed and carriage-return, respectively. A "\" at the end of a line can be used to split commands over multiple lines as it "escapes" the line end, provided that the split points don't appear in the middle of command names. Lines are first concatenated before interpretation so that a multi-line can be commented by commenting out the first line only. Example_3.4._Splitting_long_configuration_commands_over_several_lines set status_format="some very \ long value split \ over several lines" It is also possible to substitute the output of a Unix command in an initialization file. This is accomplished by enclosing the command in backticks (``). In Example 3.5, "Using external command's output in configuration files", the output of the Unix command "uname -a" will be substituted before the line is parsed. Since initialization files are line oriented, only the first line of output from the Unix command will be substituted. Example_3.5._Using_external_command's_output_in_configuration_files my_hdr X-Operating-System: `uname -a` To avoid the output of backticks being parsed, place them inside double quotes. In Example 3.6, "Preventing the output of backticks from being parsed", the output of the gpg decryption is assigned directly to $imap_pass, so that special characters in the password (e.g."'", "#", "$") are not parsed and interpreted specially by mutt. Example_3.6._Preventing_the_output_of_backticks_from_being_parsed set imap_pass="`gpg --batch -q --decrypt ~/.mutt/account.gpg`" Both environment variables and Mutt variables can be accessed by prepending "$" to the name of the variable. For example, Example_3.7._Using_environment_variables_in_configuration_files set record=+sent_on_$HOSTNAME will cause Mutt to save outgoing messages to a folder named "sent_on_kremvax" if the environment variable $HOSTNAME is set to "kremvax." (See $record for details.) Mutt expands the variable when it is assigned, not when it is used. If the value of a variable on the right-hand side of an assignment changes after the assignment, the variable on the left-hand side will not be affected. If $muttlisp_inline_eval is set, an unquoted parenthesis-enclosed expression will be evaluated as MuttLisp. See the Using MuttLisp section for more details. Example_3.8._Using_MuttLisp_expressions set signature = \ (if (equal $my_name "Kevin McCarthy") ~/kevin.sig ~/other.sig) The commands understood by Mutt are explained in the next paragraphs. For a complete list, see the command reference. All configuration files are expected to be in the current locale as specified by the $charset variable which doesn't have a default value since it's determined by Mutt at startup. If a configuration file is not encoded in the same character set the $config_charset variable should be used: all lines starting with the next are recoded from $config_charset to $charset. This mechanism should be avoided if possible as it has the following implications: * These variables should be set early in a configuration file with $charset preceding $config_charset so Mutt knows what character set to convert to. * If $config_charset is set, it should be set in each configuration file because the value is global and not per configuration file. * Because Mutt first recodes a line before it attempts to parse it, a conversion introducing question marks or other characters as part of errors (unconvertable characters, transliteration) may introduce syntax errors or silently change the meaning of certain tokens (e.g. inserting question marks into regular expressions). 4. Address Groups Usage: group [ -group name ...] { -rx expr ... | -addr expr ... } ungroup [ -group name ...] { * | -rx expr ... | -addr expr ... } Mutt supports grouping addresses logically into named groups. An address or address pattern can appear in several groups at the same time. These groups can be used in patterns (for searching, limiting and tagging) and in hooks by using group patterns. This can be useful to classify mail and take certain actions depending on in what groups the message is. For example, the mutt user's mailing list would fit into the categories "mailing list" and "mutt-related". Using send-hook, the sender can be set to a dedicated one for writing mailing list messages, and the signature could be set to a mutt-related one for writing to a mutt list -- for other lists, the list sender setting still applies but a different signature can be selected. Or, given a group only containing recipients known to accept encrypted mail, "auto-encryption" can be achieved easily. The group command is used to directly add either addresses or regular expressions to the specified group or groups. The different categories of arguments to the group command can be in any order. The flags -rx and -addr specify what the following strings (that cannot begin with a hyphen) should be interpreted as: either a regular expression or an email address, respectively. These address groups can also be created implicitly by the alias, lists, subscribe and alternates commands by specifying the optional -group option. For example, alternates -group me address1 address2 alternates -group me -group work address3 would create a group named "me" which contains all your addresses and a group named "work" which contains only your work address address3. Besides many other possibilities, this could be used to automatically mark your own messages in a mailing list folder as read or use a special signature for work-related messages. The ungroup command is used to remove addresses or regular expressions from the specified group or groups. The syntax is similar to the group command, however the special character * can be used to empty a group of all of its contents. As soon as a group gets empty because all addresses and regular expressions have been removed, it'll internally be removed, too (i.e. there cannot be an empty group). When removing regular expressions from a group, the pattern must be specified exactly as given to the group command or -group argument. 5. Defining/Using Aliases Usage: alias [ -group name ...] key address [ address ...] unalias [ -group name ...] { * | key ... } It's usually very cumbersome to remember or type out the address of someone you are communicating with. Mutt allows you to create "aliases" which map a short string to a full address. Note If you want to create an alias for more than one address, you must separate the addresses with a comma (","). The optional -group argument to alias causes the aliased address(es) to be added to the named group. To add an alias: alias muttdude me@cs.hmc.edu (Michael Elkins) alias theguys manny, moe, jack To remove an alias or aliases ("*" means all aliases): unalias muttdude unalias * Note: The alias key is matched case insensitively when creating (checking for duplicates), removing, or expanding aliases. Unlike other mailers, Mutt doesn't require aliases to be defined in a special file. The alias command can appear anywhere in a configuration file, as long as this file is sourced. Consequently, you can have multiple alias files, or you can have all aliases defined in your .muttrc. On the other hand, the function can use only one file, the one pointed to by the $alias_file variable (which is ~/.muttrc by default). This file is not special either, in the sense that Mutt will happily append aliases to any file, but in order for the new aliases to take effect you need to explicitly source this file too. Example_3.9._Configuring_external_alias_files source /usr/local/share/Mutt.aliases source ~/.mail_aliases set alias_file=~/.mail_aliases To use aliases, you merely use the alias at any place in Mutt where Mutt prompts for addresses, such as the To: or Cc: prompt. You can also enter aliases in your editor at the appropriate headers if you have the $edit_headers variable set. In addition, at the various address prompts, you can use the tab character to expand a partial alias to the full alias. If there are multiple matches, Mutt will bring up a menu with the matching aliases. In order to be presented with the full list of aliases, you must hit tab without a partial alias, such as at the beginning of the prompt or after a comma denoting multiple addresses. In the alias menu, you can select as many aliases as you want with the tag-entry key (default: or t), and use the exit key (default: q) to return to the address prompt. 6. Changing the Default Key Bindings Usage: bind map key function This command allows you to change the default key bindings (operation invoked when pressing a key). map specifies in which menu the binding belongs. Multiple maps may be specified by separating them with commas (no additional whitespace is allowed). The currently defined maps are: generic This is not a real menu, but is used as a fallback for all of the other menus except for the pager and editor modes. If a key is not defined in another menu, Mutt will look for a binding to use in this menu. This allows you to bind a key to a certain function in multiple menus instead of having multiple bind statements to accomplish the same task. alias The alias menu is the list of your personal aliases as defined in your .muttrc. It is the mapping from a short alias name to the full email address(es) of the recipient(s). attach The attachment menu is used to access the attachments on received messages. browser The browser is used for both browsing the local directory structure, and for listing all of your incoming mailboxes. editor The editor is used to allow the user to enter a single line of text, such as the To or Subject prompts in the compose menu. index The index is the list of messages contained in a mailbox. compose The compose menu is the screen used when sending a new message. pager The pager is the mode used to display message/attachment data, and help listings. pgp The pgp menu is used to select the OpenPGP keys used to encrypt outgoing messages. smime The smime menu is used to select the OpenSSL certificates used to encrypt outgoing messages. postpone The postpone menu is similar to the index menu, except is used when recalling a message the user was composing, but saved until later. query The query menu is the browser for results returned by $query_command. mix The mixmaster screen is used to select remailer options for outgoing messages (if Mutt is compiled with Mixmaster support). key is the key (or key sequence) you wish to bind. To specify a control character, use the sequence \Cx, where x is the letter of the control character (for example, to specify control-A use "\Ca"). Note that the case of x as well as \C is ignored, so that \CA, \Ca, \cA and \ca are all equivalent. An alternative form is to specify the key as a three digit octal number prefixed with a "\" (for example \177 is equivalent to \c?). You can also use the form <177>, which allows octal numbers with an arbitrary number of digits. In addition, key may be a symbolic name as shown in Table 3.1, "Symbolic key names". Table_3.1._Symbolic_key_names Symbolic name Meaning \t tab tab backtab / shift-tab \r carriage return \n newline \e escape escape up arrow down arrow left arrow right arrow Page Up Page Down Backspace Delete Insert Enter Return Enter key on numeric keypad Home End Space bar function key 1 function key 10 The function can be used to explore keycode and symbolic names for other keys on your keyboard. Executing this function will display information about each key pressed, until terminated by ^G. key does not need to be enclosed in quotes unless it contains a space (" ") or semi-colon (";"). function specifies which action to take when key is pressed. For a complete list of functions, see the reference. Note that the bind expects function to be specified without angle brackets. The special function unbinds the specified key sequence. 6.1. Terminal Keybindings Some key bindings are controlled by the terminal, and so by default can't be bound inside Mutt. These may include ^C, ^\, ^Q, ^S, ^Z, and on BSD/Mac ^Y. These terminal settings can be viewed and changed using the stty program. "stty -a" will list the bound characters (not all of them affect Mutt), and what actions they take when pressed. For example, you may see "intr = ^C" in its output. This means typing ^C will send an interrupt signal. "quit = ^\" means typing ^\ (commonly also ^4) will send a quit signal. To unbind a key from an action, you invoke "stty action undef". For example, "stty quit undef" will unbind ^\ (and ^4) from sending the quit signal. Once unbound (e.g, by placing that line in your .bashrc, or in a Mutt wrapper script/function) you can use the key sequence in your Mutt bindings. 6.2. Enter versus Return Prior to version 2.2, Mutt used a default ncurses mode ("nl()"). This mode maps keyboard input of either or to the same value, which Mutt interpreted as internally. However, starting in version 2.2, this mode is turned off, allowing and to be mapped separately, if desired. The default keyboard mappings set both, but you can override this or create new bindings with one or the other (or both). Note that in terminal application, such as Mutt, is the same as "\n" and ^J; while is the same as "\r" and ^M. 7. Changing the current working directory Usage: cd directory The cd command changes Mutt's current working directory. This affects commands and functions like source, change-folder, and save-entry that use relative paths. Using cd without directory changes to your home directory. 8. Defining Aliases for Character Sets Usage: charset-hook alias charset iconv-hook charset local-charset The charset-hook command defines an alias for a character set. This is useful to properly display messages which are tagged with a character set name not known to Mutt. The iconv-hook command defines a system-specific name for a character set. This is helpful when your systems character conversion library insists on using strange, system-specific names for character sets. 9. Setting Variables Based Upon Mailbox Usage: folder-hook [!]regexp command It is often desirable to change settings based on which mailbox you are reading. The folder-hook command provides a method by which you can execute any configuration command. regexp is a regular expression specifying in which mailboxes to execute command before loading. If a mailbox matches multiple folder-hooks, they are executed in the order given in the .muttrc. The regexp parameter has mailbox shortcut expansion performed on the first character. See Mailbox Matching in Hooks for more details. Note If you use the "!" shortcut for $spoolfile at the beginning of the pattern, you must place it inside of double or single quotes in order to distinguish it from the logical not operator for the expression. Note Settings are not restored when you leave the mailbox. For example, a command action to perform is to change the sorting method based upon the mailbox being read: folder-hook mutt "set sort=threads" However, the sorting method is not restored to its previous value when reading a different mailbox. To specify a default command, use the pattern "." before other folder-hooks adjusting a value on a per-folder basis because folder-hooks are evaluated in the order given in the configuration file. Note The keyboard buffer will not be processed until after all hooks are run; multiple push or exec commands will end up being processed in reverse order. The following example will set the sort variable to date-sent for all folders but to threads for all folders containing "mutt" in their name. Example_3.10._Setting_sort_method_based_on_mailbox_name folder-hook . "set sort=date-sent" folder-hook mutt "set sort=threads" 10. Keyboard Macros Usage: macro menu key sequence [ description ] Macros are useful when you would like a single key to perform a series of actions. When you press key in menu menu, Mutt will behave as if you had typed sequence. So if you have a common sequence of commands you type, you can create a macro to execute those commands with a single key or fewer keys. menu is the map which the macro will be bound in. Multiple maps may be specified by separating multiple menu arguments by commas. Whitespace may not be used in between the menu arguments and the commas separating them. key and sequence are expanded by the same rules as the key bindings with some additions. The first is that control characters in sequence can also be specified as ^x. In order to get a caret ("^") you need to use ^^. Secondly, to specify a certain key such as up or to invoke a function directly, you can use the format and . For a listing of key names see the section on key bindings. Functions are listed in the reference. The advantage with using function names directly is that the macros will work regardless of the current key bindings, so they are not dependent on the user having particular key definitions. This makes them more robust and portable, and also facilitates defining of macros in files used by more than one user (e.g., the system Muttrc). Optionally you can specify a descriptive text after sequence, which is shown in the help screens if they contain a description. Note Macro definitions (if any) listed in the help screen(s), are silently truncated at the screen width, and are not wrapped. 11. Using Color and Mono Video Attributes Usage: color object [ attribute ...] foreground background color { header | body } [ attribute ...] foreground background regexp color index [ attribute ...] foreground background pattern color compose composeobject [ attribute ...] foreground background uncolor { index | header | body } { * | pattern ... } If your terminal supports color, you can spice up Mutt by creating your own color scheme. To define the color of an object (type of information), you must specify both a foreground color and a background color (it is not possible to only specify one or the other). header and body match regexp in the header/body of a message, index matches pattern in the message index. Note that IMAP server-side searches (=b, =B, =h) are not supported for color index patterns. When $header_color_partial is unset (the default), a header matched by regexp will have color applied to the entire header. When set, color is applied only to the exact text matched by regexp. object can be one of: * attachment * bold (highlighting bold patterns in the body of messages) * error (error messages printed by Mutt) * hdrdefault (default color of the message header in the pager) * indicator (arrow or bar used to indicate the current item in a menu) * markers (the "+" markers at the beginning of wrapped lines in the pager) * message (informational messages) * normal * prompt * quoted (text matching $quote_regexp in the body of a message) * quoted1, quoted2, ..., quotedN (higher levels of quoting) * search (highlighting of words in the pager) * signature * status (mode lines used to display info about the mailbox or message) * tilde (the "~" used to pad blank lines in the pager) * tree (thread tree drawn in the message index and attachment menu) * underline (highlighting underlined patterns in the body of messages) composeobject can be one of: * header * security_encrypt * security_sign * security_both * security_none attribute can be one of the following: * none * bold * underline * reverse * standout foreground and background can be one of the following: * white * black * green * magenta * blue * cyan * yellow * red * default * colorx The color name can optionally be prefixed with the keyword bright or light to make the color boldfaced or light (e.g., brightred). The precise behavior depends on the terminal and its configuration. In particular, the boldfaced/light difference and such background colors may be available only for terminals configured with at least 16 colors, as specified by the $TERM environment variable. If your terminal supports it, the special keyword default can be used as a transparent color. The value brightdefault is also valid. If Mutt is linked against the S-Lang library, you also need to set the $COLORFGBG environment variable to the default colors of your terminal for this to work; for example (for Bourne-like shells): set COLORFGBG="green;black" export COLORFGBG Note The S-Lang library requires you to use the lightgray and brown keywords instead of white and yellow when setting this variable. Note The uncolor command can be applied to the index, header and body objects only. It removes entries from the list. You must specify the same pattern specified in the color command for it to be removed. The pattern "*" is a special token which means to clear the color list of all entries. Mutt also recognizes the keywords color0, color1, ..., colorN-1 (N being the number of colors supported by your terminal). This is useful when you remap the colors for your display (for example by changing the color associated with color2 for your xterm), since color names may then lose their normal meaning. If your terminal does not support color, it is still possible change the video attributes through the use of the "mono" command. Usage: mono object attribute mono { header | body } attribute regexp mono index attribute pattern mono compose composeobject attribute unmono { index | header | body } { * | pattern ... } For object, composeobject, and attribute, see the color command. 12. Message Header Display 12.1. Header Display When displaying a message in the pager, Mutt folds long header lines at $wrap columns. Though there're precise rules about where to break and how, Mutt always folds headers using a tab for readability. (Note that the sending side is not affected by this, Mutt tries to implement standards compliant folding.) Despite not being a real header, Mutt will also display an mbox "From_" line in the pager along with other headers. This line can be manipulated with ignore/unignore and hdr_order/unhdr_order commands. 12.2. Selecting Headers Usage: ignore pattern [ pattern ...] unignore { * | pattern ... } Messages often have many header fields added by automatic processing systems, or which may not seem useful to display on the screen. This command allows you to specify header fields which you don't normally want to see in the pager. You do not need to specify the full header field name. For example, "ignore content-" will ignore all header fields that begin with the pattern "content-". "ignore *" will ignore all headers. To remove a previously added token from the list, use the "unignore" command. The "unignore" command will make Mutt display headers with the given pattern. For example, if you do "ignore x-" it is possible to "unignore x-mailer". "unignore *" will remove all tokens from the ignore list. Example_3.11._Header_weeding # Sven's draconian header weeding ignore * unignore from date subject to cc unignore organization organisation x-mailer: x-newsreader: x-mailing-list: unignore posted-to: The above example will show "From:" headers as well as mbox "From_" lines. To hide the latter, instead use "unignore from: date subject to cc" on the second line. 12.3. Ordering Displayed Headers Usage: hdr_order header [ header ...] unhdr_order { * | header ... } With the hdr_order command you can specify an order in which Mutt will attempt to present these headers to you when viewing messages. "unhdr_order *" will clear all previous headers from the order list, thus removing the header order effects set by the system-wide startup file. Example_3.12._Configuring_header_display_order hdr_order From Date: From: To: Cc: Subject: 13. Alternative Addresses Usage: alternates [ -group name ...] regexp [ regexp ...] unalternates [ -group name ...] { * | regexp ... } With various functions, Mutt will treat messages differently, depending on whether you sent them or whether you received them from someone else. For instance, when replying to a message that you sent to a different party, Mutt will automatically suggest to send the response to the original message's recipients -- responding to yourself won't make much sense in many cases. (See $reply_to.) Many users receive e-mail under a number of different addresses. To fully use Mutt's features here, the program must be able to recognize what e-mail addresses you receive mail under. That's the purpose of the alternates command: It takes a list of regular expressions, each of which can identify an address under which you receive e-mail. As addresses are matched using regular expressions and not exact strict comparisons, you should make sure you specify your addresses as precise as possible to avoid mismatches. For example, if you specify: alternates user@example Mutt will consider "some-user@example" as being your address, too which may not be desired. As a solution, in such cases addresses should be specified as: alternates '^user@example$' The -group flag causes all of the subsequent regular expressions to be added to the named group. The unalternates command can be used to write exceptions to alternates patterns. If an address matches something in an alternates command, but you nonetheless do not think it is from you, you can list a more precise pattern under an unalternates command. To remove a regular expression from the alternates list, use the unalternates command with exactly the same regexp. Likewise, if the regexp for an alternates command matches an entry on the unalternates list, that unalternates entry will be removed. If the regexp for unalternates is "*", all_entries on alternates will be removed. 14. Mailing Lists Usage: lists [ -group name ...] regexp [ regexp ...] unlists { * | regexp ... } subscribe [ -group name ...] regexp [ regexp ...] unsubscribe { * | regexp ... } Mutt has a few nice features for handling mailing lists. In order to take advantage of them, you must specify which addresses belong to mailing lists, and which mailing lists you are subscribed to. Mutt also has limited support for auto-detecting mailing lists: it supports parsing mailto: links in the common List-Post: header which has the same effect as specifying the list address via the lists command (except the group feature). Once you have done this, the function will work for all known lists. Additionally, when you send a message to a known list and $followup_to is set, Mutt will add a Mail-Followup-To header. For unsubscribed lists, this will include your personal address, ensuring you receive a copy of replies. For subscribed mailing lists, the header will not, telling other users' mail user agents not to send copies of replies to your personal address. Note The Mail-Followup-To header is a non-standard extension which is not supported by all mail user agents. Adding it is not bullet-proof against receiving personal CCs of list messages. Also note that the generation of the Mail-Followup-To header is controlled by the $followup_to configuration variable since it's common practice on some mailing lists to send Cc upon replies (which is more a group- than a list-reply). More precisely, Mutt maintains lists of patterns for the addresses of known and subscribed mailing lists. Every subscribed mailing list is known. To mark a mailing list as known, use the list command. To mark it as subscribed, use subscribe. You can use regular expressions with both commands. To mark all messages sent to a specific bug report's address on Debian's bug tracking system as list mail, for instance, you could say subscribe [0-9]+.*@bugs.debian.org as it's often sufficient to just give a portion of the list's e-mail address. Specify as much of the address as you need to remove ambiguity. For example, if you've subscribed to the Mutt mailing list, you will receive mail addressed to mutt-users@mutt.org. So, to tell Mutt that this is a mailing list, you could add lists mutt-users@ to your initialization file. To tell Mutt that you are subscribed to it, add subscribe mutt-users to your initialization file instead. If you also happen to get mail from someone whose address is mutt-users@example.com, you could use lists ^mutt-users@mutt\\.org$ or subscribe ^mutt-users@mutt\\.org$ to match only mail from the actual list. The -group flag adds all of the subsequent regular expressions to the named address group in addition to adding to the specified address list. The "unlists" command is used to remove a token from the list of known and subscribed mailing-lists. Use "unlists *" to remove all tokens. To remove a mailing list from the list of subscribed mailing lists, but keep it on the list of known mailing lists, use unsubscribe. All of the mailing list configuration options described so far govern mutt's knowledge of your list subscriptions and how it presents list information to you. If you have a message from a mailing list, you can also use the list menu (bound to "ESC L" by default) to interact with the message's list's list server. This makes it easy to subscribe, unsubscribe, and so on. 15. Using Multiple Spool Mailboxes Usage: mbox-hook [!]regexp mailbox This command is used to move read messages from a specified mailbox to a different mailbox automatically when you quit or change folders. regexp is a regular expression specifying the mailbox to treat as a "spool" mailbox and mailbox specifies where mail should be saved when read. The regexp parameter has mailbox shortcut expansion performed on the first character. See Mailbox Matching in Hooks for more details. Note that execution of mbox-hooks is dependent on the $move configuration variable. If set to "no" (the default), mbox-hooks will not be executed. Unlike some of the other hook commands, only the first matching regexp is used (it is not possible to save read mail in more than a single mailbox). 16. Monitoring Incoming Mail Usage: mailboxes [ [ -notify | -nonotify ] [ -poll | -nopoll ] [ -label label | -nolabel ] mailbox ] [...] unmailboxes { * | mailbox ... } This command specifies folders which can receive mail and which will be checked for new messages periodically. Use -nonotify to disable notifying when new mail arrives. The -notify argument can be used to reenable notifying for an existing mailbox. If unspecified: a new mailbox will notify by default, while an existing mailbox will be unchanged. To disable polling, specify -nopoll before the mailbox name. The -poll argument can be used to reenable polling for an existing mailbox. If unspecified: a new mailbox will poll by default, while an existing mailbox will be unchanged. The -label argument can be used to specify an alternative label to print in the sidebar or mailbox browser instead of the mailbox path. A label may be removed via the -nolabel argument. If unspecified, an existing mailbox label will be unchanged. mailbox can either be a local file or directory (Mbox/Mmdf or Maildir/Mh). If Mutt was built with POP and/or IMAP support, mailbox can also be a POP/IMAP folder URL. The URL syntax is described in Section 1.2, "URL Syntax", POP and IMAP are described in Section 3, "POP3 Support" and Section 4, "IMAP Support" respectively. Mutt provides a number of advanced features for handling (possibly many) folders and new mail within them, please refer to Section 13, "New Mail Detection" for details (including in what situations and how often Mutt checks for new mail). Additionally, $new_mail_command can be used to run a command when new mail is detected. The "unmailboxes" command is used to remove a token from the list of folders which receive mail. Use "unmailboxes *" to remove all tokens. Note The folders in the mailboxes command are resolved when the command is executed, so if these names contain shortcut characters (such as "=" and "!"), any variable definition that affects these characters (like $folder and $spoolfile) should be set before the mailboxes command. If none of these shortcuts are used, a local path should be absolute as otherwise Mutt tries to find it relative to the directory from where Mutt was started which may not always be desired. 17. User-Defined Headers Usage: my_hdr string unmy_hdr { * | field ... } The my_hdr command allows you to create your own header fields which will be added to every message you send and appear in the editor if $edit_headers is set. For example, if you would like to add an "Organization:" header field to all of your outgoing messages, you can put the command something like shown in Example 3.13, "Defining custom headers" in your .muttrc. Example_3.13._Defining_custom_headers my_hdr Organization: A Really Big Company, Anytown, USA Note Space characters are not allowed between the keyword and the colon (":"). The standard for electronic mail (RFC2822) says that space is illegal there, so Mutt enforces the rule. If you would like to add a header field to a single message, you should either set the $edit_headers variable, or use the function (default: "E") in the compose menu so that you can edit the header of your message along with the body. To remove user defined header fields, use the unmy_hdr command. You may specify an asterisk ("*") to remove all header fields, or the fields to remove. For example, to remove all "To" and "Cc" header fields, you could use: unmy_hdr to cc 18. Specify Default Save Mailbox Usage: save-hook [!]pattern mailbox This command is used to override the default mailbox used when saving messages. mailbox will be used as the default if the message matches pattern, see Message Matching in Hooks for information on the exact format. To provide more flexibility and good defaults, Mutt applies the expandos of $index_format to mailbox after it was expanded. Example_3.14._Using_%-expandos_in_save-hook # default: save all to ~/Mail/ save-hook . ~/Mail/%F # save from me@turing.cs.hmc.edu and me@cs.hmc.edu to $folder/elkins save-hook me@(turing\\.)?cs\\.hmc\\.edu$ +elkins # save from aol.com to $folder/spam save-hook aol\\.com$ +spam Also see the fcc-save-hook command. 19. Specify Default Fcc: Mailbox When Composing Usage: fcc-hook [!]pattern mailbox This command is used to save outgoing mail in a mailbox other than $record. Mutt searches the initial list of message recipients for the first matching pattern and uses mailbox as the default Fcc: mailbox. If no match is found the message will be saved to $record mailbox. To provide more flexibility and good defaults, Mutt applies the expandos of $index_format to mailbox after it was expanded. See Message Matching in Hooks for information on the exact format of pattern. fcc-hook [@.]aol\\.com$ +spammers ...will save a copy of all messages going to the aol.com domain to the `+spammers' mailbox by default. Also see the fcc-save-hook command. Multiple mailboxes may be specified by separating them with $fcc_delimiter, if set: set fcc_delimiter = ',' fcc-hook 'foo@example\.com$' '+one,+two' 20. Specify Default Save Filename and Default Fcc: Mailbox at Once Usage: fcc-save-hook [!]pattern mailbox This command is a shortcut, almost equivalent to doing both a fcc-hook and a save-hook with its arguments, including %-expansion on mailbox according to $index_format. Note, however that the fcc-save-hook is not designed to take advantage of multiple mailboxes, as fcc-hook is. For correct behavior, you should use separate fcc and save hooks in that case. 21. Change Settings Based Upon Message Recipients Usage: reply-hook [!]pattern command send-hook [!]pattern command send2-hook [!]pattern command These commands can be used to execute arbitrary configuration commands based upon recipients of the message. pattern is used to match the message, see Message Matching in Hooks for details. command is executed when pattern matches. reply-hook is matched against the message you are replying_to, instead of the message you are sending. send-hook is matched against all messages, both new and replies. Note reply-hooks are matched before the send-hook, regardless of the order specified in the user's configuration file. However, you can inhibit send-hook in the reply case by using the pattern '! ~Q' (not_replied, see Message Matching in Hooks) in the send-hook to tell when reply-hook have been executed. send2-hook is matched every time a message is changed, either by editing it, or by using the compose menu to change its recipients or subject. send2-hook is executed after send-hook, and can, e.g., be used to set parameters such as the $sendmail variable depending on the message's sender address. For each type of send-hook or reply-hook, when multiple matches occur, commands are executed in the order they are specified in the .muttrc (for that type of hook). Example: send-hook mutt "set mime_forward signature=''" Another typical use for this command is to change the values of the $attribution, $attribution_locale, and $signature variables in order to change the language of the attributions and signatures based upon the recipients. Note send-hook's are only executed once after getting the initial list of recipients. They are not executed when resuming a postponed draft. Adding a recipient after replying or editing the message will not cause any send-hook to be executed, similarly if $autoedit is set (as then the initial list of recipients is empty). Also note that my_hdr commands which modify recipient headers, or the message's subject, don't have any effect on the current message when executed from a send-hook. 22. Change Settings Before Formatting a Message Usage: message-hook [!]pattern command This command can be used to execute arbitrary configuration commands before viewing or formatting a message based upon information about the message. command is executed if the pattern matches the message to be displayed. When multiple matches occur, commands are executed in the order they are specified in the .muttrc. See Message Matching in Hooks for information on the exact format of pattern. Example: message-hook ~A 'set pager=builtin' message-hook '~f freshmeat-news' 'set pager="less \"+/^ subject: .*\""' 23. Choosing the Cryptographic Key of the Recipient Usage: crypt-hook regexp keyid When encrypting messages with PGP/GnuPG or OpenSSL, you may want to associate a certain key with a given e-mail address automatically, either because the recipient's public key can't be deduced from the destination address, or because, for some reasons, you need to override the key Mutt would normally use. The crypt-hook command provides a method by which you can specify the ID of the public key to be used when encrypting messages to a certain recipient. You may use multiple crypt-hooks with the same regexp; multiple matching crypt-hooks result in the use of multiple keyids for a recipient. During key selection, Mutt will confirm whether each crypt-hook is to be used (unless the $crypt_confirmhook option is unset). If all crypt-hooks for a recipient are declined, Mutt will use the original recipient address for key selection instead. The meaning of keyid is to be taken broadly in this context: You can either put a numerical key ID or fingerprint here, an e-mail address, or even just a real name. 24. Dynamically Changing $index_format using Patterns Usage: index-format-hook name [!]pattern format-string This command is used to inject format strings dynamically into $index_format based on pattern matching against the current message. The $index_format expando %@name@ specifies a placeholder for the injection. Index-format-hooks with the same name are matched using pattern against the current message. Matching is done in the order specified in the .muttrc, with the first match being used. The hook's format-string is then substituted and evaluated. Because the first match is used, best practice is to put a catch-all ~A pattern as the last hook. Here is an example showing how to implement dynamic date formatting: set index_format="%4C %-6@date@ %-15.15F %Z (%4c) %s" index-format-hook date "~d<1d" "%[%H:%M]" index-format-hook date "~d<1m" "%[%a %d]" index-format-hook date "~d<1y" "%[%b %d]" index-format-hook date "~A" "%[%m/%y]" Another example, showing a way to prepend to the subject. Note that without a catch-all ~A pattern, no match results in the expando being replaced with an empty string. set index_format="%4C %@subj_flags@%s" index-format-hook subj_flags "~f boss@example.com" "** BOSS ** " index-format-hook subj_flags "~f spouse@example.com" ":-) " 25. Adding Key Sequences to the Keyboard Buffer Usage: push string This command adds the named string to the beginning of the keyboard buffer. The string may contain control characters, key names and function names like the sequence string in the macro command. You may use it to automatically run a sequence of commands at startup, or when entering certain folders. For example, Example 3.15, "Embedding push in folder-hook" shows how to automatically collapse all threads when entering a folder. Example_3.15._Embedding_push_in_folder-hook folder-hook . 'push ' For using functions like shown in the example, it's important to use angle brackets ("<" and ">") to make Mutt recognize the input as a function name. Otherwise it will simulate individual just keystrokes, i.e. "push collapse-all" would be interpreted as if you had typed "c", followed by "o", followed by "l", ..., which is not desired and may lead to very unexpected behavior. Keystrokes can be used, too, but are less portable because of potentially changed key bindings. With default bindings, this is equivalent to the above example: folder-hook . 'push \eV' because it simulates that Esc+V was pressed (which is the default binding of ). 26. Executing Functions Usage: exec function [ function ...] This command can be used to execute any function. Functions are listed in the function reference. "exec function" is equivalent to "push ". 27. Message Scoring Usage: score pattern value unscore { * | pattern ... } The score commands adds value to a message's score if pattern matches it. pattern is a string in the format described in the patterns section (note: For efficiency reasons, patterns which scan information not available in the index, such as ~b, ~B, ~h, ~M, or ~X may not be used). value is a positive or negative integer. A message's final score is the sum total of all matching score entries. However, you may optionally prefix value with an equal sign ("=") to cause evaluation to stop at a particular entry if there is a match. Negative final scores are rounded up to 0. The unscore command removes score entries from the list. You must specify the same pattern specified in the score command for it to be removed. The pattern "*" is a special token which means to clear the list of all score entries. Scoring occurs as the messages are read in, before the mailbox is sorted. Because of this, patterns which depend on threading, such as ~=, ~$, and ~(), will not work by default. A workaround is to push the scoring command in a folder hook. This will cause the mailbox to be rescored after it is opened and input starts being processed: folder-hook . 'push "score ~= 10"' 28. Spam Detection Usage: spam pattern format nospam { * | pattern } Mutt has generalized support for external spam-scoring filters. By defining your spam patterns with the spam and nospam commands, you can limit, search, and sort your mail based on its spam attributes, as determined by the external filter. You also can display the spam attributes in your index display using the %H selector in the $index_format variable. (Tip: try %?H?[%H] ? to display spam tags only when they are defined for a given message.) Note: the value displayed by %H and searched by ~H is stored in the header cache. Mutt isn't smart enough to invalidate a header cache entry based on changing spam rules, so if you aren't seeing correct %H values, try temporarily turning off the header cache. If that fixes the problem, then once your spam rules are set to your liking, remove your stale header cache files and turn the header cache back on. Your first step is to define your external filter's spam patterns using the spam command. pattern should be a regular expression that matches a header in a mail message. If any message in the mailbox matches this regular expression, it will receive a "spam tag" or "spam attribute" (unless it also matches a nospam pattern -- see below.) The appearance of this attribute is entirely up to you, and is governed by the format parameter. format can be any static text, but it also can include back-references from the pattern expression. (A regular expression "back-reference" refers to a sub-expression contained within parentheses.) %1 is replaced with the first back-reference in the regex, %2 with the second, etc. To match spam tags, mutt needs the corresponding header information which is always the case for local and POP folders but not for IMAP in the default configuration. Depending on the spam header to be analyzed, $imap_headers may need to be adjusted. If you're using multiple spam filters, a message can have more than one spam-related header. You can define spam patterns for each filter you use. If a message matches two or more of these patterns, and the $spam_separator variable is set to a string, then the message's spam tag will consist of all the format strings joined together, with the value of $spam_separator separating them. For example, suppose one uses DCC, SpamAssassin, and PureMessage, then the configuration might look like in Example 3.16, "Configuring spam detection". Example_3.16._Configuring_spam_detection spam "X-DCC-.*-Metrics:.*(....)=many" "90+/DCC-%1" spam "X-Spam-Status: Yes" "90+/SA" spam "X-PerlMX-Spam: .*Probability=([0-9]+)%" "%1/PM" set spam_separator=", " If then a message is received that DCC registered with "many" hits under the "Fuz2" checksum, and that PureMessage registered with a 97% probability of being spam, that message's spam tag would read 90+/DCC-Fuz2, 97/PM. (The four characters before "=many" in a DCC report indicate the checksum used -- in this case, "Fuz2".) If the $spam_separator variable is unset, then each spam pattern match supersedes the previous one. Instead of getting joined format strings, you'll get only the last one to match. The spam tag is what will be displayed in the index when you use %H in the $index_format variable. It's also the string that the ~H pattern-matching expression matches against for and functions. And it's what sorting by spam attribute will use as a sort key. That's a pretty complicated example, and most people's actual environments will have only one spam filter. The simpler your configuration, the more effective Mutt can be, especially when it comes to sorting. Generally, when you sort by spam tag, Mutt will sort lexically -- that is, by ordering strings alphanumerically. However, if a spam tag begins with a number, Mutt will sort numerically first, and lexically only when two numbers are equal in value. (This is like UNIX's sort -n.) A message with no spam attributes at all -- that is, one that didn't match any of your spam patterns -- is sorted at lowest priority. Numbers are sorted next, beginning with 0 and ranging upward. Finally, non-numeric strings are sorted, with "a" taking lower priority than "z". Clearly, in general, sorting by spam tags is most effective when you can coerce your filter to give you a raw number. But in case you can't, Mutt can still do something useful. The nospam command can be used to write exceptions to spam patterns. If a header pattern matches something in a spam command, but you nonetheless do not want it to receive a spam tag, you can list a more precise pattern under a nospam command. If the pattern given to nospam is exactly the same as the pattern on an existing spam list entry, the effect will be to remove the entry from the spam list, instead of adding an exception. Likewise, if the pattern for a spam command matches an entry on the nospam list, that nospam entry will be removed. If the pattern for nospam is "*", all_entries_on both_lists will be removed. This might be the default action if you use spam and nospam in conjunction with a folder-hook. You can have as many spam or nospam commands as you like. You can even do your own primitive spam detection within Mutt -- for example, if you consider all mail from MAILER-DAEMON to be spam, you can use a spam command like this: spam "^From: .*MAILER-DAEMON" "999" 29. Setting and Querying Variables 29.1. Variable Types Mutt supports these types of configuration variables: boolean A boolean expression, either "yes" or "no". number A signed integer number in the range -32768 to 32767. number (long) A signed integer number in the range -2147483648 to 2147483647. string Arbitrary text. path A specialized string for representing paths including support for mailbox shortcuts (see Section 10, "Mailbox Shortcuts") as well as tilde ("~") for a user's home directory and more. quadoption Like a boolean but triggers a prompt when set to "ask-yes" or "ask-no" with "yes" and "no" preselected respectively. sort order A specialized string allowing only particular words as values depending on the variable. regular expression A regular expression, see Section 2, "Regular Expressions" for an introduction. folder magic Specifies the type of folder to use: mbox, mmdf, mh or maildir. Currently only used to determine the type for newly created folders. e-mail address An e-mail address either with or without realname. The older "user@example.org (Joe User)" form is supported but strongly deprecated. user-defined Arbitrary text, see Section 29.3, "User-Defined Variables" for details. 29.2. Commands The following commands are available to manipulate and query variables: Usage: set { [ no | inv ] variable | variable=value } [...] toggle variable [ variable ...] unset variable [ variable ...] reset variable [ variable ...] This command is used to set (and unset) configuration variables. There are four basic types of variables: boolean, number, string and quadoption. boolean variables can be set (true) or unset (false). number variables can be assigned a positive integer value. string variables consist of any number of printable characters and must be enclosed in quotes if they contain spaces or tabs. You may also use the escape sequences "\n" and "\t" for newline and tab, respectively. quadoption variables are used to control whether or not to be prompted for certain actions, or to specify a default action. A value of yes will cause the action to be carried out automatically as if you had answered yes to the question. Similarly, a value of no will cause the action to be carried out as if you had answered "no." A value of ask-yes will cause a prompt with a default answer of "yes" and ask-no will provide a default answer of "no." Prefixing a variable with "no" will unset it. Example: set noaskbcc. For boolean variables, you may optionally prefix the variable name with inv to toggle the value (on or off). This is useful when writing macros. Example: set invsmart_wrap. The toggle command automatically prepends the inv prefix to all specified variables. The unset command automatically prepends the no prefix to all specified variables. Using the function in the index menu, you can query the value of a variable by prefixing the name of the variable with a question mark: set ?allow_8bit The question mark is actually only required for boolean and quadoption variables. The reset command resets all given variables to the compile time defaults (hopefully mentioned in this manual). If you use the command set and prefix the variable with "&" this has the same behavior as the reset command. With the reset command there exists the special variable "all", which allows you to reset all variables to their system defaults. 29.3. User-Defined Variables 29.3.1. Introduction Along with the variables listed in the Configuration variables section, Mutt supports user-defined variables with names starting with my_ as in, for example, my_cfgdir. The set command either creates a custom my_ variable or changes its value if it does exist already. The unset and reset commands remove the variable entirely. Since user-defined variables are expanded in the same way that environment variables are (except for the shell-escape command and backtick expansion), this feature can be used to make configuration files more readable. 29.3.2. Examples The following example defines and uses the variable my_cfgdir to abbreviate the calls of the source command: Example_3.17._Using_user-defined_variables_for_config_file_readability set my_cfgdir = $HOME/mutt/config source $my_cfgdir/hooks source $my_cfgdir/macros # more source commands... A custom variable can also be used in macros to backup the current value of another variable. In the following example, the value of the $delete is changed temporarily while its original value is saved as my_delete. After the macro has executed all commands, the original value of $delete is restored. Example_3.18._Using_user-defined_variables_for_backing_up_other_config option_values macro pager ,x '\ set my_delete=$delete\ set delete=yes\ ...\ set delete=$my_delete' Since Mutt expands such values already when parsing the configuration file(s), the value of $my_delete in the last example would be the value of $delete exactly as it was at that point during parsing the configuration file. If another statement would change the value for $delete later in the same or another file, it would have no effect on $my_delete. However, the expansion can be deferred to runtime, as shown in the next example, when escaping the dollar sign. Example_3.19._Deferring_user-defined_variable_expansion_to_runtime macro pager "\ set my_old_pager_stop=\$pager_stop pager_stop\ \ set pager_stop=\$my_old_pager_stop\ unset my_old_pager_stop" Note that there is a space between and the set configuration command, preventing Mutt from recording the macro's commands into its history. 29.4. Type Conversions Variables are always assigned string values which Mutt parses into its internal representation according to the type of the variable, for example an integer number for numeric types. For all queries (including $-expansion) the value is converted from its internal type back into string. As a result, any variable can be assigned any value given that its content is valid for the target. This also counts for custom variables which are of type string. In case of parsing errors, Mutt will print error messages. Example 3.20, "Type conversions using variables" demonstrates type conversions. Example_3.20._Type_conversions_using_variables set my_lines = "5" # value is string "5" set pager_index_lines = $my_lines # value is integer 5 set my_sort = "date-received" # value is string "date-received" set sort = "last-$my_sort" # value is sort last-date-received set my_inc = $read_inc # value is string "10" (default of $read_inc) set my_foo = $my_inc # value is string "10" These assignments are all valid. If, however, the value of $my_lines would have been "five" (or something else that cannot be parsed into a number), the assignment to $pager_index_lines would have produced an error message. Type conversion applies to all configuration commands which take arguments. But please note that every expanded value of a variable is considered just a single token. A working example is: set my_pattern = "~A" set my_number = "10" # same as: score ~A +10 score $my_pattern +$my_number What does not work is: set my_mx = "+mailbox1 +mailbox2" mailboxes $my_mx +mailbox3 because the value of $my_mx is interpreted as a single mailbox named "+mailbox1 +mailbox2" and not two distinct mailboxes. 30. Reading Initialization Commands From Another File Usage: source filename This command allows the inclusion of initialization commands from other files. For example, I place all of my aliases in ~/.mail_aliases so that I can make my ~/.muttrc readable and keep my aliases private. If the filename begins with a tilde ("~"), it will be expanded to the path of your home directory. If the filename ends with a vertical bar ("|"), then filename is considered to be an executable program from which to read input (e.g. source ~/bin/myscript|). 31. Removing Hooks Usage: unhook { * | hook-type } This command permits you to flush hooks you have previously defined. You can either remove all hooks by giving the "*" character as an argument, or you can remove all hooks of a specific type by saying something like unhook send-hook. 32. Format Strings 32.1. Basic usage Format strings are a general concept you'll find in several locations through the Mutt configuration, especially in the $index_format, $pager_format, $status_format, and other related variables. These can be very straightforward, and it's quite possible you already know how to use them. The most basic format string element is a percent symbol followed by another character. For example, %s represents a message's Subject: header in the $index_format variable. The "expandos" available are documented with each format variable, but there are general modifiers available with all formatting expandos, too. Those are our concern here. Some of the modifiers are borrowed right out of C (though you might know them from Perl, Python, shell, or another language). These are the [-]m.n modifiers, as in %-12.12s. As with such programming languages, these modifiers allow you to specify the minimum and maximum size of the resulting string, as well as its justification. If the "-" sign follows the percent, the string will be left-justified instead of right-justified. If there's a number immediately following that, it's the minimum amount of space the formatted string will occupy -- if it's naturally smaller than that, it will be padded out with spaces. If a decimal point and another number follow, that's the maximum space allowable -- the string will not be permitted to exceed that width, no matter its natural size. Each of these three elements is optional, so that all these are legal format strings: %-12s, %4c, %.15F and %-12.15L. Mutt adds some other modifiers to format strings. If you use an equals symbol (=) as a numeric prefix (like the minus above), it will force the string to be centered within its minimum space range. For example, %=14y will reserve 14 characters for the %y expansion -- that's the X-Label: header, in $index_format. If the expansion results in a string less than 14 characters, it will be centered in a 14-character space. If the X-Label for a message were "test", that expansion would look like " test ". There are two very little-known modifiers that affect the way that an expando is replaced. If there is an underline ("_") character between any format modifiers (as above) and the expando letter, it will expands in all lower case. And if you use a colon (":"), it will replace all decimal points with underlines. 32.2. Conditionals Depending on the format string variable, some of its sequences can be used to optionally print a string if their value is nonzero. For example, you may only want to see the number of flagged messages if such messages exist, since zero is not particularly meaningful. To optionally print a string based upon one of the above sequences, the following construct is used: %??? where sequence_char is an expando, and optional_string is the string you would like printed if sequence_char is nonzero. optional_string may contain other sequences as well as normal text, but you may not nest optional strings. Here is an example illustrating how to optionally print the number of new messages in a mailbox in $status_format: %?n?%n new messages.? You can also switch between two strings using the following construct: %??&? If the value of sequence_char is non-zero, if_string will be expanded, otherwise else_string will be expanded. 32.3. Filters Any format string ending in a vertical bar ("|") will be expanded and piped through the first word in the string, using spaces as separator. The string returned will be used for display. If the returned string ends in %, it will be passed through the formatter a second time. This allows the filter to generate a replacement format string including % expandos. All % expandos in a format string are expanded before the script is called so that: Example_3.21._Using_external_filters_in_format_strings set status_format="script.sh '%r %f (%L)'|" will make Mutt expand %r, %f and %L before calling the script. The example also shows that arguments can be quoted: the script will receive the expanded string between the single quotes as the only argument. A practical example is the mutt_xtitle script installed in the samples subdirectory of the Mutt documentation: it can be used as filter for $status_format to set the current terminal's title, if supported. 32.4. Padding In most format strings, Mutt supports different types of padding using special %-expandos: %|X When this occurs, Mutt will fill the rest of the line with the character X. For example, filling the rest of the line with dashes is done by setting: set status_format = "%v on %h: %B: %?n?%n&no? new messages %|-" %>X Since the previous expando stops at the end of line, there must be a way to fill the gap between two items via the %>X expando: it puts as many characters X in between two items so that the rest of the line will be right-justified. For example, to not put the version string and hostname the above example on the left but on the right and fill the gap with spaces, one might use (note the space after %>): set status_format = "%B: %?n?%n&no? new messages %> (%v on %h)" %*X Normal right-justification will print everything to the left of the %>, displaying padding and whatever lies to the right only if there's room. By contrast, "soft-fill" gives priority to the right-hand side, guaranteeing space to display it and showing padding only if there's still room. If necessary, soft-fill will eat text leftwards to make room for rightward text. For example, to right-justify the subject making sure as much as possible of it fits on screen, one might use (note two spaces after %* : the second ensures there's a space between the truncated right-hand side and the subject): set index_format="%4C %Z %{%b %d} %-15.15L (%?l?%4l&%4c?)%* %s" 32.5. Bytes size display Various format strings contain expandos that display the size of messages in bytes. This includes %s in $attach_format, %l in $compose_format, %s in $folder_format, %c in $index_format, and %l and %L in $status_format. There are four configuration variables that can be used to customize how the numbers are displayed. $size_show_bytes will display the number of bytes when the size is < 1 kilobyte. When unset, kilobytes will be displayed instead. $size_show_mb will display the number of megabytes when the size is >= 1 megabyte. When unset, kilobytes will be displayed instead (which could be a large number). $size_show_fractions, will display numbers with a single decimal place for values from 0 to 10 kilobytes, and 1 to 10 megabytes. $size_units_on_left will display the unit ("K" or "M") to the left of the number, instead of the right if unset. These variables also affect size display in a few other places, such as progress indicators and attachment delimiters in the pager. 33. Control allowed header fields in a mailto: URL Usage: mailto_allow { * | header-field ... } unmailto_allow { * | header-field ... } As a security measure, Mutt will only add user-approved header fields from a mailto: URL. This is necessary since Mutt will handle certain header fields, such as Attach:, in a special way. The mailto_allow and unmailto_allow commands allow the user to modify the list of approved headers. Mutt initializes the default list to contain the Subject and Body header fields, which are the only requirement specified by the mailto: specification in RFC2368, along with Cc, In-Reply-To, and References, to support mailing list URLs. Chapter 4. Advanced Usage Table_of_Contents 1. Character Set Handling 2. Regular Expressions 3. Patterns: Searching, Limiting and Tagging 3.1. Pattern Modifier 3.2. Simple Searches 3.3. Nesting and Boolean Operators 3.4. Searching by Date 4. Marking Messages 5. Using Tags 6. Using Hooks 6.1. Message Matching in Hooks 6.2. Mailbox Matching in Hooks 7. Managing the Environment 8. External Address Queries 9. Mailbox Formats 10. Mailbox Shortcuts 11. Handling Mailing Lists 12. Display Munging 13. New Mail Detection 13.1. How New Mail Detection Works 13.2. Polling For New Mail 13.3. Monitoring New Mail 13.4. Calculating Mailbox Message Counts 14. Editing Threads 14.1. Linking Threads 14.2. Breaking Threads 15. Delivery Status Notification (DSN) Support 16. Start a WWW Browser on URLs 17. Echoing Text 18. Message Composition Flow 19. Batch Composition Flow 20. Using MuttLisp (EXPERIMENTAL) 20.1. Running a command generated by MuttLisp 20.2. Interpolating MuttLisp in a Command Argument 20.3. MuttLisp Syntax 20.4. MuttLisp Functions 20.5. Examples 21. Miscellany 1. Character Set Handling A "character set" is basically a mapping between bytes and glyphs and implies a certain character encoding scheme. For example, for the ISO 8859 family of character sets, an encoding of 8bit per character is used. For the Unicode character set, different character encodings may be used, UTF-8 being the most popular. In UTF-8, a character is represented using a variable number of bytes ranging from 1 to 4. Since Mutt is a command-line tool run from a shell, and delegates certain tasks to external tools (such as an editor for composing/editing messages), all of these tools need to agree on a character set and encoding. There exists no way to reliably deduce the character set a plain text file has. Interoperability is gained by the use of well-defined environment variables. The full set can be printed by issuing locale on the command line. Upon startup, Mutt determines the character set on its own using routines that inspect locale-specific environment variables. Therefore, it is generally not necessary to set the $charset variable in Mutt. It may even be counter-productive as Mutt uses system and library functions that derive the character set themselves and on which Mutt has no influence. It's safest to let Mutt work out the locale setup itself. If you happen to work with several character sets on a regular basis, it's highly advisable to use Unicode and an UTF-8 locale. Unicode can represent nearly all characters in a message at the same time. When not using a Unicode locale, it may happen that you receive messages with characters not representable in your locale. When displaying such a message, or replying to or forwarding it, information may get lost possibly rendering the message unusable (not only for you but also for the recipient, this breakage is not reversible as lost information cannot be guessed). A Unicode locale makes all conversions superfluous which eliminates the risk of conversion errors. It also eliminates potentially wrong expectations about the character set between Mutt and external programs. The terminal emulator used also must be properly configured for the current locale. Terminal emulators usually do not derive the locale from environment variables, they need to be configured separately. If the terminal is incorrectly configured, Mutt may display random and unexpected characters (question marks, octal codes, or just random glyphs), format strings may not work as expected, you may not be abled to enter non-ascii characters, and possible more. Data is always represented using bytes and so a correct setup is very important as to the machine, all character sets "look" the same. Warning: A mismatch between what system and library functions think the locale is and what Mutt was told what the locale is may make it behave badly with non-ascii input: it will fail at seemingly random places. This warning is to be taken seriously since not only local mail handling may suffer: sent messages may carry wrong character set information the receiver has too deal with. The need to set $charset directly in most cases points at terminal and environment variable setup problems, not Mutt problems. A list of officially assigned and known character sets can be found at IANA, a list of locally supported locales can be obtained by running locale -a. 2. Regular Expressions All string patterns in Mutt including those in more complex patterns must be specified using regular expressions (regexp) in the "POSIX extended" syntax (which is more or less the syntax used by egrep and GNU awk). For your convenience, we have included below a brief description of this syntax. The search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise. Note "\" must be quoted if used for a regular expression in an initialization command: "\\". A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions. Note The regular expression can be enclosed/delimited by either " or ' which is useful if the regular expression includes a white-space character. See Syntax of Initialization Files for more information on " and ' delimiter processing. To match a literal " or ' you must preface it with \ (backslash). The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that match themselves. Any metacharacter with special meaning may be quoted by preceding it with a backslash. The period "." matches any single character. The caret "^" and the dollar sign "$" are metacharacters that respectively match the empty string at the beginning and end of a line. A list of characters enclosed by "[" and "]" matches any single character in that list; if the first character of the list is a caret "^" then it matches any character not in the list. For example, the regular expression [0123456789] matches any single digit. A range of ASCII characters may be specified by giving the first and last characters, separated by a hyphen "-". Most metacharacters lose their special meaning inside lists. To include a literal "]" place it first in the list. Similarly, to include a literal "^" place it anywhere but first. Finally, to include a literal hyphen "-" place it last. Certain named classes of characters are predefined. Character classes consist of "[:", a keyword denoting the class, and ":]". The following classes are defined by the POSIX standard in Table 4.1, "POSIX regular expression character classes" Table_4.1._POSIX_regular_expression_character_classes Character class Description [:alnum:] Alphanumeric characters [:alpha:] Alphabetic characters [:blank:] Space or tab characters [:cntrl:] Control characters [:digit:] Numeric characters [:graph:] Characters that are both printable and visible. (A space is printable, but not visible, while an "a" is both) [:lower:] Lower-case alphabetic characters [:print:] Printable characters (characters that are not control characters) [:punct:] Punctuation characters (characters that are not letter, digits, control characters, or space characters) [:space:] Space characters (such as space, tab and formfeed, to name a few) [:upper:] Upper-case alphabetic characters [:xdigit:] Characters that are hexadecimal digits A character class is only valid in a regular expression inside the brackets of a character list. Note Note that the brackets in these class names are part of the symbolic names, and must be included in addition to the brackets delimiting the bracket list. For example, [[:digit:]] is equivalent to [0-9]. Two additional special sequences can appear in character lists. These apply to non-ASCII character sets, which can have single symbols (called collating elements) that are represented with more than one character, as well as several characters that are equivalent for collating or sorting purposes: Collating Symbols A collating symbol is a multi-character collating element enclosed in "[." and ".]". For example, if "ch" is a collating element, then [[.ch.]] is a regexp that matches this collating element, while [ch] is a regexp that matches either "c" or "h". Equivalence Classes An equivalence class is a locale-specific name for a list of characters that are equivalent. The name is enclosed in "[=" and "=]". For example, the name "e" might be used to represent all of "e" with grave ("e"), "e" with acute ("e") and "e". In this case, [[=e=]] is a regexp that matches any of: "e" with grave ("e"), "e" with acute ("e") and "e". A regular expression matching a single character may be followed by one of several repetition operators described in Table 4.2, "Regular expression repetition operators". Table_4.2._Regular_expression_repetition_operators Operator Description ? The preceding item is optional and matched at most once * The preceding item will be matched zero or more times + The preceding item will be matched one or more times {n} The preceding item is matched exactly n times {n,} The preceding item is matched n or more times {,m} The preceding item is matched at most m times {n,m} The preceding item is matched at least n times, but no more than m times Two regular expressions may be concatenated; the resulting regular expression matches any string formed by concatenating two substrings that respectively match the concatenated subexpressions. Two regular expressions may be joined by the infix operator "|"; the resulting regular expression matches any string matching either subexpression. Repetition takes precedence over concatenation, which in turn takes precedence over alternation. A whole subexpression may be enclosed in parentheses to override these precedence rules. Note If you compile Mutt with the included regular expression engine, the following operators may also be used in regular expressions as described in Table 4.3, "GNU regular expression extensions". Table_4.3._GNU_regular_expression_extensions Expression Description \\y Matches the empty string at either the beginning or the end of a word \\B Matches the empty string within a word \\< Matches the empty string at the beginning of a word \\> Matches the empty string at the end of a word \\w Matches any word-constituent character (letter, digit, or underscore) \\W Matches any character that is not word-constituent \\` Matches the empty string at the beginning of a buffer (string) \\' Matches the empty string at the end of a buffer Please note however that these operators are not defined by POSIX, so they may or may not be available in stock libraries on various systems. 3. Patterns: Searching, Limiting and Tagging 3.1. Pattern Modifier Many of Mutt's commands allow you to specify a pattern to match (limit, tag-pattern, delete-pattern, etc.). Table 4.4, "Pattern modifiers" shows several ways to select messages. Table_4.4._Pattern_modifiers Pattern modifier Description ~A all messages ~b EXPR messages which contain EXPR in the message body ***) =b STRING If IMAP is enabled, like ~b but searches for STRING on the server, rather than downloading each message and searching it locally. ~B EXPR messages which contain EXPR in the whole message ***) =B STRING If IMAP is enabled, like ~B but searches for STRING on the server, rather than downloading each message and searching it locally. ~c EXPR messages carbon-copied to EXPR %c GROUP messages carbon-copied to any member of GROUP ~C EXPR messages either to: or cc: EXPR %C GROUP messages either to: or cc: to any member of GROUP ~d [MIN]-[MAX] messages with "date-sent" in a Date range ~D deleted messages ~e EXPR messages which contains EXPR in the "Sender" field %e GROUP messages which contain a member of GROUP in the "Sender" field ~E expired messages ~F flagged messages ~f EXPR messages originating from EXPR %f GROUP messages originating from any member of GROUP ~g cryptographically signed messages ~G cryptographically encrypted messages ~h EXPR messages which contain EXPR in the message header ***) =h STRING If IMAP is enabled, like ~h but searches for STRING on the server, rather than downloading each message and searching it locally; STRING must be of the form "header: substring" (see below). ~H EXPR messages with a spam attribute matching EXPR ~i EXPR messages which match EXPR in the "Message-ID" field ~k messages which contain PGP key material ~L EXPR messages either originated or received by EXPR %L GROUP message either originated or received by any member of GROUP ~l messages addressed to a known mailing list ~m [MIN]-[MAX] messages in the range MIN to MAX *) ~M EXPR messages which contain a mime Content-Type matching EXPR ***) ~n [MIN]-[MAX] messages with a score in the range MIN to MAX *) ~N new messages ~O old messages ~p messages addressed to you (consults $from, alternates, and local account/hostname information) ~P messages from you (consults $from, alternates, and local account/hostname information) ~Q messages which have been replied to ~r [MIN]-[MAX] messages with "date-received" in a Date range ~R read messages ~s EXPR messages having EXPR in the "Subject" field. ~S superseded messages ~t EXPR messages addressed to EXPR ~T tagged messages ~u messages addressed to a subscribed mailing list ~U unread messages ~v messages part of a collapsed thread. ~V cryptographically verified messages ~x EXPR messages which contain EXPR in the "References" or "In-Reply-To" field ~X [MIN]-[MAX] messages with MIN to MAX attachments *) ***) ~y EXPR messages which contain EXPR in the "X-Label" field ~z [MIN]-[MAX] messages with a size in the range MIN to MAX *) **) ~= duplicated messages (see $duplicate_threads) ~$ unreferenced messages (requires threaded view) ~(PATTERN) messages in threads containing messages matching PATTERN, e.g. all threads containing messages from you: ~(~P) ~<(PATTERN) messages whose immediate parent matches PATTERN, e.g. replies to your messages: ~<(~P) ~>(PATTERN) messages having an immediate child matching PATTERN, e.g. messages you replied to: ~>(~P) Where EXPR is a regular expression, and GROUP is an address group. *) The forms "<[MAX]", ">[MIN]", "[MIN]-" and "-[MAX]" are allowed, too. **) The suffixes "K" and "M" are allowed to specify kilobyte and megabyte respectively. ***) These patterns read each message in, and can therefore be much slower. Over IMAP this will entail downloading each message. They can not be used for message scoring, and it is recommended to avoid using them for index coloring. Special attention has to be paid when using regular expressions inside of patterns. Specifically, Mutt's parser for these patterns will strip one level of backslash ("\"), which is normally used for quoting. If it is your intention to use a backslash in the regular expression, you will need to use two backslashes instead ("\\"). You can force Mutt to treat EXPR as a simple string instead of a regular expression by using = instead of ~ in the pattern name. For example, =b *.* will find all messages that contain the literal string "*.*". Simple string matches are less powerful than regular expressions but can be considerably faster. For IMAP folders, string matches =b, =B, and =h will be performed on the server instead of by fetching every message. IMAP treats =h specially: it must be of the form "header: substring" and will not partially match header names. The substring part may be omitted if you simply wish to find messages containing a particular header without regard to its value. Patterns matching lists of addresses (notably c, C, p, P and t) match if there is at least one match in the whole list. If you want to make sure that all elements of that list match, you need to prefix your pattern with "^". This example matches all mails which only has recipients from Germany. Example_4.1._Matching_all_addresses_in_address_lists ^~C \.de$ You can restrict address pattern matching to aliases that you have defined with the "@" modifier. This example matches messages whose recipients are all from Germany, and who are known to your alias list. Example_4.2._Matching_restricted_to_aliases ^@~C \.de$ To match any defined alias, use a regular expression that matches any string. This example matches messages whose senders are known aliases. Example_4.3._Matching_any_defined_alias @~f . 3.2. Simple Searches Mutt supports two versions of so called "simple searches". These are issued if the query entered for searching, limiting and similar operations does not seem to contain a valid pattern modifier (i.e. it does not contain one of these characters: "~", "=" or "%"). If the query is supposed to contain one of these special characters, they must be escaped by prepending a backslash ("\"). The first type is by checking whether the query string equals a keyword case-insensitively from Table 4.5, "Simple search keywords": If that is the case, Mutt will use the shown pattern modifier instead. If a keyword would conflict with your search keyword, you need to turn it into a regular expression to avoid matching the keyword table. For example, if you want to find all messages matching "flag" (using $simple_search) but don't want to match flagged messages, simply search for "[f]lag". Table_4.5._Simple_search_keywords Keyword Pattern modifier all ~A . ~A ^ ~A del ~D flag ~F new ~N old ~O repl ~Q read ~R tag ~T unread ~U The second type of simple search is to build a complex search pattern using $simple_search as a template. Mutt will insert your query properly quoted and search for the composed complex query. 3.3. Nesting and Boolean Operators Logical AND is performed by specifying more than one criterion. For example: ~t mutt ~f elkins would select messages which contain the word "mutt" in the list of recipients and that have the word "elkins" in the "From" header field. Mutt also recognizes the following operators to create more complex search patterns: * ! -- logical NOT operator * | -- logical OR operator * () -- logical grouping operator Here is an example illustrating a complex search pattern. This pattern will select all messages which do not contain "mutt" in the "To" or "Cc" field and which are from "elkins". Example_4.4._Using_boolean_operators_in_patterns !(~t mutt|~c mutt) ~f elkins Here is an example using white space in the regular expression (note the "'" and """ delimiters). For this to match, the mail's subject must match the "^Junk +From +Me$" and it must be from either "Jim +Somebody" or "Ed +SomeoneElse": '~s "^Junk +From +Me$" ~f ("Jim +Somebody"|"Ed +SomeoneElse")' Note If a regular expression contains parenthesis, or a vertical bar ("|"), you must enclose the expression in double or single quotes since those characters are also used to separate different parts of Mutt's pattern language. For example: ~f "me@(mutt\.org|cs\.hmc\.edu)" Without the quotes, the parenthesis wouldn't end. This would be separated to two OR'd patterns: ~f_me@(mutt\.org and cs\.hmc\.edu). They are never what you want. 3.4. Searching by Date Mutt supports two types of dates, absolute and relative. 3.4.1. Absolute Dates Dates must be in DD/MM/YY format (month and year are optional, defaulting to the current month and year) or YYYYMMDD. An example of a valid range of dates is: Limit to messages matching: ~d 20/1/95-31/10 Limit to messages matching: ~d 19950120-19951031 If you omit the minimum (first) date, and just specify "-DD/MM/YY" or "-YYYYMMDD", all messages before the given date will be selected. If you omit the maximum (second) date, and specify "DD/MM/YY-", all messages after the given date will be selected. If you specify a single date with no dash ("-"), only messages sent on the given date will be selected. You can add error margins to absolute dates. An error margin is a sign (+ or -), followed by a digit, followed by one of the units in Table 4.6, "Date units". As a special case, you can replace the sign by a "*" character, which is equivalent to giving identical plus and minus error margins. Table_4.6._Date_units Unit Description y Years m Months w Weeks d Days Example: To select any messages two weeks around January 15, 2001, you'd use the following pattern: Limit to messages matching: ~d 15/1/2001*2w 3.4.2. Relative Dates This type of date is relative to the current date, and may be specified as: * >offset for messages older than offset units * function, which is bound to "shift-T" by default. Or you can select individual messages by hand using the function, which is bound to "t" by default. See patterns for Mutt's pattern matching syntax. Once you have tagged the desired messages, you can use the "tag-prefix" operator, which is the ";" (semicolon) key by default. When the "tag-prefix" operator is used, the next operation will be applied to all tagged messages if that operation can be used in that manner. If the $auto_tag variable is set, the next operation applies to the tagged messages automatically, without requiring the "tag-prefix". In macros or push commands, you can use the operator. If there are no tagged messages, Mutt will "eat" the rest of the macro to abort it's execution. Mutt will stop "eating" the macro when it encounters the operator; after this operator the rest of the macro will be executed as normal. 6. Using Hooks A hook is a concept found in many other programs which allows you to execute arbitrary commands before performing some operation. For example, you may wish to tailor your configuration based upon which mailbox you are reading, or to whom you are sending mail. In the Mutt world, a hook consists of a regular expression or pattern along with a configuration option/command. See: * account-hook * charset-hook * crypt-hook * fcc-hook * fcc-save-hook * folder-hook * iconv-hook * index-format-hook * mbox-hook * message-hook * reply-hook * save-hook * send-hook * send2-hook for specific details on each type of hook available. Also see Message Composition Flow for an overview of the composition process. Note If a hook changes configuration settings, these changes remain effective until the end of the current Mutt session. As this is generally not desired, a "default" hook needs to be added before all other hooks of that type to restore configuration defaults. Example_4.5._Specifying_a_"default"_hook send-hook . 'unmy_hdr From:' send-hook ~C'^b@b\.b$' my_hdr from: c@c.c In Example 4.5, "Specifying a "default" hook", by default the value of $from and $realname is not overridden. When sending messages either To: or Cc: to , the From: header is changed to . 6.1. Message Matching in Hooks Hooks that act upon messages (message-hook, reply-hook, send-hook, send2-hook, save-hook, fcc-hook, index-format-hook) are evaluated in a slightly different manner. For the other types of hooks, a regular expression is sufficient. But in dealing with messages a finer grain of control is needed for matching since for different purposes you want to match different criteria. Mutt allows the use of the search pattern language for matching messages in hook commands. This works in exactly the same way as it would when limiting or searching the mailbox, except that you are restricted to those operators which match information Mutt extracts from the header of the message (i.e., from, to, cc, date, subject, etc.). For example, if you wanted to set your return address based upon sending mail to a specific address, you could do something like: send-hook '~t ^me@cs\.hmc\.edu$' 'my_hdr From: Mutt User ' which would execute the given command when sending mail to me@cs.hmc.edu. However, it is not required that you write the pattern to match using the full searching language. You can still specify a simple regular expression like the other hooks, in which case Mutt will translate your pattern into the full language, using the translation specified by the $default_hook variable. The pattern is translated at the time the hook is declared, so the value of $default_hook that is in effect at that time will be used. 6.2. Mailbox Matching in Hooks Hooks that match against mailboxes (folder-hook, mbox-hook) apply both regular expression syntax as well as mailbox shortcut expansion on the regexp parameter. There is some overlap between these, so special attention should be paid to the first character of the regexp. # Here, ^ will expand to "the current mailbox" not "beginning of string": folder-hook ^/home/user/Mail/bar "set sort=threads" # If you want ^ to be interpreted as "beginning of string", one workaround # is to enclose the regexp in parenthesis: folder-hook (^/home/user/Mail/bar) "set sort=threads" # This will expand to the default save folder for the alias "imap.example.com", which # is probably not what you want: folder-hook @imap.example.com "set sort=threads" # A workaround is to use parenthesis or a backslash: folder-hook (@imap.example.com) "set sort=threads" folder-hook '\@imap.example.com' "set sort=threads" Keep in mind that mailbox shortcut expansion on the regexp parameter takes place when the hook is initially parsed, not when the hook is matching against a mailbox. When Mutt starts up and is reading the .muttrc, some mailbox shortcuts may not be usable. For example, the "current mailbox" shortcut, ^, will expand to an empty string because no mailbox has been opened yet. Mutt will issue an error for this case or if the mailbox shortcut results in an empty regexp. 7. Managing the Environment You can alter the environment that Mutt passes on to its child processes using the "setenv" and "unsetenv" operators. (N.B. These follow Mutt-style syntax, not shell-style!) You can also query current environment values by prefixing a "?" character. setenv TERM vt100 setenv ORGANIZATION "The Mutt Development Team" unsetenv DISPLAY setenv ?LESS 8. External Address Queries Mutt supports connecting to external directory databases such as LDAP, ph/qi, bbdb, or NIS through a wrapper script which connects to Mutt using a simple interface. Using the $query_command variable, you specify the wrapper command to use. For example: set query_command = "mutt_ldap_query.pl %s" The wrapper script should accept the query on the command-line. It should return a one line message, then each matching response on a single line, each line containing a tab separated address then name then some other optional information. On error, or if there are no matching addresses, return a non-zero exit code and a one line error message. An example multiple response output: Searching database ... 20 entries ... 3 matching: me@cs.hmc.edu Michael Elkins mutt dude blong@fiction.net Brandon Long mutt and more roessler@does-not-exist.org Thomas Roessler mutt pgp There are two mechanisms for accessing the query function of Mutt. One is to do a query from the index menu using the function (default: Q). This will prompt for a query, then bring up the query menu which will list the matching responses. From the query menu, you can select addresses to create aliases, or to mail. You can tag multiple addresses to mail, start a new query, or have a new query appended to the current responses. The other mechanism for accessing the query function is for address completion, similar to the alias completion. In any prompt for address entry, you can use the function (default: ^T) to run a query based on the current address you have typed. Like aliases, Mutt will look for what you have typed back to the last space or comma. If there is a single response for that query, Mutt will expand the address in place. If there are multiple responses, Mutt will activate the query menu. At the query menu, you can select one or more addresses to be added to the prompt. 9. Mailbox Formats Mutt supports reading and writing of four different local mailbox formats: mbox, MMDF, MH and Maildir. The mailbox type is auto detected, so there is no need to use a flag for different mailbox types. When creating new mailboxes, Mutt uses the default specified with the $mbox_type variable. A short description of the formats follows. mbox. This is a widely used mailbox format for UNIX. All messages are stored in a single file. Each message has a line of the form: From me@cs.hmc.edu Fri, 11 Apr 1997 11:44:56 PST to denote the start of a new message (this is often referred to as the "From_" line). The mbox format requires mailbox locking, is prone to mailbox corruption with concurrently writing clients or misinterpreted From_ lines. Depending on the environment, new mail detection can be unreliable. Mbox folders are fast to open and easy to archive. MMDF. This is a variant of the mbox format. Each message is surrounded by lines containing "^A^A^A^A" (four times control-A's). The same problems as for mbox apply (also with finding the right message separator as four control-A's may appear in message bodies). MH. A radical departure from mbox and MMDF, a mailbox consists of a directory and each message is stored in a separate file. The filename indicates the message number (however, this is may not correspond to the message number Mutt displays). Deleted messages are renamed with a comma (",") prepended to the filename. Mutt detects this type of mailbox by looking for either .mh_sequences or .xmhcache files (needed to distinguish normal directories from MH mailboxes). MH is more robust with concurrent clients writing the mailbox, but still may suffer from lost flags; message corruption is less likely to occur than with mbox/mmdf. It's usually slower to open compared to mbox/mmdf since many small files have to be read (Mutt provides Section 8.1, "Header Caching" to greatly speed this process up). Depending on the environment, MH is not very disk-space efficient. Maildir. The newest of the mailbox formats, used by the Qmail MTA (a replacement for sendmail). Similar to MH, except that it adds three subdirectories of the mailbox: tmp, new and cur. Filenames for the messages are chosen in such a way they are unique, even when two programs are writing the mailbox over NFS, which means that no file locking is needed and corruption is very unlikely. Maildir maybe slower to open without caching in Mutt, it too is not very disk-space efficient depending on the environment. Since no additional files are used for metadata (which is embedded in the message filenames) and Maildir is locking-free, it's easy to sync across different machines using file-level synchronization tools. 10. Mailbox Shortcuts There are a number of built in shortcuts which refer to specific mailboxes. These shortcuts can be used anywhere you are prompted for a file or mailbox path or in path-related configuration variables. Note that these only work at the beginning of a string. Table_4.8._Mailbox_shortcuts Shortcut Refers to... ! your $spoolfile (incoming) mailbox > your $mbox file < your $record file ^ the current mailbox - or !! the file you've last visited ~ your home directory = or + your $folder directory @alias to the default save folder as determined by the address of the alias For example, to store a copy of outgoing messages in the folder they were composed in, a folder-hook can be used to set $record: folder-hook . 'set record=^' Note: the current mailbox shortcut, "^", has no value in some cases. No mailbox is opened when Mutt is invoked to send an email from the command-line. In interactive mode, Mutt reads the muttrc before opening the mailbox, so immediate expansion won't work as expected either. This can be an issue when trying to directly assign to $record, but also affects the fcc-hook mailbox, which is expanded immediately too. The folder-hook example above works because the command is executed later, when the folder-hook fires. Note: the $record shortcut "<" is substituted without any regard to multiple mailboxes and $fcc_delimiter. If you use multiple Fcc mailboxes, and also want to use the "<" mailbox shortcut, it might be better to set $record to the primary mailbox and use a fcc-hook to set all mailboxes during message composition. 11. Handling Mailing Lists Mutt has a few configuration options that make dealing with large amounts of mail easier. The first thing you must do is to let Mutt know what addresses you consider to be mailing lists (technically this does not have to be a mailing list, but that is what it is most often used for), and what lists you are subscribed to. This is accomplished through the use of the lists and subscribe commands in your .muttrc. Alternatively or additionally, you can set $auto_subscribe to automatically subscribe addresses found in a List-Post header. Now that Mutt knows what your mailing lists are, it can do several things, the first of which is the ability to show the name of a list through which you received a message (i.e., of a subscribed list) in the index menu display. This is useful to distinguish between personal and list mail in the same mailbox. In the $index_format variable, the expando "%L" will print the string "To " when "list" appears in the "To" field, and "Cc " when it appears in the "Cc" field (otherwise it prints the name of the author). Often times the "To" and "Cc" fields in mailing list messages tend to get quite large. Most people do not bother to remove the author of the message they reply to from the list, resulting in two or more copies being sent to that person. The function, which by default is bound to "L" in the index menu and pager, helps reduce the clutter by only replying to the known mailing list addresses instead of all recipients (except as specified by Mail-Followup-To, see below). Mutt also supports the Mail-Followup-To header. When you send a message to a list of recipients which includes one or several known mailing lists, and if the $followup_to option is set, Mutt will generate a Mail-Followup-To header. If any of the recipients are subscribed mailing lists, this header will contain all the recipients to whom you send this message, but not your address. This indicates that group-replies or list-replies (also known as "followups") to this message should only be sent to the original recipients of the message, and not separately to you - you'll receive your copy through one of the mailing lists you are subscribed to. If none of the recipients are subscribed mailing lists, the header will also contain your address, ensuring you receive a copy of replies. Conversely, when group-replying or list-replying to a message which has a Mail-Followup-To header, Mutt will respect this header if the $honor_followup_to configuration variable is set. Using list-reply will in this case also make sure that the reply goes to the mailing list, even if it's not specified in the list of recipients in the Mail-Followup-To. Note When header editing is enabled, you can create a Mail-Followup-To header manually. Mutt will only auto-generate this header if it doesn't exist when you send the message. The other method some mailing list admins use is to generate a "Reply-To" field which points back to the mailing list address rather than the author of the message. This can create problems when trying to reply directly to the author in private, since most mail clients will automatically reply to the address given in the "Reply-To" field. Mutt uses the $reply_to variable to help decide which address to use. If set to ask-yes or ask-no, you will be prompted as to whether or not you would like to use the address given in the "Reply-To" field, or reply directly to the address given in the "From" field. When set to yes, the "Reply-To" field will be used when present. While looking at an email message from a mailing list in the index or pager, you can interact with the list server in the ways defined by RFC 2369, provided the email message specifies how to do so. Invoke the list menu (bound to "ESC L" by default) to see what options are available for a given message. Common options are: * Post to the list * Contact the list owner * Subscribe to the list * Unsubscribe from the list * Get help from the list server * Get list archive information Note that many list servers only specify some of these options. The "X-Label:" header field can be used to further identify mailing lists or list subject matter (or just to annotate messages individually). The $index_format variable's "%y" and "%Y" expandos can be used to expand "X-Label:" fields in the index, and Mutt's pattern-matcher can match regular expressions to "X-Label:" fields with the "~y" selector. "X-Label:" is not a standard message header field, but it can easily be inserted by procmail and other mail filtering agents. You can change or delete the "X-Label:" field within Mutt using the "edit-label" command, bound to the "y" key by default. This works for tagged messages, too. While in the edit-label function, pressing the binding (TAB, by default) will perform completion against all labels currently in use. Lastly, Mutt has the ability to sort the mailbox into threads. A thread is a group of messages which all relate to the same subject. This is usually organized into a tree-like structure where a message and all of its replies are represented graphically. If you've ever used a threaded news client, this is the same concept. It makes dealing with large volume mailing lists easier because you can easily delete uninteresting threads and quickly find topics of value. 12. Display Munging Working within the confines of a console or terminal window, it is often useful to be able to modify certain information elements in a non-destructive way -- to change how they display, without changing the stored value of the information itself. This is especially so of message subjects, which may often be polluted with extraneous metadata that either is reproduced elsewhere, or is of secondary interest. subjectrx pattern replacement unsubjectrx { * | pattern } subjectrx specifies a regular expression "pattern" which, if detected in a message subject, causes the subject to be replaced with the "replacement" value. The replacement is subject to substitutions in the same way as for the spam command: %L for the text to the left of the match, %R for text to the right of the match, and %1 for the first subgroup in the match (etc). If you simply want to erase the match, set it to "%L%R". Any number of subjectrx commands may coexist. Note this well: the "replacement" value replaces the entire subject, not just the match! unsubjectrx removes a given subjectrx from the substitution list. If * is used as the pattern, all substitutions will be removed. Example_4.6._Subject_Munging # Erase [rt #12345] tags from Request Tracker (RT) e-mails subjectrx '\[rt #[0-9]+\] *' '%L%R' # Servicedesk is another RT that sends more complex subjects. # Keep the ticket number. subjectrx '\[servicedesk #([0-9]+)\] ([^.]+)\.([^.]+) - (new|open|pending|update ) - ' '%L[#%1] %R' # Strip out annoying [listname] prefixes in subjects subjectrx '\[[^]]*\]:? *' '%L%R' 13. New Mail Detection Mutt supports setups with multiple folders, allowing all of them to be monitored for new mail (see Section 16, "Monitoring Incoming Mail" for details). 13.1. How New Mail Detection Works For Mbox and Mmdf folders, new mail is detected by comparing access and/or modification times of files: Mutt assumes a folder has new mail if it wasn't accessed after it was last modified. Utilities like biff or frm or any other program which accesses the mailbox might cause Mutt to never detect new mail for that mailbox if they do not properly reset the access time. Other possible causes of Mutt not detecting new mail in these folders are backup tools (updating access times) or filesystems mounted without access time update support (for Linux systems, see the relatime option). Note Contrary to older Mutt releases, it now maintains the new mail status of a folder by properly resetting the access time if the folder contains at least one message which is neither read, nor deleted, nor marked as old. In cases where new mail detection for Mbox or Mmdf folders appears to be unreliable, the $check_mbox_size option can be used to make Mutt track and consult file sizes for new mail detection instead which won't work for size-neutral changes. New mail for Maildir is assumed if there is one message in the new/ subdirectory which is not marked deleted (see $maildir_trash). For MH folders, a mailbox is considered having new mail if there's at least one message in the "unseen" sequence as specified by $mh_seq_unseen. Mutt does not poll POP3 folders for new mail, it only periodically checks the currently opened folder (if it's a POP3 folder). For IMAP, by default Mutt uses recent message counts provided by the server to detect new mail. If the $imap_idle option is set, it'll use the IMAP IDLE extension if advertised by the server. The $mail_check_recent option changes whether Mutt will notify you of new mail in an already visited mailbox. When set (the default) it will only notify you of new mail received since the last time you opened the mailbox. When unset, Mutt will notify you of any new mail in the mailbox. 13.2. Polling For New Mail When in the index menu and being idle (also see $timeout), Mutt periodically checks for new mail in all folders which have been configured via the mailboxes command (excepting those specified with the -nopoll flag). The interval depends on the folder type: for local/IMAP folders it consults $mail_check and $pop_checkinterval for POP folders. Outside the index menu the directory browser supports checking for new mail using the function which is unbound by default. Pressing TAB will bring up a menu showing the files specified by the mailboxes command, and indicate which contain new messages. Mutt will automatically enter this mode when invoked from the command line with the -y option, or from the index/pager via the function. For the pager, index and directory browser menus, Mutt contains the function (bound to "." by default) which will print a list of folders with new mail in the command line at the bottom of the screen. For the index, by default Mutt displays the number of mailboxes with new mail in the status bar, please refer to the $status_format variable for details. When changing folders, Mutt fills the prompt with the first folder from the mailboxes list containing new mail (if any), pressing will cycle through folders with new mail. The (by default unbound) function in the index can be used to immediately open the next folder with unread mail (if any). 13.3. Monitoring New Mail When the Inotify mechanism for monitoring of files is supported (Linux only) and not disabled at compilation time, Mutt immediately notifies about new mail for all folders configured via the mailboxes command (excepting those specified with the -nopoll flag). Dependent on mailbox format also added old mails are tracked (not for Maildir). No configuration variables are available. Trace output is given when debugging is enabled via command line option -d3. The lower level 2 only shows errors, the higher level 5 all including raw Inotify events. Note Getting events about new mail is limited to the capabilities of the underlying mechanism. Inotify only reports local changes, i. e. new mail notification works for mails delivered by an agent on the same machine as Mutt, but not when delivered remotely on a network file system as NFS. Also the monitoring handles might fail in rare conditions, so you better don't completely rely on this feature. 13.4. Calculating Mailbox Message Counts If $mail_check_stats is set, Mutt will periodically calculate the unread, flagged, and total message counts for each mailbox watched by the mailboxes command. (Note: IMAP mailboxes only support unread and total counts). This calculation takes place at the same time as new mail polling, but is controlled by a separate timer: $mail_check_stats_interval. The sidebar can display these message counts. See $sidebar_format. 14. Editing Threads Mutt has the ability to dynamically restructure threads that are broken either by misconfigured software or bad behavior from some correspondents. This allows to clean your mailboxes from these annoyances which make it hard to follow a discussion. 14.1. Linking Threads Some mailers tend to "forget" to correctly set the "In-Reply-To:" and "References:" headers when replying to a message. This results in broken discussions because Mutt has not enough information to guess the correct threading. You can fix this by tagging the reply, then moving to the parent message and using the function (bound to & by default). The reply will then be connected to this parent message. You can also connect multiple children at once, tagging them and using the command (";") or the $auto_tag option. 14.2. Breaking Threads On mailing lists, some people are in the bad habit of starting a new discussion by hitting "reply" to any message from the list and changing the subject to a totally unrelated one. You can fix such threads by using the function (bound by default to #), which will turn the subthread starting from the current message into a whole different thread. 15. Delivery Status Notification (DSN) Support RFC1894 defines a set of MIME content types for relaying information about the status of electronic mail messages. These can be thought of as "return receipts." To support DSN, there are two variables. $dsn_notify is used to request receipts for different results (such as failed message, message delivered, etc.). $dsn_return requests how much of your message should be returned with the receipt (headers or full message). When using $sendmail for mail delivery, you need to use either Berkeley sendmail 8.8.x (or greater) a MTA supporting DSN command line options compatible to Sendmail: The -N and -R options can be used by the mail client to make requests as to what type of status messages should be returned. Please consider your MTA documentation whether DSN is supported. For SMTP delivery using $smtp_url, it depends on the capabilities announced by the server whether Mutt will attempt to request DSN or not. 16. Start a WWW Browser on URLs If a message contains URLs, it is efficient to get a menu with all the URLs and start a WWW browser on one of them. This functionality is provided by the external urlview program which can be retrieved at https://github.com/sigpipe/urlview and the configuration commands: macro index \cb |urlview\n macro pager \cb |urlview\n 17. Echoing Text Usage: echo message You can print messages to the message window using the "echo" command. This might be useful after a macro finishes executing. After printing the message, echo will pause for the number of seconds specified by $sleep_time. echo "Sourcing muttrc file" unset confirmappend macro index ,a "=archiveecho 'Saved to archi ve'" 18. Message Composition Flow This is a brief overview of the steps Mutt takes during message composition. It also shows the order and timing of hook execution. * Reply envelope settings. $reverse_name processing. To, Cc, Subject, References header defaults. * my_hdr processing for To, Cc, Bcc, Subject headers. * Prompts for To, Cc, Bcc, Subject headers. See $askcc, $askbcc, $fast_reply. * From header setting. Note: this is so send-hooks below can match ~P, but From is re-set further below in case a send-hook changes the value. * reply-hook * send-hook * From header setting. * my_hdr processing for From, Reply-To, Message-ID and user-defined headers. The To, Cc, Bcc, Subject, and Return-Path headers are ignored at this stage. * Message body and signature generation. * send2-hook * $realname part of From header setting. * $editor invocation for the message. * send2-hook * Cryptographic settings. * fcc-hook. Fcc setting. * Compose menu. Note: send2-hook is evaluated each time the headers are changed. * $send_multipart_alternative generation. * Message encryption and signing. Key selection. * Fcc saving if $fcc_before_send is set. (Note the variable documentation for caveats of Fcc'ing before sending.) * Message sending. * Fcc saving if $fcc_before_send is unset (the default). Note: prior to version 1.12, the Fcc was saved before sending the message. It is now by default saved afterwards, but if the saving fails, the user is prompted. 19. Batch Composition Flow In batch mode, Mutt performs less steps than interactive mode. Encryption and Signing are not supported. * my_hdr processing for To, Cc, Bcc headers. (Subject is not processed.) * From header setting. Note: this is so send-hooks below can match ~P, but From is re-set further below in case a send-hook changes the value. * send-hook * From header setting. * my_hdr processing for From, Reply-To, Message-ID and user-defined headers. The To, Cc, Bcc, Subject, and Return-Path headers are ignored at this stage. * Message body is copied from stdin. $signature is not appended in batch mode. * send2-hook * $realname part of From header setting. * fcc-hook. Fcc setting. * $send_multipart_alternative generation. * Fcc saving if $fcc_before_send is set. (Note the variable documentation for caveats of Fcc'ing before sending.) * Message sending. * Fcc saving if $fcc_before_send is unset (the default). Note: prior to version 1.12, the Fcc was saved before sending the message. It is now by default saved afterwards, but if the saving fails, the user is prompted. 20. Using MuttLisp (EXPERIMENTAL) MuttLisp is a Lisp-like enhancement for the Mutt configuration file. It is currently experimental, meaning new releases may change or break syntax. MuttLisp is not a real language, and is not meant to be an alternative to macros. The features are purposely minimal, with the actual work still being done by Mutt commands. There are two ways to invoke MuttLisp: via the run command, or interpolated as a command argument. 20.1. Running a command generated by MuttLisp Usage: run MuttLisp The run command evaluates the MuttLisp argument. The output of the MuttLisp is then executed as a Mutt command, as if it were typed in the muttrc instead. run (concat "set my_name = '" \ (or $ENV_NAME "Test User") "'") ==> generates and runs the line: set my_name = 'Test User' This will set the Mutt User-Defined Variable $my_name to either the environment variable $ENV_NAME, if defined, or else "Test User". 20.2. Interpolating MuttLisp in a Command Argument The second way of running is directly as a command argument. An unquoted parenthesis expression will be evaluated, and the result substituted as the argument. To avoid breaking existing configurations, this is disabled by default. It can be enabled by setting $muttlisp_inline_eval. Before doing so, you should review your Mutt configuration to ensure you don't have any bare parenthesis expressions elsewhere, such as the regexp parameter of a folder-hook. These can typically be surrounded by single or double-quotes to prevent being evaluated as MuttLisp. set my_name = (or $ENV_NAME "Test User") The result of the MuttLisp is directly assigned as the argument. It isn't reinterpreted, so there is no need for the outer quotes. This is in contrast with the run command, where the output is reinterpreted by the muttrc parser. 20.3. MuttLisp Syntax MuttLisp was inspired by Lisp, and so follows the same basic syntax. All statements are surrounded by parenthesis. The first argument inside the parenthesis is a function to invoke. The remaining arguments are passed as parameters. The arguments to functions are read and evaluated using muttrc syntax. This means Mutt variables or environment variables can be passed directly, or interpolated inside a double-quoted string. Although the arguments to a function are evaluated, the result of the function call is not. echo (concat '$' 'spoolfile') ==> $spoolfile MuttLisp has no types - everything is stored and evaluated as a string, just as with the muttrc. True is defined as a non-empty string, and false as the empty string. The muttrc is evaluated line by line, and MuttLisp is similarly constrained. Input can be continued on more than one line by placing a backslash at the end of the line. 20.4. MuttLisp Functions 20.4.1. concat Combines all arguments into a single string. echo (concat one two three) ==> onetwothree 20.4.2. quote Prevents interpretation of the list. Note that the list must still obey MuttLisp syntax: single quotes, double quotes, backticks, and parenthesis are still parsed prior to quote running and must be matching. echo (quote one two three) ==> one two three echo (quote $spoolfile) ==> $spoolfile echo (quote (one two three)) ==> (one two three) 20.4.3. equal Performs a case-sensitive comparison of each argument. Stops evaluating arguments when it finds the first one that is not equal. Returns "t" if they are all equal, and the empty string if not. echo (equal one one) ==> "t" echo (equal one `echo one`) ==> "t" echo (equal one one two `echo three`) ==> "" note: `echo three` does not execute. echo (equal "one two" `echo one two`) ==> "" note: backticks generate two arguments "one" and "two" echo (equal "one two" "`echo one two`") ==> "t" note: backticks inside double quotes generates a single argument: "one two" 20.4.4. not Accepts a single argument only. Returns "t" if the argument evaluates to the empty string. Otherwise returns the empty string. echo (not one) ==> "" echo (not "") ==> "t" echo (not (equal one two)) ==> "t" 20.4.5. and Returns the first argument that evaluates to the empty string. Otherwise returns the last argument, or "t" if there are no arguments. echo (and one two) ==> "two" echo (and "" two `echo three`) ==> "" note: `echo three` does not execute. echo (and) ==> "t" 20.4.6. or Returns the first argument that evaluates to a non-empty string. Otherwise returns the empty string. echo (or one two) ==> "one" echo (or "" two `echo three`) ==> "two" note: `echo three` does not execute. echo (or) ==> "" 20.4.7. if Requires 2 or 3 arguments. The first is a conditional. If it evaluates to "true" (a non-empty string), the second argument is evaluated and returned. Otherwise the third argument is evaluated and returned. echo (if a one two) ==> "one" echo (if "" one two) ==> "two" set spoolfile = "/var/mail/user" echo (if (equal $spoolfile "/var/mail/user") yes no) ==> "yes" Note that boolean configuration variables evaluate to the strings "yes" or "no". You can see the value of other kinds of configuration variables using the echo command. unset allow_ansi echo $allow_ansi ===> "no" # the correct way to test a boolean: echo (if (equal $allow_ansi "yes") "set" "unset") ===> "unset" # the incorrect way to test a boolean: echo (if $allow_ansi "set" "unset") ===> "set" 20.5. Examples It's important to remember that function arguments are evaluated, but the result is not. Also, the result of an interpolated command argument is used directly, and needs no quoting. # A three-way toggle of $index_format: set muttlisp_inline_eval set my_idx1 = "one" set my_idx2 = "two" set my_idx3 = "three" set index_format = $my_idx1 macro index i 'set index_format = \ (or \ (if (equal $index_format $my_idx1) $my_idx2) \ (if (equal $index_format $my_idx2) $my_idx3) \ $my_idx1) \ ' The output of the run command is re-evaluated by the muttrc parser. So it's important to pay more attention to quoting issues when generating the command string below. # Conditionally set up background editing in tmux or GNU Screen: run \ (if (or $STY $TMUX) \ (concat \ 'set background_edit;' \ 'set editor = "bgedit-screen-tmux.sh vim"') \ (concat \ 'unset background_edit;' \ 'set editor = "vim"')) Because backticks are evaluated by MuttLisp too, we need to use the run command below and pay close attention to quoting. # Use a Mutt variable inside backticks. set spoolfile = "/var/mail/testuser" # This will generate and then run the command string: # set my_var = "`~/bin/myscript.sh /var/mail/testuser`" run \ (concat \ 'set my_var = "`~/bin/myscript.sh ' \ $spoolfile \ '`"') 21. Miscellany This section documents various features that fit nowhere else. Address normalization Mutt normalizes all e-mail addresses to the simplest form possible. If an address contains a realname, the form Joe_User is used and the pure e-mail address without angle brackets otherwise, i.e. just joe@example.com. This normalization affects all headers Mutt generates including aliases. Initial folder selection The folder Mutt opens at startup is determined as follows: the folder specified in the $MAIL environment variable if present. Otherwise, the value of $MAILDIR is taken into account. If that isn't present either, Mutt takes the user's mailbox in the mailspool as determined at compile-time (which may also reside in the home directory). The $spoolfile setting overrides this selection. Highest priority has the mailbox given with the -f command line option. Chapter 5. Mutt's MIME Support Table_of_Contents 1. Using MIME in Mutt 1.1. MIME Overview 1.2. Viewing MIME Messages in the Pager 1.3. The Attachment Menu 1.4. The Compose Menu 2. MIME Type Configuration with mime.types 3. MIME Viewer Configuration with Mailcap 3.1. The Basics of the Mailcap File 3.2. Secure Use of Mailcap 3.3. Advanced Mailcap Usage 3.4. Example Mailcap Files 4. MIME Autoview 5. MIME Multipart/Alternative 6. Attachment Searching and Counting 7. MIME Lookup Quite a bit of effort has been made to make Mutt the premier text-mode MIME MUA. Every effort has been made to provide the functionality that the discerning MIME user requires, and the conformance to the standards wherever possible. When configuring Mutt for MIME, there are two extra types of configuration files which Mutt uses. One is the mime.types file, which contains the mapping of file extensions to IANA MIME types. The other is the mailcap file, which specifies the external commands to use for handling specific MIME types. 1. Using MIME in Mutt 1.1. MIME Overview MIME is short for "Multipurpose Internet Mail Extension" and describes mechanisms to internationalize and structure mail messages. Before the introduction of MIME, messages had a single text part and were limited to us-ascii header and content. With MIME, messages can have attachments (and even attachments which itself have attachments and thus form a tree structure), nearly arbitrary characters can be used for sender names, recipients and subjects. Besides the handling of non-ascii characters in message headers, to Mutt the most important aspect of MIME are so-called MIME types. These are constructed using a major and minor type separated by a forward slash. These specify details about the content that follows. Based upon these, Mutt decides how to handle this part. The most popular major type is "text" with minor types for plain text, HTML and various other formats. Major types also exist for images, audio, video and of course general application data (e.g. to separate cryptographically signed data with a signature, send office documents, and in general arbitrary binary data). There's also the multipart major type which represents the root of a subtree of MIME parts. A list of supported MIME types can be found in Table 5.1, "Supported MIME types". MIME also defines a set of encoding schemes for transporting MIME content over the network: 7bit, 8bit, quoted-printable, base64 and binary. There're some rules when to choose what for encoding headers and/or body (if needed), and Mutt will in general make a good choice. Mutt does most of MIME encoding/decoding behind the scenes to form messages conforming to MIME on the sending side. On reception, it can be flexibly configured as to how what MIME structure is displayed (and if it's displayed): these decisions are based on the content's MIME type. There are three areas/menus in dealing with MIME: the pager (while viewing a message), the attachment menu and the compose menu. 1.2. Viewing MIME Messages in the Pager When you select a message from the index and view it in the pager, Mutt decodes as much of a message as possible to a text representation. Mutt internally supports a number of MIME types, including the text major type (with all minor types), the message/rfc822 (mail messages) type and some multipart types. In addition, it recognizes a variety of PGP MIME types, including PGP/MIME and application/pgp. Mutt will denote attachments with a couple lines describing them. These lines are of the form: [-- Attachment #1: Description --] [-- Type: text/plain, Encoding: 7bit, Size: 10000 --] Where the Description is the description or filename given for the attachment, and the Encoding is one of the already mentioned content encodings. If Mutt cannot deal with a MIME type, it will display a message like: [-- image/gif is unsupported (use 'v' to view this part) --] 1.3. The Attachment Menu The default binding for is "v", which displays the attachment menu for a message. The attachment menu displays a list of the attachments in a message. From the attachment menu, you can save, print, pipe, delete, and view attachments. You can apply these operations to a group of attachments at once, by tagging the attachments and by using the operator. You can also reply to the current message from this menu, and only the current attachment (or the attachments tagged) will be quoted in your reply. You can view attachments as text, or view them using the mailcap viewer definition (the mailcap mechanism is explained later in detail). Finally, you can apply the usual message-related functions (like , and the and functions) to attachments of type message/rfc822. See table Table 9.7, "Default Attachment Menu Bindings" for all available functions. 1.3.1. Viewing Attachments There are four(!) ways of viewing attachments, so the functions deserve some extra explanation. (default keybinding: m) This will use the first matching mailcap entry. If no matching mailcap entries are found, it will abort with an error message. (default keybinding: ) Mutt will display internally supported MIME types (see Section 1.2, "Viewing MIME Messages in the Pager") in the pager. This will respect auto_view settings, to determine whether to use a copiousoutput mailcap entry or just directly display the attachment. Other MIME types will use the first matching mailcap entry. If no matching mailcap entries are found, the attachment will be displayed in the pager as raw text. Mutt will use the first matching copiousoutput mailcap entry to display the attachment in the pager (regardless of auto_view settings). If no matching mailcap entries are found, the attachment will be displayed in the pager as raw text. (default keybinding: T) The attachment will always be displayed in the pager as raw text. 1.4. The Compose Menu The compose menu is the menu you see before you send a message. It allows you to edit the recipient list, the subject, and other aspects of your message. It also contains a list of the attachments of your message, including the main body. From this menu, you can print, copy, filter, pipe, edit, compose, review, and rename an attachment or a list of tagged attachments. You can also modifying the attachment information, notably the type, encoding and description. Attachments appear as follows by default: - 1 [text/plain, 7bit, 1K] /tmp/mutt-euler-8082-0 2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz The "-" denotes that Mutt will delete the file after sending (or postponing, or canceling) the message. It can be toggled with the command (default: u). The next field is the MIME content-type, and can be changed with the command (default: ^T). The next field is the encoding for the attachment, which allows a binary message to be encoded for transmission on 7bit links. It can be changed with the command (default: ^E). The next field is the size of the attachment, rounded to kilobytes or megabytes. The next field is the filename, which can be changed with the command (default: R). The final field is the description of the attachment, and can be changed with the command (default: d). See $attach_format for a full list of available expandos to format this display to your needs. 2. MIME Type Configuration with mime.types To get most out of MIME, it's important that a MIME part's content type matches the content as closely as possible so that the recipient's client can automatically select the right viewer for the content. However, there's no reliable way for Mutt to know how to detect every possible file type. Instead, it uses a simple plain text mapping file that specifies what file extension corresponds to what MIME type. This file is called mime.types. When you add an attachment to your mail message, Mutt searches your personal mime.types file at $HOME/.mime.types, and then the system mime.types file at /usr/local/share/mutt/mime.types or /etc/mime.types Each line starts with the full MIME type, followed by a space and space-separated list of file extensions. For example you could use: Example_5.1._mime.types application/postscript ps eps application/pgp pgp audio/x-aiff aif aifc aiff A sample mime.types file comes with the Mutt distribution, and should contain most of the MIME types you are likely to use. If Mutt can not determine the MIME type by the extension of the file you attach, it will run the command specified in $mime_type_query_command. If that command is not specified, Mutt will look at the file. If the file is free of binary information, Mutt will assume that the file is plain text, and mark it as text/plain. If the file contains binary information, then Mutt will mark it as application/octet-stream. You can change the MIME type that Mutt assigns to an attachment by using the command from the compose menu (default: ^T), see Table 5.1, "Supported MIME types" for supported major types. Mutt recognizes all of these if the appropriate entry is found in the mime.types file. Non-recognized mime types should only be used if the recipient of the message is likely to be expecting such attachments. Table_5.1._Supported_MIME_types MIME major type Standard Description application yes General application data audio yes Audio data image yes Image data message yes Mail messages, message status information model yes VRML and other modeling data multipart yes Container for other MIME parts text yes Text data video yes Video data chemical no Mostly molecular data MIME types are not arbitrary, they need to be assigned by IANA. 3. MIME Viewer Configuration with Mailcap Mutt supports RFC 1524 MIME Configuration, in particular the Unix specific format specified in Appendix A of RFC 1524. This file format is commonly referred to as the "mailcap" format. Many MIME compliant programs utilize the mailcap format, allowing you to specify handling for all MIME types in one place for all programs. Programs known to use this format include Firefox, lynx and metamail. In order to handle various MIME types that Mutt doesn't have built-in support for, it parses a series of external configuration files to find an external handler. The default search string for these files is a colon delimited list containing the following files: 1. $HOME/.mailcap 2. $PKGDATADIR/mailcap 3. $SYSCONFDIR/mailcap 4. /etc/mailcap 5. /usr/etc/mailcap 6. /usr/local/etc/mailcap where $HOME is your home directory. The $PKGDATADIR and the $SYSCONFDIR directories depend on where Mutt is installed: the former is the default for shared data, the latter for system configuration files. The default search path can be obtained by running the following command: mutt -nF /dev/null -Q mailcap_path In particular, the metamail distribution will install a mailcap file, usually as /usr/local/etc/mailcap, which contains some baseline entries. 3.1. The Basics of the Mailcap File A mailcap file consists of a series of lines which are comments, blank, or definitions. A comment line consists of a # character followed by anything you want. A blank line is blank. A definition line consists of a content type, a view command, and any number of optional fields. Each field of a definition line is divided by a semicolon ";" character. The content type is specified in the MIME standard "type/subtype" notation. For example, text/plain, text/html, image/gif, etc. In addition, the mailcap format includes two formats for wildcards, one using the special "*" subtype, the other is the implicit wild, where you only include the major type. For example, image/*, or video will match all image types and video types, respectively. The view command is a Unix command for viewing the type specified. There are two different types of commands supported. The default is to send the body of the MIME message to the command on stdin. You can change this behavior by using %s as a parameter to your view command. This will cause Mutt to save the body of the MIME message to a temporary file, and then call the view command with the %s replaced by the name of the temporary file. In both cases, Mutt will turn over the terminal to the view program until the program quits, at which time Mutt will remove the temporary file if it exists. This means that mailcap does not work out of the box with programs which detach themselves from the terminal right after starting, like open on Mac OS X. In order to nevertheless use these programs with mailcap, you probably need custom shell scripts. So, in the simplest form, you can send a text/plain message to the external pager more on standard input: text/plain; more Or, you could send the message as a file: text/plain; more %s Perhaps you would like to use lynx to interactively view a text/html message: text/html; lynx %s In this case, lynx does not support viewing a file from standard input, so you must use the %s syntax. Note Some_older_versions_of_lynx_contain_a_bug_where_they_will_check_the mailcap_file_for_a_viewer_for_text/html._They_will_find_the_line_which calls_lynx,_and_run_it._This_causes_lynx_to_continuously_spawn_itself to_view_the_object. On the other hand, maybe you don't want to use lynx interactively, you just want to have it convert the text/html to text/plain, then you can use: text/html; lynx -dump %s | more Perhaps you wish to use lynx to view text/html files, and a pager on all other text formats, then you would use the following: text/html; lynx %s text/*; more 3.2. Secure Use of Mailcap The interpretation of shell meta-characters embedded in MIME parameters can lead to security problems in general. Mutt tries to quote parameters in expansion of %s syntaxes properly, and avoids risky characters by substituting them, see the $mailcap_sanitize variable. Although Mutt's procedures to invoke programs with mailcap seem to be safe, there are other applications parsing mailcap, maybe taking less care of it. Therefore you should pay attention to the following rules: Keep_the_%-expandos_away_from_shell_quoting. Don't quote them with single or double quotes. Mutt does this for you, the right way, as should any other program which interprets mailcap. Don't put them into backtick expansions. Be highly careful with evil statements, and avoid them if possible at all. Trying to fix broken behavior with quotes introduces new leaks -- there is no alternative to correct quoting in the first place. If you have to use the %-expandos' values in context where you need quoting or backtick expansions, put that value into a shell variable and reference the shell variable where necessary, as in the following example (using $charset inside the backtick expansion is safe, since it is not itself subject to any further expansion): text/test-mailcap-bug; cat %s; copiousoutput; test=charset=%{charset} \ && test "`echo $charset | tr '[A-Z]' '[a-z]'`" != iso-8859-1 3.3. Advanced Mailcap Usage 3.3.1. Optional Fields In addition to the required content-type and view command fields, you can add semi-colon ";" separated fields to set flags and other options. Mutt recognizes the following optional fields: copiousoutput This flag tells Mutt that the command passes possibly large amounts of text on standard output. This causes Mutt to invoke a pager (either the internal pager or the external pager defined by the pager variable) on the output of the view command. Without this flag, Mutt assumes that the command is interactive. One could use this to replace the pipe to more in the lynx -dump example in the Basic section: text/html; lynx -dump %s ; copiousoutput This will cause lynx to format the text/html output as text/plain and Mutt will use your standard pager to display the results. Mutt will set the COLUMNS environment variable to the width of the pager. Some programs make use of this environment variable automatically. Others provide a command line argument that can use this to set the output width: text/html; lynx -dump -width ${COLUMNS:-80} %s; copiousoutput Note that when using the built-in pager, only entries with this flag will be considered a handler for a MIME type -- all other entries will be ignored. needsterminal Mutt uses this flag when viewing attachments with auto_view, in order to decide whether it should honor the setting of the $wait_key variable or not. When an attachment is viewed using an interactive program, and the corresponding mailcap entry has a needsterminal flag, Mutt will use $wait_key and the exit status of the program to decide if it will ask you to press a key after the external program has exited. In all other situations it will not prompt you for a key. compose= This flag specifies the command to use to create a new attachment of a specific MIME type. Mutt supports this from the compose menu. composetyped= This flag specifies the command to use to create a new attachment of a specific MIME type. This command differs from the compose command in that Mutt will expect standard MIME headers on the data. This can be used to specify parameters, filename, description, etc. for a new attachment. Mutt supports this from the compose menu. print= This flag specifies the command to use to print a specific MIME type. Mutt supports this from the attachment and compose menus. edit= This flag specifies the command to use to edit a specific MIME type. Mutt supports this from the compose menu, and also uses it to compose new attachments. Mutt will default to the defined $editor for text attachments. nametemplate=