-
Attaching files to Mutt messages
I moved to the Mutt email client in mid 2011. I wrote up some tips and tricks for using Mutt and OS X.
The interesting and somewhat annoying thing about Mutt is that sometimes features are so well hidden you only hear whispers and rumors about them.
This is one of those times.
Goal: Attach files to an email message without using Mutt’s file browser
Mutt’s has a built-in file browser which it uses to select mailboxes, save attachments, and attach files to the current outgoing message.
The reality of email in 2012 is that we’re attaching files to messages a lot. Ok, maybe “several times a week”, but hey, we’re on OS X - I don’t want to select files using some console interface.
Mutt has a solution: the
Attachpseudo headerOne of the “whispers and rumors” features of Mutt is the Attach pseudo header.
When it calls your editor of choice Mutt lets you edit the email headers of that message. This feature is the basis of the Attach pseudo header.
First, to get this to work, you must have
edit_headersset to yes.With
edit_headersset, when you open your editor you’ll seeFrom,To,Subjectetc.Deep in the Mutt documentation (manual section 2 subsection 2.4, second sub-sub section it talks about the
Attach:header.So, here’s how you use this:
- Create a new message or reply to an existing one in Mutt. This will trigger your editor
- If you want to attach a message, directly underneath the last header data you see, add a new new line that starts with
Attach:. Insert the path to the file to attach to the message.
Example of
Attachin useFrom: Ryan Wilcox <ryan@example.com> To: bob@example.com Cc: Bcc: Subject: Hello world Reply-To: Attach: ~/Documents/the.docWhen you exit your editor
the.docwill be attached to your message: you should see it in the attachment list in the Mutt outgoing message view.About whitespace
Like pretty much every Unix utility, Mutt’s
Attachfeature doesn’t handle whitespace in filenames. You must escape this whitespace using the\character.