[Dovecot] Plugin Handle input messages

Timo Sirainen tss at iki.fi
Fri Jun 25 23:21:44 EEST 2010


On Mon, 2010-06-21 at 16:43 -0300, Alex Baule wrote:
>     if (imail->data.stream != NULL ||
>        (_mail->uid == 0 && zuser->save_handler == NULL)) {
>        return zmail->super.get_stream(_mail, hdr_size, body_size,
>                           stream_r);
>    }
> 
> I think this is the line that return the stream that is the stream sent by
> client.
> 
> I try to change this line and put inside this IF , a call to my function to
> handle with the input email from client. But i got some errors about the
> input part.

I'm not really sure what you mean by this. What input are you sending
where? Show some example non-working code?

> In other email, Timo said, to get the S and W flags in the email name, i
> need to intercept the email input from client to dovecot, in this part is
> done the W and S calculation.
> 
> Timo, where is the part that i can get the input from client ?

IIRC you wanted to add some extra headers to the mail (and you wanted it
to be visible to clients, right? if not, you could do it similarly than
how mbox hides some headers). All mails are saved via:

int mailbox_save_begin(struct mail_save_context **ctx, struct istream
*input);

And the input comes from there. You need to replace that input with your
own input stream that contains the wanted headers and other changes
(probably something built with istream-concat and
istream-header-filter). You can replace the input by overriding
mailbox.save_begin() method, for example see acl plugin how it uses
acl_save_begin(). Maybe something like:

static int
your_save_begin(struct mail_save_context *ctx, struct istream *input)
{
	struct mailbox *box = ctx->transaction->box;
	struct your_mailbox *abox = YOUR_CONTEXT(box);
	struct istream *new_input;
	int ret;

	new_input = build_changed_input(input);
	ret = abox->module_ctx.super.save_begin(ctx, new_input);
	i_stream_unref(&new_input);
	return ret;
}




More information about the dovecot mailing list