On Tue, 2007-07-03 at 21:13 +0300, Uldis Pakuls wrote: > > http://article.gmane.org/gmane.mail.imap.dovecot/20813/match > > > > Thanks, > I wrote this patch about 6 moth ago. As far, as I tested it, it works as > expected. Other users reports only success with this path too. > Timo: My be it's good idea to include this patch in CVS version? Anyway > original code only reports "generic error" as "notify" method is > unimplemented, and produces bounce messages.
Yes .. Although I have another version by Petr Smotek <[EMAIL PROTECTED]> as well. I haven't looked closely either of your patches, so want to tell me which one would be better? :) Attached the other one.
diff -u -r dovecot-sieve-1.0.1/src/libsieve/script.c dovecot-sieve-1.0.1-psm/src/libsieve/script.c --- dovecot-sieve-1.0.1/src/libsieve/script.c 2007-02-24 16:57:24.000000000 +0100 +++ dovecot-sieve-1.0.1-psm/src/libsieve/script.c 2007-02-24 10:49:06.000000000 +0100 @@ -330,8 +330,8 @@ build_msg = xmalloc(out_msglen + strlen(actions_string) + 30); strcpy(build_msg, out_msg); - strcat(build_msg, "\n\n"); - strcat(build_msg, actions_string); +// strcat(build_msg, "\n\n"); +// strcat(build_msg, actions_string); nc.message = build_msg; diff -u -r dovecot-sieve-1.0.1/src/sieve-cmu.c dovecot-sieve-1.0.1-psm/src/sieve-cmu.c --- dovecot-sieve-1.0.1/src/sieve-cmu.c 2006-10-10 21:44:54.000000000 +0200 +++ dovecot-sieve-1.0.1-psm/src/sieve-cmu.c 2007-02-24 16:52:59.000000000 +0100 @@ -253,31 +253,72 @@ } static int sieve_notify(void *ac __attr_unused__, - void *interp_context __attr_unused__, - void *script_context __attr_unused__, + void *ic __attr_unused__, + void *sc __attr_unused__, void *mc __attr_unused__, const char **errmsg __attr_unused__) { -#if 0 - const char *notifier = config_getstring(IMAPOPT_SIEVENOTIFIER); + sieve_notify_context_t *nc = (sieve_notify_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *md = (sieve_msgdata_t *) mc; + + int i = 0; + int ret = SIEVE_OK; + + /* mailto method? */ + if ( strcmp(nc->method, "mailto") == 0 ) { + + const char *from_addr; + from_addr = mail_get_first_header(md->mail, "To"); + + while (( nc->options[i] ) && ( ret == SIEVE_OK )) { + + FILE *f; + const char *outmsgid; + struct smtp_client *smtp_client; + + smtp_client = smtp_client_open(nc->options[i], NULL, &f); + outmsgid = deliver_get_new_message_id(); + + fprintf(f, "Message-ID: %s\r\n", outmsgid); + fprintf(f, "Date: %s\r\n", message_date_create(ioloop_time)); + fprintf(f, "X-Sieve: %s\r\n", SIEVE_VERSION); + fprintf(f, "From: <%s>\r\n", from_addr); + fprintf(f, "To: <%s>\r\n", nc->options[i]); + fprintf(f, "Subject: %s\r\n", "New mail notification"); + fprintf(f, "Precedence: bulk\r\n"); + if ( strcmp(nc->priority, "high") == 0 ) { + fprintf(f, "X-Priority: 1 (Highest)\r\n"); + fprintf(f, "Importance: High\r\n"); + } else if ( strcmp(nc->priority, "normal") == 0 ) { + fprintf(f, "X-Priority: 3 (Normal)\r\n"); + fprintf(f, "Importance: Normal\r\n"); + } else if ( strcmp(nc->priority, "low") == 0 ) { + fprintf(f, "X-Priority: 5 (Lowest)\r\n"); + fprintf(f, "Importance: Low\r\n"); + } + fprintf(f, "Content-Type: text/plain; charset=utf-8\r\n"); + fprintf(f, "Content-Transfer-Encoding: 8bit\r\n"); + fprintf(f, "\r\n"); + fprintf(f, "%s\r\n", nc->message); + + if (smtp_client_close(smtp_client) == 0) { + duplicate_mark(outmsgid, strlen(outmsgid), + sd->username, ioloop_time + DUPLICATE_DEFAULT_KEEP); + ret = SIEVE_OK; + } else { + *errmsg = "Error sending mail"; + ret = SIEVE_FAIL; + } + + i = i + 1; + } + } - if (notifier) { - sieve_notify_context_t *nc = (sieve_notify_context_t *) ac; - script_data_t *sd = (script_data_t *) script_context; - int nopt = 0; - - /* count options */ - while (nc->options[nopt]) nopt++; - - /* "default" is a magic value that implies the default */ - notify(!strcmp("default",nc->method) ? notifier : nc->method, - "SIEVE", nc->priority, sd->username, NULL, - nopt, nc->options, nc->message); - } -#endif - return SIEVE_FAIL; + return ret; } + static int autorespond(void *ac, void *ic __attr_unused__, void *sc,
signature.asc
Description: This is a digitally signed message part