CHALLENGE
I want to determine the local path of the currently viewed mail within mutt and transfer it to a bash script, before or after saving the mail to a local project folder.
CONCEPT
I am using mutt
together with offlineimap
and msmtp
in order to decouple my mail infrastructure from the necessity of a permanent internet connection. In doing so, I find my mails within the mailfile structure where each <PROJECT>
and <ACCOUNT>
may live in its own local folder structure:
Mail/
|-- <PROJECT>/
| |-- cur/
| | |-- 1584016380.RPi-18:2,
| | |-- 1595241604.RPi-18:2,
| | |-- 1603636018.RPi-18:2,
| | `-- 1612159655.RPi-18:2,
| |-- new/
| `-- tmp/
|-- <ACCOUNT>/
| |-- DRAFTS/
| | |-- cur/
| | |-- new/
| | `-- tmp/
| |-- INBOX/
...
When I browse my mail (using the index or pager view in mutt), I can select, tag, delete, ... open the respective mail element which is read by mutt from the sketched folder structure.
Now, I want to save the current message using mutt's save-message
function. But beforehand (or after the save), I want to automatically extract the message's attachment and possibly do some other stuff using the mail contents.
I already wrote a bash script which reads in the path of a mail file, e.g. ~/Mail/<PROJECT>/cur/1584016380.RPi-18:2
as its argument, and then stores the mail's attachments in a predefined location using the mu
command.
PROBLEM
I have looked within the available mutt variables (folder
, spoolfile
, from
, ...) in order to find anything that would tell me where my currently viewed mail file is actually located. But I could not find anything. So, I don't know which path to pass to my bash script for it to find the mail locally.
Is there anything usable, here?
pipe-message
, my target script does not know WHERE the piped messasge is to be saved. a target folder is determined while using mutt'ssave
command. not before that. I see two options: (1) is there a way to set a target folder for a message (which is originally done when using thesave
command) and transfer it to the script? and afterwards use it in thesave
command? (2) alternatively, thesave
command could be executed first, then pipe the message to the script. would there be a way to determine the target folder used bysave
?pipe-message
accepts an executable script as a target. not only a file. otherwise the function might better be calledredirect-message
, eh? would this be the case?