Softpanorama

May the source be with you, but remember the KISS principle ;-)
Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

Mutt

News SMTP Mail Recommended Books Recommended links 4 Ways to Send Email Attachment  Perl Mail Processing Scripts
 mail mailx Email Etiquette eMail Security Decoding Mime Attachments Mail aliases
Event correlation The Unix Haterís Handbook   Horror Stories  Humor Etc

Mutt is a small but very powerful text-based mail client that for the most part can replace old mail/mailx client. The current stable public release version is 1.4.2.3; the current development release version is 1.5.23.

One important feature of mutt is the it is able to attach files to the mail.

Other Mutt's features include:

Linux.ie Mutt Primer

by Brian Brazil

Mutt is a console based email client. It has built in support for multiple mail folders, POP and IMAP, PGP, aliases, mailing lists, powerful search capabilities and a pile of other stuff. Essentially it can handle a lot of email. This document assumes you are able to run commands in a shell.

Initial Setup

This is optional but will make Mutt a lot nicer to use.

Copy the following into your shell:

cat << "EOF" >> $HOME/.muttrc
set sort=threads
set pager_index_lines=5		#You might want to increase this
set pager_context=1
set index_format='%4C %Z %{%b %d} %-15.15F (%4l) %s'

#Different colors for different levels of quoting
color quoted    magenta         black
color quoted1   blue            black
color quoted2   red             black
color quoted3   yellow          black
color quoted4   cyan            black
color quoted5   blue            black
color quoted6   magenta         black
color quoted7   red             black
color quoted8   yellow          black
color quoted9   cyan            black
color signature blue            default

EOF

Starting Mutt

To start Mutt type

	mutt
	
in the shell. This will bring up something like
 

 

To quit press 'q'.

Moving Around

You are now in the index where all the messages in a folder are listed. Pressing '?'(question mark) will generally display all valid keys for a given screen. In the screenshot above you can see a full page of messages.

Handy Movement keys

The arrow keys as well as page up and page down work but shouldn't be depended on.

Looking at a message

Having selected a message pressing <Enter> or <Space> will open the message.
 
The bottom right corner indicates that only 45% of the message is shown.

Pressing <Space> will page froward while '-' (hyphen, dash or minus) will go back. 'j', 'k' and Tab work as above. 'q' or 'i' will go back to the index view.

You will note that some of the index view is shown - this is caused by the 'set pager_index_lines=5' in your Muttrc.

Sending Mail

Replying to mail

If you have a message selected as above pressing 'r' will reply to the sender. Mutt will verify the recipient and subject. You will then be dropped in an editor. Once you have finished creating your message and exited you will come to the compose screen:

 
 

Pressing 'y' will send the message. 'a' will allow you to attach files. 'e' edits the message. 'q' cancels sending the message.

If you want to reply to all recipients of a mail use 'g' instead of 'r'. It is considered bad practise to use 'g' on a mailing list - unless a CC is requested.

Sending a New Mail

From the pager or index menu pressing 'm' will allow you to send a new mail.

Alternatively from the command line you could type

	mutt bbrazil@netsoc.tcd.ie
	
to send me a mail.

 

Forwarding Mail

From the pager or index menu pressing 'f' will allow you to forward a mail. It will drop you in a n editor and allow you to make any changes necessary.

Another way(but a bit more advanced) is to use bounce ('b'). This will send an exact copy of a message to someone else.

Aliases

Tired of having to remember difficult email addresses? Aliases can help. In your Muttrc:

	alias brian bbrazil@netsoc.tcd.ie
	alias brazil bbrazil@netsoc.tcd.ie (Brian Brazil)	#With full name
	
You can also specify multiple addresses:
	alias lads joe@netsoc.tcd.ie, mick@tcd.ie, frank@netsoc.tcd.ie
	

 

Now any time Mutt asks you for an email address you can use brian, brazil or lads.

Deleting Mail

In the index or pager view:

 

Note that you will be asked if you really want to delete the messages when you leave the folder or quit.

