Sending all mail in IMAP folder from command line

Olli Savolainen olli at savolai.net
Sun Nov 15 20:53:10 UTC 2020


>>
>> 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?
>>
>
> It can be done, but it's a bit tricky.
>
> Put the following script somewhere in your path, and make it executable:
>
> #!/bin/sh
> printf "%s" "$1" > ~/.mutt/value
>
> Then execute the following script (after changing the "Drafts" and "Sent"
> value if necessary):
>
> #!/bin/bash
> mutt -e "push '<change-folder>=Drafts<enter><enter-command>set status_format = \"get_value '%m'|\"<return><quit>'"
> N=$(cat ~/.mutt/value)
> for ((;N>1;N--))
> do
> mutt -e 'set postponed = "=Drafts"; set record = "=Sent"; set editor=builtin;' -e 'push "<recall-message><select-entry>.<return><send-message><quit>"'
> done
> mutt -e 'set postponed = "=Drafts"; set record = "=Sent"; set editor=builtin;' -e 'push "<recall-message>.<return><send-message><quit>"'

Thanks a lot Gregory for clarifying what's possible! That's really helpful.
The script seems to be mixed with mutt-specific ui idioms though so I think I'll take a python route after all.

Olli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mutt.org/pipermail/mutt-users/attachments/20201115/f8ea36c3/attachment.html>


More information about the Mutt-users mailing list