I am looking for a way to save all attachments from an IMAP folder with 3000+ DMARC reports each of which is attached inside the individual messages as .zip or .xml.gz file. I am using Claws Mail which has a way to automate this (See Examples -> Save) through munpack. Unfortunately on openSUSE Leap 42.3 (which I use) there doesn't seem to be a package which provides munpack. After some web searching I found an alternative: metamail -wy suggested as an answer to this question.
Trying that directly in claws gave me some error (as not using properly the program). So I saved manually one message in a temp directory and tried from console:
[/tmp/download]: metamail -yw msg
Date: Mon, 03 Nov 2014 10:13:53 +0000
Subject: Report domain: ████████ Submitter: ████████
From: noreply-dmarc-support@google.com
To: ████████
This message contains data in an unrecognized format, application/zip,
which can either be viewed as text or written to a file.
What do you want to do with the application/zip data?
1 -- See it as text
2 -- Write it to a file
3 -- Just skip it
2
Please enter the name of a file to which the data should be written
(Default: ████████.zip) >
Wrote file ████████.zip
In other words: It works per se but it requires interactive input for each individual message - surely not an option for 3000+ mails.
My question is:
How can I use metamail in a way which doesn't require interactive input, so that it can be iterated (e.g. in a script or through Claws Mail's functinality)?