Discussion:
[imapfilter-devel] Dated archive
Brendan Hide
2011-02-27 13:24:19 UTC
Permalink
Hi, all

I've been looking for hints or even a guide to dated archiving. As is
I'm filtering all read and old email into inbox.archive however this
folder is getting a bit big. I receive hundreds of emails every day,
many of which are automated mails which I don't normally need to give
attention to. Imapfilter moves these emails into the archive
automatically. Many automated emails I'm able to delete after a month or
so however some I have to keep on hand as reference.

As a result of the massive number of emails, my archive folder is
getting pretty big (edging on a couple of years of archive now) and it
actually puts load on the mail server when I open the folder.

If it hasn't already been done then I will do the leg work to make an
example available. However, I don't want to waste my time if there is a
really easy way to do this I haven't yet thought of or, of course, if it
has been done already. Here's an overview of how I'd like to resolve my
issue:

Emails in Inbox that are read and and/or from automated systems must be
moved into Inbox\archive (already implemented)
Mails in Inbox\archive\ older than 90 days must be moved into monthly
dated folders such as Inbox\archive\2010\11\

Thank you very much for your excellent work thus far. Imapfilter has
already made managing my email less a burden and more a pleasure. :)
--
__________
Brendan Hide
Mobile: +27 83 448 3867
Mobile: brendan.cell at swiftspirit.co.za (plain text only please)
Web Africa - Internet Business Solutions
http://www.webafrica.co.za/?AFF1E97
Rob Austein
2011-02-27 15:48:29 UTC
Permalink
This is what I use, after Lefteris straightened me out on a few of the
details. Hack as necessary.


-------------- next part --------------

myserver = IMAP {
server = "myserver.example.org",
username = "me",
password = "secret",
ssl = "tls1"
}

month = {
["Jan"] = "01", ["Feb"] = "02", ["Mar"] = "03", ["Apr"] = "04", ["May"] = "05", ["Jun"] = "06",
["Jul"] = "07", ["Aug"] = "08", ["Sep"] = "09", ["Oct"] = "10", ["Nov"] = "11", ["Dec"] = "12"
}

-- Archive old messages. This is (sort of) a recreation of something
-- that existed in the original 0.x version of imapfilter, rewritten
-- in LUA. Move old unflagged seen messages to archive mailboxes
-- named using the internal date of the message.

function archive(days, mailboxes)
for _, mailbox in ipairs(mailboxes) do
results = myserver[mailbox]:is_older(days) * myserver[mailbox]:is_seen() * myserver[mailbox]:is_unflagged()
targets = {}
for _, message in ipairs(results) do
mbox, uid = unpack(message)
date = mbox[uid]:fetch_date()
_, _, m, y = string.find(date, "%d+-(%a+)-(%d+)")
target = mailbox .. "." .. y .. "." .. month[m]
if targets[target] == nil then
targets[target] = Set {}
end
table.insert(targets[target], message)
end
for target, msgset in pairs(targets) do
msgset:move_messages(myserver[target])
end
end
end

archive(120, { "fee", "fie" })
archive(14, { "foe", "fum" })
Brendan Hide
2011-03-07 16:21:47 UTC
Permalink
Thank you so much, Rob. :)

Sorry so late on my response. I'll need to adjust the filter that
filtered this. ;)
Post by Rob Austein
This is what I use, after Lefteris straightened me out on a few of the
details. Hack as necessary.
myserver = IMAP {
server = "myserver.example.org",
username = "me",
password = "secret",
ssl = "tls1"
}
month = {
["Jan"] = "01", ["Feb"] = "02", ["Mar"] = "03", ["Apr"] = "04", ["May"] = "05", ["Jun"] = "06",
["Jul"] = "07", ["Aug"] = "08", ["Sep"] = "09", ["Oct"] = "10", ["Nov"] = "11", ["Dec"] = "12"
}
-- Archive old messages. This is (sort of) a recreation of something
-- that existed in the original 0.x version of imapfilter, rewritten
-- in LUA. Move old unflagged seen messages to archive mailboxes
-- named using the internal date of the message.
function archive(days, mailboxes)
for _, mailbox in ipairs(mailboxes) do
results = myserver[mailbox]:is_older(days) * myserver[mailbox]:is_seen() * myserver[mailbox]:is_unflagged()
targets = {}
for _, message in ipairs(results) do
mbox, uid = unpack(message)
date = mbox[uid]:fetch_date()
_, _, m, y = string.find(date, "%d+-(%a+)-(%d+)")
target = mailbox .. "." .. y .. "." .. month[m]
if targets[target] == nil then
targets[target] = Set {}
end
table.insert(targets[target], message)
end
for target, msgset in pairs(targets) do
msgset:move_messages(myserver[target])
end
end
end
archive(120, { "fee", "fie" })
archive(14, { "foe", "fum" })
_______________________________________________
Imapfilter-devel mailing list
Imapfilter-devel at lists.hellug.gr
http://lists.hellug.gr/mailman/listinfo/imapfilter-devel
--
__________
Brendan Hide
Mobile: +27 83 448 3867
Mobile: brendan.cell at swiftspirit.co.za (plain text only please)
Web Africa - Internet Business Solutions - http://www.webafrica.co.za/?AFF1E97

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hellug.gr/pipermail/imapfilter-devel/attachments/20110307/15d5c78d/attachment.html>
Continue reading on narkive:
Loading...