1

Topic: iRedMail EE dovecot custom conf problem

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version: upgraded today to EE from 1.7.4
- Deployed via installer originally
- Linux/BSD distribution name and version: Debian 12.12
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes, til EE upgrade
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Putting custom settings in /opt/iredmail/custom/<software> worked fine for all software, except for custom dovecot-pgsql.conf settings.

This server has been modified to use the sdbox mail storage, a move I now regret but need to live with. This involves a few changes to dovecot.conf and putting my custom conf in /opt/iredmail/custom/dovecot/conf-enabled/dovecot.conf works fine.

But if I put a file in this directory named dovecot-pgsql.conf with my custom user_query string, Dovecot fails to start with error message "Unknown settings user_query." If I copy the entire contents of the dovecot-pgsql.conf file it takes issue with the very first config line: "Unknown setting: driver"

Can I specify custom user_query settings so the deploy / upgrade process doesn't overwrite? For now to get going I have hand-edited the file in the /etc/dovecot directory but I know that is over-written with any changes in the GUI.

For the record, my new user_query setting is below:

user_query = SELECT \
            '%u' AS master_user, \
            LOWER(CONCAT(mailbox.storagebasedirectory, '/', mailbox.storagenode, '/', mailbox.maildir)) AS home, \
            CONCAT('*:bytes=', mailbox.quota*1048576) AS quota_rule \
        FROM mailbox,domain \
       WHERE mailbox.username='%u' \
             AND mailbox.domain='%d' \
             AND mailbox."enable%Ls%Lc"=1 \
             AND mailbox.domain=domain.domain \
             AND domain.backupmx=0 \
             AND domain.active=1 \
             AND mailbox.active=1

The only difference from the original is the removal of this line:

            CONCAT(mailbox.mailboxformat, ':~/', mailbox.mailboxfolder) AS mail, \

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedMail EE dovecot custom conf problem

Hi,

Why not updating sql column `mailboxformat` and `mailboxfolder` to use mdbox format mailbox?

3 (edited by caretech 2025-09-18 07:33:37)

Re: iRedMail EE dovecot custom conf problem

Hi Zhang,

This server is not using mdbox but rather sdbox. We chose this to take advantage of deduplicated attachment storage. iRedMail's graphical config offers just two options, mdbox and maildir. sdbox is not a GUI option. The complete list of changes to make this happen:

In dovecot.conf:

# comment the original mail_location line, and add the following:
mail_location = sdbox:~/dbox
mail_attachment_dir = /var/vmail/attachments
mail_attachment_min_size = 64k

Then in dovecot-pgsql.conf, the user_query is modified as shown in my original post.

We will have to do a massive migration operation at some point to switch back to maildir, because Dovecot 2.4 drops support for sdbox. We are still running 2.3. But meantime I need a way to manually specify dovecot-pgsql overrides in custom config.

4

Re: iRedMail EE dovecot custom conf problem

As it stands now, when we do a Deploy all the mail disappears because dovecot is configured for maildir again and sees no messages. After manually editing config and restarting dovecot, all is normal.

5 (edited by gerald_martin 2025-09-18 09:14:49)

Re: iRedMail EE dovecot custom conf problem

Hi Zhang, @caretech is my sysadmin and performed the EE upgrade.

I know at one time it looked like dovecot was deprecating sdbox - but maybe they changed course?

I can't post links here, but you can search sdbox in Dovecot's docs and it appears to be supported in 2.4.0 and 2.4.1

Could you add an option to the EE interface to natively support sdbox storage?

Gerald

PS:  Edit, it appears what's being deprecated moving forward is the single instance storage / deduplication of attachments.  However it appears that dovecot 2.4 will continue to read the existing mail store, it just won't deduplicate attachments moving forward.

6

Re: iRedMail EE dovecot custom conf problem

- Why do you prefer sdbox over mdbox and maildir?
- You can set the mailbox format in sql column `mailbox.mailboxformat` (in lower case), e.g. "mdbox", "maildir". Also set mailbox folder in `vmail.mailboxfolder` (case sensitive). e.g. "mdbox", "Maildir".

I don't understand why you need to customize dovecot-pgsql.conf.

7 (edited by caretech 2025-09-18 09:39:54)

Re: iRedMail EE dovecot custom conf problem

ZhangHuangbin wrote:

- Why do you prefer sdbox over mdbox and maildir?

The switch to sdbox was, as stated, so we could enjoy deduplicated attachment storage. On some servers this nearly cuts the mail storage on disk in half. If several emails share the exact same attachment the file is stored only once instead of multiple copies of it.

After reading some more I realize that the sdbox format is staying but the single instance attachment storage part of it is being deprecated. Dovecot will continue to read the single-instance storage but will no longer write to it after upgrade to 2.4.

As far as why sdbox over mdbox, a mail guru I know told me the "one email per file" model of sdbox is more reliable than mdbox, which with multiple mails per file tends to have corruption issues more often. I have no mdbox experience but based on a long relationship with this person and observing his technical knowledge and skill, I am satisfied to trust his judgment.

Thanks for the sql database change suggestions, I'll give that a look later. It'll be a few days before I can get to it.

The bottom line is that now with single-instance attachment storage being deprecated, our whole reason to prefer sdbox over maildir is taken away. This is why I said I regret the move, in my first post.