[Dovecot] Developer Documentation
Hi Everyone....
I Try to make a modification in dovecot Maildir system....
I want to include lines from another file into every email when the user request to read this email.
Is Like put some extras itens email. I try to find how to do this but what i understand is, every email is read "on the fly", but i dont find exactly where... i didnt find some "read" to do this.
Some one can help me to do this ?
Tks !
Let me explain to you....
i want to split the email in header and body...my smtp server do this for me.... but, to read again in dovecot, i need to "point" the email to this two files.
This division in two parts is more like a test... and if the dovecot can join again this two files in "read time" is good for me....
There is no much reason to do that ? yes... i know... but like i say, its like a test to another thinks....
There is a way to do this ?
2009/12/9 Timo Sirainen <tss@iki.fi>
On Tue, 2009-12-08 at 21:42 -0200, Alex Baule wrote:
I want to include lines from another file into every email when the user request to read this email.
Why do you want this? Why not add the extra contents on the SMTP server side when the mail is being delivered?
On Wed, 2009-12-09 at 23:30 -0200, Alex Baule wrote:
Let me explain to you....
i want to split the email in header and body...my smtp server do this for me.... but, to read again in dovecot, i need to "point" the email to this two files.
This division in two parts is more like a test... and if the dovecot can join again this two files in "read time" is good for me....
So you're thinking maybe you get better performance that way, or something? I was first thinking you'd want to add some automatic signature that gets modified once in a while, that wouldn't have worked.
But yeah, you could do this with Maildir in a similar way than zlib plugin works. Instead of using i_stream_create_zlib(), you'd open the other file with i_stream_create_fd() and then make i_stream_create_concat() use both of the streams. Should be pretty easy to implement based on the zlib plugin code.
Also when messages get expunged, you'd also need to delete the other file yourself. You can do that the same way as quota plugin decreases quota when message gets deleted.
See http://wiki.dovecot.org/Design for more information about istreams and some other Dovecot code docs.
Hi Timo...
There is a way to do this with a plugin ? or you pass the zlib-plugin for reference ?
I can made this in the same monent the i_stream_create_fd() open the email in maildir,
and make a extra i_stream_create_fd() to my file.. then put this 2 streams (email + myfile)
in i_stream_create_concat()...
I will see the zlib-plugin code....
tks
2009/12/9 Timo Sirainen <tss@iki.fi>
On Wed, 2009-12-09 at 23:30 -0200, Alex Baule wrote:
Let me explain to you....
i want to split the email in header and body...my smtp server do this for me.... but, to read again in dovecot, i need to "point" the email to this two files.
This division in two parts is more like a test... and if the dovecot can join again this two files in "read time" is good for me....
So you're thinking maybe you get better performance that way, or something? I was first thinking you'd want to add some automatic signature that gets modified once in a while, that wouldn't have worked.
But yeah, you could do this with Maildir in a similar way than zlib plugin works. Instead of using i_stream_create_zlib(), you'd open the other file with i_stream_create_fd() and then make i_stream_create_concat() use both of the streams. Should be pretty easy to implement based on the zlib plugin code.
Also when messages get expunged, you'd also need to delete the other file yourself. You can do that the same way as quota plugin decreases quota when message gets deleted.
See http://wiki.dovecot.org/Design for more information about istreams and some other Dovecot code docs.
On Dec 10, 2009, at 7:33 AM, Alex Baule wrote:
Hi Timo...
There is a way to do this with a plugin ? or you pass the zlib-plugin for reference ?
You can do it with a plugin. I mention zlib plugin, because it works in a similar way by reading gzipped maildir files.
I can made this in the same monent the i_stream_create_fd() open the email in maildir,
and make a extra i_stream_create_fd() to my file.. then put this 2 streams (email + myfile)
in i_stream_create_concat()...
Right.
Ok ... i understand...
this is the last one...lol
in zib plugin i see a implementation of i_stream_create_zlib, this is a "substitution" to the i_stream_create_fd , right ?
So, i need to do every think like in istream-zlib.c (close, destroy, read, seek, stat and sync) to swap the original functions ?
I try to do a way to save some space in disc, spliting the head and body in 2 files....because sometimes the users have the same email (Cc/CCb).
Doing this, i will use 1 body to various headers....
In delivery by SMTP is easy, split in 2 and write the files... but in IMAP is more complicated....
Tks again !
2009/12/10 Timo Sirainen <tss@iki.fi>
On Dec 10, 2009, at 7:33 AM, Alex Baule wrote:
Hi Timo...
There is a way to do this with a plugin ? or you pass the zlib-plugin for reference ?
You can do it with a plugin. I mention zlib plugin, because it works in a similar way by reading gzipped maildir files.
I can made this in the same monent the i_stream_create_fd() open the email in maildir,
and make a extra i_stream_create_fd() to my file.. then put this 2 streams (email + myfile)
in i_stream_create_concat()...
Right.
On Dec 10, 2009, at 11:16 AM, Alex Baule wrote:
Ok ... i understand...
this is the last one...lol
in zib plugin i see a implementation of i_stream_create_zlib, this is a "substitution" to the i_stream_create_fd , right ?
So, i need to do every think like in istream-zlib.c (close, destroy, read, seek, stat and sync) to swap the original functions ?
No, you don't need to implement a new istream, just ignore istream-zlib.c completely. Instead of the plugin calling i_stream_create_zlib, you just call i_stream_create_concat.
Hi Timo....
For tests i do it:
In src/lib-storage/index/maildir/maildir-mail.c
In the final of function maildir_open_mail i change the i_stream_create_fd to this:
------- origin ------ int fd = -1; . . . . .
if (fd == -1) {
*deleted_r = TRUE;
return NULL;
}
input = i_stream_create_fd(fd, 0, TRUE);
index_mail_set_read_buffer_size(mail, input);
return input;
-------- my ------------ int fd = -1; int fd1 = -1; int fdp[2]; . . . . . . if (fd == -1) { *deleted_r = TRUE; return NULL; }
do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1); fdp[0] = fd; fdp[1] = fd1;
input = i_stream_create_concat(fdp);
index_mail_set_read_buffer_size(mail, input);
return input;
But the concat don't work.
I Try too create 2 streams and put this 2 fds in concat, not work too....
---------- my second ---------------- int fd = -1; int fd1 = -1; int fdp[2]; . . . . . . if (fd == -1) { *deleted_r = TRUE; return NULL; }
do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1); fdp[0] = fd; fdp[1] = fd1;
input = i_stream_create_fd(fd, 0, TRUE);
input = i_stream_create_fd(fd1, 0, TRUE);
input = i_stream_create_concat(fdp);
2009/12/10 Timo Sirainen <tss@iki.fi>
On Dec 10, 2009, at 11:16 AM, Alex Baule wrote:
Ok ... i understand...
this is the last one...lol
in zib plugin i see a implementation of i_stream_create_zlib, this is a "substitution" to the i_stream_create_fd , right ?
So, i need to do every think like in istream-zlib.c (close, destroy, read, seek, stat and sync) to swap the original functions ?
No, you don't need to implement a new istream, just ignore istream-zlib.c completely. Instead of the plugin calling i_stream_create_zlib, you just call i_stream_create_concat.
On Thu, 2009-12-10 at 18:10 -0200, Alex Baule wrote:
do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1); fdp[0] = fd; fdp[1] = fd1;
input = i_stream_create_fd(fd, 0, TRUE); input = i_stream_create_fd(fd1, 0, TRUE); input = i_stream_create_concat(fdp);
struct istream *full_input[3]; full_input[0] = i_stream_create_fd(fd, 0, TRUE); full_input[1] = i_stream_create_fd(fd1, 0, TRUE); full_input[2] = NULL; input = i_stream_create_concat(full_input);
Wow....
i am stupid ehehehehehe
concat the input, not the filedescriptor.....
Tks again... Now its working !
2009/12/10 Timo Sirainen <tss@iki.fi>
On Thu, 2009-12-10 at 18:10 -0200, Alex Baule wrote:
do_open(mbox, "/storage/emexis/
exemplo.com.br/messages/alex/Maildir/body_test", &fd1); fdp[0] = fd; fdp[1] = fd1;
input = i_stream_create_fd(fd, 0, TRUE); input = i_stream_create_fd(fd1, 0, TRUE); input = i_stream_create_concat(fdp);
struct istream *full_input[3]; full_input[0] = i_stream_create_fd(fd, 0, TRUE); full_input[1] = i_stream_create_fd(fd1, 0, TRUE); full_input[2] = NULL; input = i_stream_create_concat(full_input);
participants (2)
-
Alex Baule
-
Timo Sirainen