11

I use v to open attachment list and select an item and hit s to save it.

Q1. Now where does Mutt save the attachment?

Q2. How to define a directory where I want to save attachments?

Thanks in advance.

shinokada
  • 2,537
  • 7
  • 34
  • 50

4 Answers4

24

By default, mutt saves attachments to whatever the current directory was when you started mutt.

If you want to save to a particular directory, cd to that directory before starting mutt:

cd mypreferreddirectory
mutt

mutt also allows you to define many powerful macros. To define a macro "W" for saving to a particular directory, put the following in your ~/.muttrc file:

macro attach W <save-entry><kill-line>/home/gawron/attachments/ 

For more on this, see the mutt FAQ.

John1024
  • 16,593
  • 5
  • 50
  • 45
  • 13
    If you use `` ("beginning of line") instead of ``, you can insert the path before the attachment name, instead of deleting the attachment name every time. Then add `` to set the cursor at the end of the line for easy editing of the attachment name. For example: `macro attach W "~/Desktop/" "Save to desktop"` – Steve HHH Nov 04 '14 at 19:59
  • If, like me, you want to bind a key to launching a terminal instance + opening mutt, do something like this (for urxvt): `urxvt -cd "your-preferred-directory" -e mutt`. Other terminal emulators work similarly. – Schiphol Feb 18 '21 at 10:37
4

There's no config option (AFAIK) but here's a simple work around.

The following alias will save your files into an "attachments" folder in your home directory:

alias mutt='cd $HOME/attachments;/usr/bin/mutt;cd -'

Add it to your .bashrc or .bash_profile.

dumolibr
  • 41
  • 1
4

After you hit s and before you hit Enter, mutt proposes a default file name (which is the original name of the attachment). At this point, you can provide mutt with a new directory (and with a different file name).

So if mutt proposes attach.ment, just fill in the path you need the file saved to, ~/your/desired/folder/attach.ment and hit Enter.

If you want to save attachments always in the same folder, John1024 describes how to do it.

xxm
  • 127
  • 1
  • 11
-1

This page suggest that procmail determines where the attachments are saved. In that case, check the file .procmailrc in your home directory. It should have a line like SAVE =$MAILDIR/save which specified where attachments are saved, likely defaulting to your mail directory. It should also have a line like MAILDIR =$HOME/Mail which will identify your mail directory.

In your case, it might be /home/shinokada/mail/save/.

Naturally, to specify where attachments are saved, just change the SAVE variable.

Synetech
  • 68,243
  • 36
  • 223
  • 356
  • I don't have .pocmailrc. – shinokada Jan 01 '14 at 05:19
  • Do you mean `.procmailrc`? If so, then I’m afraid I cannot find the location. There are a small handful of pages that refer to attachments and Mutt, but there is no information about where it is saved (it’s not even in the man-pages). You could try selecting a unique filename when you save one then doing a search for it. If you find the location, then you could try to grep for a file that contains that path. – Synetech Jan 01 '14 at 05:25