[imapfilter-devel] append message to mailbox
Lefteris Chatzimparmpas
lefcha at hellug.gr
Fri Sep 3 17:40:48 EEST 2010
Hello,
Such functions are not part of the official documentation, but as you
have already proved, this can be accomplished by using some lower level
API functions.
Thanks for posting your patches here, they may be useful to somebody.
I will also consider adding such functions since I believe other people
have already asked for uploading and optionally editing the messages to
be uploaded.
Cheers!
On 09/01/2010 06:24 PM, Daniel-Constantin Mierla wrote:
> Hello,
>
> I was searching documentation and API for a function that allows to
> upload an email message to imap server. Also, sometime I need to mangle
> headers (eg, some mailing lists don't have any prefix in subject and I
> want to add one), but I couldn't find existing API, hope I haven't
> missed something obvious.
>
> Not a heavy lua developer here, but I started to use it more lately for
> other purposes so I coded some extensions for imapfilter. If you find
> them useful, would be great to integrate in next version (improvements
> are welcome!).
>
> 1) http://bit.ly/azDCcT - here is a patch that adds new function to
> mailbox.lua:
> - append_plain_message(self, mplain, mflags, mdate) - upload a plain
> text formatted email message to imap server with respective flags and
> date - inspired from message copy/move to another imap server
>
> 2) http://bit.ly/cVSrIs - rawmessage.lua - new class to mangle plain
> text formatted email message (ie, add header, set header, prefix header,
> ...)
>
> Short sample of usage:
>
> require "rawmessage"
> ...
> all = accounta["unsorted"]:select_all()
> for tmp, mesg in ipairs(all) do
> mbox, uid = unpack(mesg)
> text = mbox[uid]:fetch_message()
> rawm = RawMessage(text)
> hdr = "X-My-Hdr: okey"
> rawm:add_header(hdr)
> rawm:prefix_header("X-My-Hdr", "-[prefix]-")
> accounta["sorted"]:append_plain_message(rawm:get_message(),
> table.concat(mbox[uid]:fetch_flags(), " "), mbox[uid]:fetch_date())
> -- you may want to delete it from "unsorted" now
> ...
> end
>
> Thanks,
> Daniel
>
More information about the Imapfilter-devel
mailing list