From: Timo Sirainen Date: Sun, 20 Jul 2008 16:45:39 +0000 (+0300) Subject: deliver: Save mails to namespace prefix to INBOX instead. X-Git-Tag: 1.2.alpha1~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=30f0d58f9f2d4bf2b43c9368aa168ce47935fa84;p=thirdparty%2Fdovecot%2Fcore.git deliver: Save mails to namespace prefix to INBOX instead. --HG-- branch : HEAD --- diff --git a/src/deliver/deliver.c b/src/deliver/deliver.c index 696979e713..7f80289fd5 100644 --- a/src/deliver/deliver.c +++ b/src/deliver/deliver.c @@ -143,7 +143,8 @@ static void deliver_log(struct mail *mail, const char *fmt, ...) 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 @@ mailbox_open_or_create_synced(struct mail_namespace *namespaces, } *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 @@ int deliver_save(struct mail_namespace *namespaces, 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 @@ int deliver_save(struct mail_namespace *namespaces, 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;