Rename Junk folder in dovecot IMAP server

5,021

It is not Dovecot recreating the Trash folder; it is your mail client (Outlook in this case).

Some mail clients, when first setting up the definition, will probe the mail server to identify folders with the special use flags such as \Junk, and will then use these flagged folders for the special purpose. Others, such as Outlook, will just go ahead and do things their own way, and will create a folder with the name that they want to use regardless.

What you can do, is to use the mailbox_alias plugin to make both names valid. See here for an example, which makes both "Sent" and "Sent Items" equivalent: https://wiki2.dovecot.org/Plugins/MailboxAlias

Share:
5,021
musicmaker99
Author by

musicmaker99

Professional freelance software engineer with >20 years experience. C, C++ and Fortran on Windows, Linux and various flavours of Unix. Worked in oil, finance, security and defence industries.

Updated on September 18, 2022

Comments

  • musicmaker99
    musicmaker99 almost 2 years

    Being English, I find the terms "Trash" and "Junk" confusing because they mean essentially the same thing. I want to rename these folders on my Dovecot IMAP server to "Deleted" and "Spam" respectively because those terms mean more to me.

    So I changed 15-mailboxes.conf like this, instead of defining mailbox Junk:

    mailbox Spam {
      special_use = \Junk
      auto = subscribe
    }
    

    and similarly for Trash to Deleted.

    I'm assuming \Junk is a magic word and should not be changed. I also changed my sieve scripts to redirect mail to the new directory names. I also renamed the existing folders in the filesystem, Junk to Spam etc.

    When I restart Dovecot and connect an IMAP client (Outlook 2013 in this case) Dovecot still creates the old named folders as well as the new ones. So we have "Junk" as well as "Spam". "Junk" is newly created and empty.

    How do I suppress this behaviour? I just want "Spam" and "Deleted" on their own.

    Here the namespace of inbox

    namespace inbox {
    
      #mailbox name {
        # auto=create will automatically create this mailbox.
        # auto=subscribe will both create and subscribe to the mailbox.
        #auto = no
    
        # Space separated list of IMAP SPECIAL-USE attributes as specified by
        # RFC 6154: \All \Archive \Drafts \Flagged \Junk \Sent \Trash
        #special_use =
      #}
    
      # These mailboxes are widely used and could perhaps be created automatically:
      mailbox Drafts {
        special_use = \Drafts
        auto = subscribe
      }
      mailbox Spam {
        special_use = \Junk
        auto = subscribe
      }
      mailbox Deleted {
        special_use = \Trash
        auto = subscribe
      }
    
      # For \Sent mailboxes there are two widely used names. We'll mark both of
      # them as \Sent. User typically deletes one of them if duplicates are created.
      mailbox Sent {
        special_use = \Sent
        auto = subscribe
      }
    
      # If you have a virtual "All messages" mailbox:
      #mailbox virtual/All {
      #  special_use = \All
      #}
    
      # If you have a virtual "Flagged" mailbox:
      #mailbox virtual/Flagged {
      #  special_use = \Flagged
      #}
    }
    
    • NickW
      NickW over 9 years
      can you post your entire namespace inbox {} configuration?
    • NickW
      NickW over 9 years
      also, have you confirmed what Outlook 2013 wants to use as Trash and Spam folders? Because the MUA can also create folders automatically, if it is expecting them.
    • musicmaker99
      musicmaker99 over 9 years
      namespace inbox posted above
    • NickW
      NickW over 9 years
      So, have you seen what the Outlook 2013 client is subscribed to?
    • musicmaker99
      musicmaker99 over 9 years
      Trash and Junk are both special names as far as Outlook 2013 is concerned. You cannot unsubscribe from them.
    • Roger
      Roger over 6 years
      @musicmaker99 I'm not 100% sure, but i think these folders are created by the client. If your user uses different email clients (iOS, macOS, Windows, Web, etc.) you ending up with multiple of these folders, because the clients create them. You need to set this up for each IMAP client. I even seen this with same client, but different languages. On my Mac, I need to setup which folders to use for: Drafts, Deleted, Spam and Send.