Reading External Mail

Normally Mutt read mail that is stored on the server. It can access mail on other servers though. For this you can use IMAPS. If you run

	mutt -f imaps://brazilb@mail.tcd.ie	#Change as appropriate
	
you can read your Trinity Email address. Remember though that all you mail remains on tcd.ie servers.

 

If you would like to transfer all tcd.ie mail to your Matrix account use fetchmail(1).

Note: Instead of 'imaps' you can use 'imap', 'pops' or 'pop'. I prefer imaps because

  1. It remembers which messages you have already read
  2. It is encrypted (as is 'pops')
You can only use what you provider has available.

 

Advanced

If you have followed the Procmail Guide and have multiple mailboxes life can be a bit easier for you. Put the following in your Muttrc:

	mailboxes imaps://brazilb@mail.tcd.ie
	set imap_pass="my password"	#Can be used without procmail. Also: See warning below
	

 

Be very careful about putting your password in files. If you are sure you want to do this make sure your Muttrc is not world-readable or everyone will be able to see your password.

Mailing lists

Mutt has very good features for handling mailing lists. To enable them you must specify all the lists you are on. In you muttrc:

	subscribe ilug@linux.ie		#I'm on this list
	#Can have more than one on a line
	subscribe social@linux.ie southeast@linux.ie
	
	#I know these lists exist but I'm not on them
	list @lists.debian.org tech@netsoc.tcd.ie
	

Now all mailing lists will be marked by an 'L' which can be seen in the first screenshot.

Now if you want to reply to a list press 'L'. This will avoid sending copies to previous senders which is considered bad form. If a CC is requested use 'g' instead.

If you get a lot of mail from mailing lists you might want to look at my Procmail on Matrix guide.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Apr 01, 2015] mutt command with multiple attachments in single mail unix

Apr 01, 2015 | Stack Overflow

Andrzej A. Filip

My requirement is to attach all the .csv files in a folder and send them in a single mail.

Here is what have tried,
mutt -s "subject" -a *.csv -- abc@gmail.com < subject.txt


