Sample Header Ad - 728x90

mutt: determine local path of current mail

2 votes
1 answer
777 views
**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 ` and ` may live in its own local folder structure:
Mail/
|-- /
|   |-- cur/
|   |   |-- 1584016380.RPi-18:2,
|   |   |-- 1595241604.RPi-18:2,
|   |   |-- 1603636018.RPi-18:2,
|   |   `-- 1612159655.RPi-18:2,
|   |-- new/
|   `-- tmp/
|-- /
|   |-- 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//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?**
Asked by nnako (21 rep)
Sep 27, 2021, 12:58 PM
Last activity: Oct 25, 2021, 02:30 PM