dovecot-1.0: If Sieve script didn't save the message anywhere, w...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jul 23 08:11:07 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/be2c4dacae2c
changeset: 5355:be2c4dacae2c
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jul 23 08:09:04 2007 +0300
description:
If Sieve script didn't save the message anywhere, we saved it to INBOX.

diffstat:

1 file changed, 21 insertions(+), 11 deletions(-)
src/deliver/deliver.c |   32 +++++++++++++++++++++-----------

diffs (47 lines):

diff -r 73a5e4b134f1 -r be2c4dacae2c src/deliver/deliver.c
--- a/src/deliver/deliver.c	Sat Jul 21 10:03:48 2007 +0300
+++ b/src/deliver/deliver.c	Mon Jul 23 08:09:04 2007 +0300
@@ -744,22 +744,32 @@ int main(int argc, char *argv[])
 		i_fatal("mail_set_seq() failed");
 
 	default_mailbox_name = mailbox;
-	if (deliver_mail != NULL)
-		(void)deliver_mail(storage, mail, destination, mailbox);
-
-	if (!saved_mail && !tried_default_save) {
+	if (deliver_mail == NULL)
+		ret = -1;
+	else {
+		if (deliver_mail(storage, mail, destination, mailbox) <= 0) {
+			/* if message was saved, don't bounce it even though
+			   the script failed later. */
+			ret = saved_mail ? 0 : -1;
+		} else {
+			/* success. message may or may not have been saved. */
+			ret = 0;
+		}
+	}
+
+	if (ret < 0 && !tried_default_save) {
 		/* plugins didn't handle this. save into the default mailbox. */
 		i_stream_seek(input, 0);
-		(void)deliver_save(storage, mailbox, mail, 0, NULL);
-	}
-	if (!saved_mail && strcasecmp(mailbox, "INBOX") != 0) {
+		ret = deliver_save(storage, mailbox, mail, 0, NULL);
+	}
+	if (ret < 0 && strcasecmp(mailbox, "INBOX") != 0) {
 		/* still didn't work. try once more to save it
 		   to INBOX. */
 		i_stream_seek(input, 0);
-		(void)deliver_save(storage, "INBOX", mail, 0, NULL);
-	}
-
-	if (!saved_mail) {
+		ret = deliver_save(storage, "INBOX", mail, 0, NULL);
+	}
+
+	if (ret < 0) {
 		const char *error, *msgid;
 		bool syntax, temporary_error;
 		int ret;


More information about the dovecot-cvs mailing list