The above command is not working (It's not recognizing multiple files) and throwing the error
Error sending message, child exited 67 (User unknown.).
Could not send the message.


Then I tried using multiple -a option as follows,
mutt -s "subject" -a aaa.csv -a bbb.csv -- abc@gmail.com < subject.txt


This works as expected. But this is not feasible for 100 files for example. I should be able use it with file mask (as like *.csv to take all csv files). Is there is any way we can use like *.csv in single command?

qqx Jun 27 '13 at 12:57

What version of mutt are you using? A command like your first attempt worked for me with my copy compiled from a recent version of the mercurial repository, but support for that started with the 1.5.15 release.

Mari Jun 27 '13 at 13:26

@qqx Oh is it? It's great then. Am using Mutt 1.4.1.. Ė

user80168

Mutt doesn't support such syntax, but it doesn't mean it's impossible. You just have to build the mutt command.
mutt -s "subject" $( printf -- '-a %q ' *.csv ) ...


The command in $( ... ) produces something like this:
-a aaa.csv -a bbb.csv -a ...

My first mutt mutt overview

From now on, this guide is going to assume that you have mutt installed locally, start by typing mutt in your console and hit enter. You may get a couple of warnings straight away; Don't worry, let mutt create a ~/Mail folder in your home directory and don't panic if there is no spoolfile for your username - This won't be created until you actually receive some mail.

The index viewer

When you launch mutt, the first thing you see is a screen with a list of email messages. This initial menu is called the index.

These messages are in a default mailfolder, often called the mailspool, that you can think of as your 'inbox'. Use the k and j keys on your keyboard to move the highlighted cursor up and down the list of messages.

The pager

If you are in the index and you want to view the contents of an email, hit the enter key on your keyboard, this will take you from the index to the pager. Mutt's built-in pager is just a scrolling text viewer like the unix programs 'more' and 'less', use the backspace and enter keys to scroll up and down the email. Most of the commands that can be used in the index can also be used in the pager.

Quit the pager and return to the index by pressing the q key.

The attachment viewer

email has a structure that can include attached parts such as files as well as plain text messages. From the index, press the v key to view the attach menu where you can see the 'mime-structure' of the email displayed as a threaded list.

If there is more than one part to a message, you can use the k and j keys to move up and down the list and the enter key to view any item. If the attachment can be viewed by mutt's internal pager as plain text then it will. If not, mutt will try and launch a suitable external viewer, and wait for it to finish.

Quit the attachment viewer by pressing the q key on your keyboard

The file browser

To change from your mailspool to a different mailfolder, press the c key. You can now either type in the location of the folder you want to open, or press the ? key to open the file browser. Use the k and j keys to select the folder you want to switch-to and open it by hitting the spacebar.

Tab completion

A faster alternative to the file browser can be to take advantage of mutt's 'tab-completion'. Whenever you need to change folders, just hit c, type the first character or two of the folder's name and hit the tab key. Mutt will show you all the available options or simply fill in the rest of the name automatically.

Mutt supports tab completion everywhere, whether it's for files, addresses or even setting configuration options. This along with features like pervasive use of regular-expressions for pattern matching and command histories make mutt very fast to use compared with a mouse-oriented mailer.

The editor

In the index or pager views, hit the r key to reply to a message or the m key to create a new one. Mutt will prompt for the To: address and the Subject: line, then launch your favourite text editor (defined by your $EDITOR environmental variable). Type away, when you save and exit, you are done.

The compose menu

After the editor, mutt drops you into the compose menu, here you can fine-tune your message headers, change the encoding, add file attachments or simply hit the y key to say yes and send your email on its way.

The muttrc file

Mutt doesn't have a configuration interface, there is no properties menu or setup wizard. All configuration options can be changed at any time by typing a : followed by the relevant command. For example :unset help turns off the handy keyboard command hints at the top of the screen. To turn those hints back on, press up-arrow to retrieve the last command and change it so it says :set help.

If you can't remember the command you want to use, there is always tab-completion to help you.

You don't have to type all your preferred configuration commands each time you run mutt, you can save them in a file which is loaded every time the program starts up. This configuration file needs to exist in your home directory, it has to be called either ~/.muttrc or ~/.mutt/muttrc.

An example muttrc file is included with the distribution (look in docs/) or you can base yours on somebody else's such as Roland's .muttrc.

Context sensitive help

This overview has mentioned just a small number of basic mutt keyboard commands. Mutt has many more commands than you would want to remember, so when you are stuck, hit the ? key and mutt will present a list of all the key-bindings relevant to the current view.

Other sources of help

The mutt manual contains all the reference information you need to run and configure mutt. It also includes a complete step-by-step overview of mutt features, so read it.

If this overview has confused you, The Mutt Wiki has a lot of handy information including links to many other Mutt user pages in several languages. Otherwise, have a look at Randall Wood's mutt guide, Linda Harden's Learning Mutt or Norm Matloff's Introduction to mutt, they cover a lot of the same ground.

You can read the full manual at any time by hitting the f1 key on your keyboard, this is a pre-set macro that opens the local text-version in the 'less' pager. The mutt manual and the mutt FAQ should answer all the questions you have, if not then you can subscribe to one of the mutt mailing lists or visit the mutt usenet group and ask a question there.

Up | Next >>

This document was last modified on 2012-02-28 21:28:31.
Bruno Postle
Copyright © 2001 Bruno Postle and others. This guide is released under the Free Documentation License. http://www.gnu.org/licenses/fdl.txt

Recommended Links

Softpanorama hot topic of the month

Softpanorama Recommended

This primer is an altered version of my Mutt primer for Matrix(Netsoc Server) users. Changes include more information on external(i.e. POP3 and IMAP) mailboxes. You might be interested in the original.

 

Documentation

From the Releases:

From the Wiki:

From Other Sources:



Etc

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes.   If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner. 

ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.  

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least


Copyright © 1996-2016 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: December, 26, 2016