]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
deliver: Save mails to namespace prefix to INBOX instead.
authorTimo Sirainen <tss@iki.fi>
Sun, 20 Jul 2008 16:45:39 +0000 (19:45 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 20 Jul 2008 16:45:39 +0000 (19:45 +0300)
--HG--
branch : HEAD

src/deliver/deliver.c

index 696979e7133f1b0bd437152d0f2e07b9729a1b74..7f80289fd509d5466600a9c05c8aa441ef8642db 100644 (file)
@@ -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;