-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 John Fawcett wrote: > > In the meantime, I'll look at making a patch to dbmail so that mailto > notify (as compatible with squirrelmail latest available sieve plugin) > can work. May be useful to someone else too, until all the software > catches up with the RFCs. > > John
so here's the first attempt at the patch for sieve notify in dbmail. I tested it using a script from squirrelmail avelsieve plugin v.1.9.7 and dbmail 2.2.9. Feedback is welcome from testers and also on coding improvements. I cannot remember what cyrus used to put in the subject line of the notify messages. In this patch I have hard coded "notify". Any suggestions? Another possible improvement would be to allow sites to configure a standard "from" address for notify messages to override the value used in individual scripts or indeed to enforce that the "from" address used should be the script owners email address. These configuration options could go into the dbmail.conf. For upgrading to the new ietf draft, should be fairly easy once libsieve is updated. I'm not sure I can help much with that. John -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFHvG3Td4I3jTtt9EIRArJ4AKCIywMriITtXVfnG+gn5OouiWV/FQCeIi/5 lyx9qUbWmyOcxMheMWWOUnc= =KAN2 -----END PGP SIGNATURE-----
diff -ur dbmail-2.2.9/modules/sortsieve.c dbmail-2.2.9-patch/modules/sortsieve.c --- dbmail-2.2.9/modules/sortsieve.c 2008-02-09 13:08:28.000000000 +0100 +++ dbmail-2.2.9-patch/modules/sortsieve.c 2008-02-20 18:42:45.000000000 +0100 @@ -187,13 +187,16 @@ if (!rc_from) rc_from = m->message->envelope_recipient->str; - rc_to = dbmail_message_get_header(m->message, "Reply-To"); + // squirrelmail avelsieve 1.9.7 uses options to store destination address for notification + // the new ietf draft will use a URI e.g. "mailto:[EMAIL PROTECTED]" - this codes does not yet support it + rc_to = options[0]; if (!rc_to) - rc_to = dbmail_message_get_header(m->message, "Return-Path"); - -// send_notification(m->message, rc_to, rc_from, method, message); + { + TRACE(TRACE_ERROR, "Notification from [%s] was not sent. No destination address specified in script.", rc_from); + return SIEVE2_OK; + } - TRACE(TRACE_INFO, "Notification from [%s] to [%s] was not sent as notify is not supported in this release.", rc_from, rc_to); + send_sieve_notification(m->message, rc_to, rc_from, method, message); return SIEVE2_OK; } @@ -660,7 +663,7 @@ } } if (sieve_config.notify) { - TRACE(TRACE_ERROR, "Sieve notify is not supported in this release."); + TRACE(TRACE_DEBUG, "Sieve notify enabled."); res = sieve2_callbacks(sieve2_context, notify_callbacks); if (res != SIEVE2_OK) { TRACE(TRACE_ERROR, "Error [%d] when calling sieve2_callbacks: [%s]", @@ -715,7 +718,7 @@ sieve2_callbacks(sieve2_context, vacation_callbacks); } if (sieve_config.notify) { - TRACE(TRACE_ERROR, "Sieve notify is not supported in this release."); + TRACE(TRACE_DEBUG, "Sieve notify enabled."); sieve2_callbacks(sieve2_context, notify_callbacks); } if (sieve_config.debug) { diff -ur dbmail-2.2.9/pipe.c dbmail-2.2.9-patch/pipe.c --- dbmail-2.2.9/pipe.c 2008-02-09 13:08:28.000000000 +0100 +++ dbmail-2.2.9-patch/pipe.c 2008-02-20 18:36:45.000000000 +0100 @@ -331,6 +331,46 @@ return result; } + +/* + * Send a notification from sieve. + */ + +int send_sieve_notification(struct DbmailMessage *message, const char *to, const char *from, const char *method, const char *body) +{ + const char * subject ="notify"; + const char * autosubheader; + int result; + + autosubheader = dbmail_message_get_header(message, "Auto-Submitted"); + if (autosubheader && strcasecmp(autosubheader, "sieve-notify") == 0) + { + TRACE(TRACE_MESSAGE, "Notification from [%s] to [%s] was not sent. Notify loop detected.", from, to); + return 1; + } + + if (!method) + { + TRACE(TRACE_ERROR, "Notification from [%s] to [%s] was not sent. No method specified in script.", from, to); + return 1; + } + + if (strcasecmp(method, "mailto") == 0) + { + struct DbmailMessage *new_message = dbmail_message_new(); + new_message = dbmail_message_construct(new_message, to, from, subject, body); + dbmail_message_set_header(new_message, "Auto-Submitted", "sieve-notify"); + result = send_mail(new_message, to, from, NULL, SENDMESSAGE, SENDMAIL); + dbmail_message_free(new_message); + + if(result) + TRACE(TRACE_ERROR, "Notification from [%s] to [%s] was not sent. Error in sending message.", from, to); + return result; + } + + TRACE(TRACE_ERROR, "Notification from [%s] to [%s] was not sent. Unsupported method [%s].", from, to, method); + return 1; +} /* * Send an automatic reply. diff -ur dbmail-2.2.9/pipe.h dbmail-2.2.9-patch/pipe.h --- dbmail-2.2.9/pipe.h 2008-02-09 13:08:28.000000000 +0100 +++ dbmail-2.2.9-patch/pipe.h 2008-02-20 18:22:27.000000000 +0100 @@ -51,5 +51,7 @@ int send_forward_list(struct DbmailMessage *message, struct dm_list *targets, const char *from); int send_alert(u64_t user_idnr, char *subject, char *body); +int send_sieve_notification(struct DbmailMessage *message, + const char *to, const char *from, const char *method, const char *body); #endif
_______________________________________________ Dbmail-dev mailing list Dbmail-dev@dbmail.org http://twister.fastxs.net/mailman/listinfo/dbmail-dev