Make ISPConfig to use of mbox mailboxes format instead of Maildir

Discussion in 'Tips/Tricks/Mods' started by Artie, Aug 23, 2016.

  1. Artie

    Artie New Member

    We have to migrate mails from very old IMAP/POP server to ISPConfig and one of major problems was that mailboxes on the old server have mbox format, while in ISPConfig Maildir is used.
    I have played much with some Mailbox-to-Maildir converting methods like Mb2MD, Dsync, ImapCopy, ...
    but none of them gave the expected result, since we wanted to automate migration of hundreds of large sized mailboxes and each tool failed for some mailbox/message losing some mails & not working perfectly.

    I have thought about one possibility, that I want to share and ask to comment on, if its good.
    The idea is to make ISPConfig (including dovecot and other parts) to work with mbox format instead of maildir.

    I have found the following workaround.

    Since in ISPConfig setup Dovecot is getting the mailbox format from 'mail_user' MySQL table,
    I have changed the following line in /etc/dovecot/dovecot-sql.conf:

    user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '1'

    To the following:

    user_query = SELECT email as user, maildir as home, CONCAT('mbox:', maildir, '/Mbox') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS
    quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '1'


    Next I wrote small shell script to move each users' mailboxes (in mbox format) to their directory for a particular domain in /var/vmail.
    For each user it would be: /var/vmail/$DOMAIN/$NEWUSERN/Mbox

    In our old server all mailboxes were kept in user's home directory in 'mail' subdirectory, where '.subscriptions' file was present too, so moving all that stuff to '/var/vmail/$DOMAIN/$NEWUSERN/Mbox' also keeps user's IMAP folder subscriptions as well.

    Also user's INBOX should be moved in the same directory and should be named: /var/vmail/$DOMAIN/$NEWUSERN/Mbox/inbox

    Additionally the script does: chown -R vmail:vmail /var/vmail/$DOMAIN/$NEWUSERN/Mbox

    After restarting dovecot it seems to start working.

    I ask ISPConfig experts/developers to comment on the above trick, and help me to undertand are there any missing or troublesome parts, so I can put my solution into production.

    Thanks in advance for any help.
     
    Last edited: Aug 24, 2016

Share This Page