[imapfilter-devel] append message to mailbox
Daniel-Constantin Mierla
miconda at gmail.com
Tue Sep 7 18:59:24 EEST 2010
Hello,
On 9/3/10 4:40 PM, Lefteris Chatzimparmpas wrote:
> 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.
OK. Is it there a project tracker where I can upload the patches to be
used meanwhile by those interested?
Another question, does imapfilter have a local email headers parser or
all search commands are sent to imap server? It happens that some search
matches messages that have attached other emails and the matched header
is inside the attached email.
Cheers,
Daniel
>
> 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
>>
--
Daniel-Constantin Mierla
http://www.asipto.com
More information about the Imapfilter-devel
mailing list