dovecot-1.0: If Sieve plugin returns any errors, ignore them. Bo...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 13 01:46:31 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/87d0ae7fbe12
changeset: 5344:87d0ae7fbe12
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 13 01:46:26 2007 +0300
description:
If Sieve plugin returns any errors, ignore them. Bounce the message only if
message couldn't be saved anywhere.

diffstat:

1 file changed, 15 insertions(+), 13 deletions(-)
src/deliver/deliver.c |   28 +++++++++++++++-------------

diffs (58 lines):

diff -r db0818972a19 -r 87d0ae7fbe12 src/deliver/deliver.c
--- a/src/deliver/deliver.c	Thu Jul 12 06:45:39 2007 +0300
+++ b/src/deliver/deliver.c	Fri Jul 13 01:46:26 2007 +0300
@@ -50,6 +50,7 @@ void (*hook_mail_storage_created)(struct
 
 /* FIXME: these two should be in some context struct instead of as globals.. */
 static const char *default_mailbox_name = NULL;
+static bool saved_mail = FALSE;
 static bool tried_default_save = FALSE;
 static bool no_mailbox_autocreate = FALSE;
 
@@ -146,9 +147,10 @@ int deliver_save(struct mail_storage *st
 	msgid = msgid == NULL ? "" : str_sanitize(msgid, 80);
 	mailbox_name = str_sanitize(mailbox_get_name(box), 80);
 
-	if (ret == 0)
+	if (ret == 0) {
+		saved_mail = TRUE;
 		i_info("msgid=%s: saved mail to %s", msgid, mailbox_name);
-	else {
+	} else {
 		const char *error;
 		bool syntax, temp;
 
@@ -742,22 +744,22 @@ int main(int argc, char *argv[])
 		i_fatal("mail_set_seq() failed");
 
 	default_mailbox_name = mailbox;
-	ret = deliver_mail == NULL ? 0 :
-		deliver_mail(storage, mail, destination, mailbox);
-
-	if (ret == 0 || (ret < 0 && !tried_default_save)) {
+	if (deliver_mail != NULL)
+		(void)deliver_mail(storage, mail, destination, mailbox);
+
+	if (!saved_mail && !tried_default_save) {
 		/* plugins didn't handle this. save into the default mailbox. */
 		i_stream_seek(input, 0);
-		ret = deliver_save(storage, mailbox, mail, 0, NULL);
-	}
-	if (ret < 0 && strcasecmp(mailbox, "INBOX") != 0) {
+		(void)deliver_save(storage, mailbox, mail, 0, NULL);
+	}
+	if (!saved_mail && strcasecmp(mailbox, "INBOX") != 0) {
 		/* still didn't work. try once more to save it
 		   to INBOX. */
 		i_stream_seek(input, 0);
-		ret = deliver_save(storage, "INBOX", mail, 0, NULL);
-	}
-
-	if (ret < 0) {
+		(void)deliver_save(storage, "INBOX", mail, 0, NULL);
+	}
+
+	if (!saved_mail) {
 		const char *error, *msgid;
 		bool syntax, temporary_error;
 		int ret;


More information about the dovecot-cvs mailing list