Sending all mail in IMAP folder from command line

raf mutt at raf.org
Sun Nov 15 22:18:46 UTC 2020


On Mon, Nov 16, 2020 at 08:19:21AM +1100, Cameron Simpson <cs at cskk.id.au> wrote:

> On 15Nov2020 09:56, Olli Savolainen <olli at savolai.net> wrote:
> >I have draft messages appearing in an imap folder. I would like to 
> >write a script that reads a message (or all messages) from that folder 
> >and sends it as it is, then moving the message to imap Sent folder.
> >
> >It seems something like mutt -H would do the job, just can’t figure
> >out how to get it to read the message from the imap Drafts folder
> >instead of a file.
> >
> >Also not sure what is the file format mutt -H expects if I were to
> >read the imap folder messages into a file first?
> >
> >(If mutt doesn’t work for this I would also welcome help in the form of 
> >strategic pointers. Also say, a php, python or powershell solution 
> >would be ok - if you know this particular task would be easy in some 
> >another ecosystem, tips are welcome. This seems like such a simple task 
> >to automate that I’m mainly trying to minimize amount of code I’ll need 
> >to maintain.)
> 
> Is this once off or to happen regularly?
> 
> You could for this:
> - save all the messages to a local filesystem maildir folder
> - write a short shell loop to run mutt -H for each message file in the 
>   maildir
> 
> Cheers,
> Cameron Simpson <cs at cskk.id.au>

Another option, especially if you need to do this a
lot, is to use imapfilter if you know (or want to
learn) lua (https://github.com/lefcha/imapfilter).

cheers,
raf



More information about the Mutt-users mailing list