[Discuss] Scripting IMAP for large numbers of messages?

Rich Pieri richard.pieri at gmail.com
Thu Jan 7 10:06:34 EST 2021


imapfilter might be the tool you need:
https://github.com/lefcha/imapfilter

I use it to move and expire mailing lists like so:

for i,mbox in ipairs(mailboxes) do
    print("Moving messages older than ".. move_older .." days in ".. mbox .." to Trash.")
    messages = account1[mbox]:is_older(move_older)
    messages:move_messages(account1['Trash'])
end

For your needs you would use arrived_before instead of is_older.

On Thu, 7 Jan 2021 09:32:37 -0500
Daniel Barrett <dbarrett at blazemonger.com> wrote:

> Has anyone done any scripting to manipulate email on a remote IMAP
> server? I'd like to select about 50,000 emails from an Inbox of
> ~80,000 (say, all emails from 2020) and move them to a different
> folder on the same IMAP server. I'm wondering if fetchmail or similar
> tools can do this (but am open to other suggestions).

-- 
Rich Pieri


More information about the Discuss mailing list