[imapfilter-devel] Conditional Actions in config.lua

Lefteris Chatzimparmpas lefcha at hellug.gr
Sat Apr 17 16:56:37 EEST 2010


On 04/16/2010 01:32 AM, Paul wrote:
> Something like this:
>
> -- accounts
>
> account1 = IMAP { xxx }
>
> account2 = IMAP { yyy }
>
> results = account1.INBOX:select_all()
>
> if results:copy_messages(account2.incoming)
>    results:move_messages(archive)
> end

The target mailbox of move_messages() should be something like
account1.archive (I guess this is what you meant).


> -------------------
>
> So that if for any reason, the account2 imap server isn't available or the
> folder cannot be written to or whatever the error may be, the email
> messages are left where they are, and can be processed in the next run.
>
> However, it doesn't look like copy_messages has a return code, so I can't
> wrap an if around it.  I tried stopping the account2 imap server and while
> the copy_messages excepts, the move_messages still seems to action.
>
> Has anyone done something similar?

I believe copy_messages() returns true or false based on whether the
IMAP COPY command (or the IMAP APPEND command when copying to a
different server) was successful.  You can check that easily:

	ret = results:copy_messages(account2.incoming)
	print(ret)
	if (ret)
	...



More information about the Imapfilter-devel mailing list