Sending all mail in IMAP folder from command line
Gregory Heytings
ghe at sdf.org
Sun Nov 15 19:29:51 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>"'
More information about the Mutt-users
mailing list