changeset 8024:8cb32b10a536 HEAD

deliver: Save mails to namespace prefix to INBOX instead.
author Timo Sirainen <tss@iki.fi>
date Sun, 20 Jul 2008 19:45:39 +0300
parents a90541a1192c
children 09295548c123
files src/deliver/deliver.c
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/deliver.c	Sun Jul 20 19:26:51 2008 +0300
+++ b/src/deliver/deliver.c	Sun Jul 20 19:45:39 2008 +0300
@@ -143,7 +143,8 @@
 
 static struct mailbox *
 mailbox_open_or_create_synced(struct mail_namespace *namespaces,
-			      struct mail_storage **storage_r, const char *name)
+			      struct mail_storage **storage_r,
+			      const char *name)
 {
 	struct mail_namespace *ns;
 	struct mailbox *box;
@@ -156,6 +157,12 @@
 	}
 	*storage_r = ns->storage;
 
+	if (*name == '\0') {
+		/* delivering to a namespace prefix means we actually want to
+		   deliver to the INBOX instead */
+		return NULL;
+	}
+
 	box = mailbox_open(ns->storage, name, NULL, MAILBOX_OPEN_FAST |
 			   MAILBOX_OPEN_KEEP_RECENT);
 	if (box != NULL || no_mailbox_autocreate)
@@ -192,9 +199,11 @@
 	struct mail_keywords *kw;
 	enum mail_error error;
 	const char *mailbox_name;
+	bool default_save;
 	int ret = 0;
 
-	if (strcmp(mailbox, default_mailbox_name) == 0)
+	default_save = strcmp(mailbox, default_mailbox_name) == 0;
+	if (default_save)
 		tried_default_save = TRUE;
 
 	mailbox_name = str_sanitize(mailbox, 80);
@@ -206,6 +215,11 @@
 				    mailbox_name);
 			return -1;
 		}
+		if (default_save &&
+		    strcmp((*storage_r)->ns->prefix, mailbox) == 0) {
+			/* silently store to the INBOX instead */
+			return -1;
+		}
 		deliver_log(mail, "save failed to %s: %s", mailbox_name,
 			    mail_storage_get_last_error(*storage_r, &error));
 		return -1;