Changing from mbox to maildir after installing ISPConfig

Discussion in 'Installation/Configuration' started by Rustin, May 9, 2006.

  1. Rustin

    Rustin New Member

    Hello everyone,

    I've configured Debian 3.1 to Falko's 'perfect' spec with mbox style mail using popd for pop3 access. ISPConfig has been working great with no problems, I've even done two upgrades without a single issue (2.2.0 to 2.2.1 to 2.2.2 I think.). For some reason I wasn't thinking when I set the mail system up. What I really want is Courier with Maildirs. Currently there are no working mail accounts on the new server (I'm moving all my clients from an old server to ISPConfig setup); the only accounts I've created for each web is one for ftp access so I could transfer the websites. I've pretty much moved and configured everything except the mail.
    My old setup is a running qmail with vpopmail which makes me more comfortable with maildirs. However, I've been wanting to switch to postfix for some time now.

    Would this work (#1 and 2 taken from the howto):

    [FONT=Courier New, Courier, mono]1)[/FONT]
    [FONT=Courier New, Courier, mono]apt-get install courier-imap courier-imap-ssl courier-pop courier-pop-ssl[/FONT]

    [FONT=Courier New, Courier, mono]postconf -e 'home_mailbox = Maildir/'
    postconf -e 'mailbox_command ='
    [/FONT][FONT=Courier New, Courier, mono]
    /etc/init.d/postfix restart

    Change the the ispconfig setup under Management for maildirs.

    Remove the user accounts I created for ftp access and re-adding them. (will this create ownership issues of the existing /var/www/... files I ftp'ed with the old accounts?)

  2. falko

    falko Super Moderator Howtoforge Staff


    You don't need this if you use ISPConfig.


    Don't remove them. Just change something in the ISPConfig interface for these users, e.g. enable Mailscan and then disable it again later on. This will make ISPConfig rewrite the mail configuration for the users.
  3. MvincM

    MvincM New Member


    If you have old mails in mbox (not downloaded by clients) you can convert them to Maildir by "mb2md" program.

    Best regards,
  4. HardyHarvey

    HardyHarvey New Member

    Hi guys glad to find a thread with a similar query to my own.

    My situation is that I neglected to install courier-pop & etc before installing ISPConfig. I guess the install didn't check for it? I had installed postfix in advance though. Now we've got a dozen sites published and a customer that wants to have serious email support.. so we have to get email working after all.

    Check out this code and tell me how screwed up my installation is:

    harvey@ubuntu:~$ telnet localhost 25
    Connected to localhost.
    Escape character is '^]'.
    220 ESMTP Postfix (Ubuntu)
    mail from:[email protected]
    250 Ok
    rcpt to: [email protected]
    250 Ok
    354 End data with <CR><LF>.<CR><LF>
    To: [email protected]
    From: [email protected]
    Subject: test only
    test onlyi
    250 Ok: queued as 88F5F480CBD
    221 Bye
    Connection closed by foreign host.
    You have mail in /var/mail/harvey 
    :confused: :confused: :confused: :confused:

    harvey@ubuntu:~$ cd /var/mail
    harvey@ubuntu:/var/mail$ ls -la
    total 12
    drwxrwsr-x  2 root                mail 4096 2008-04-10 11:54 .
    drwxr-xr-x 15 root                root 4096 2008-03-16 20:10 ..
    -rw-------  1 someotherdomain  mail    0 2008-03-28 15:17 someotherdomain
    -rw-------  1 harvey               mail 2391 2008-04-10 11:54 harvey
    -rw-------  1 riccardo            mail    0 2008-04-08 08:03 riccardo
    -rw-------  1 web2_testuser       mail    0 2008-03-26 07:22 web2_testuser
    harvey@ubuntu:/var/mail$ cat harvey
    From MAILER-DAEMON  Thu Apr 10 11:54:59 2008
    Return-Path: <>
    X-Original-To: [email protected]
    Delivered-To: [email protected]
    Received: by (Postfix)
            id 98534480CC1; Thu, 10 Apr 2008 11:54:59 -0700 (PDT)
    Date: Thu, 10 Apr 2008 11:54:59 -0700 (PDT)
    From: [email protected] (Mail Delivery System)
    Subject: Undelivered Mail Returned to Sender
    To: [email protected]
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=delivery-status;
    Message-Id: <[email protected]>
    This is a MIME-encapsulated message.
    Content-Description: Notification
    Content-Type: text/plain
    This is the Postfix program at host
    I'm sorry to have to inform you that your message could not
    be delivered to one or more recipients. It's attached below.
    For further assistance, please send mail to <postmaster>
    If you do so, please include this problem report. You can
    delete your own text from the attached returned message.
                            The Postfix program
    <[email protected]> (expanded from <[email protected]>): Host
        or domain name not found. Name service error for
        type=A: Host not found
    Content-Description: Delivery report
    Content-Type: message/delivery-status
    Reporting-MTA: dns;
    X-Postfix-Queue-ID: 88F5F480CBD
    X-Postfix-Sender: rfc822; [email protected]
    Arrival-Date: Thu, 10 Apr 2008 11:54:06 -0700 (PDT)
    Final-Recipient: rfc822; [email protected]
    Original-Recipient: rfc822; [email protected]
    Action: failed
    Status: 5.0.0
    Diagnostic-Code: X-Postfix; Host or domain name not found. Name service error
        for type=A: Host not found
    Content-Description: Undelivered Message
    Content-Type: message/rfc822
    Received: from (localhost [])
            by (Postfix) with SMTP id 88F5F480CBD
            for <[email protected]>; Thu, 10 Apr 2008 11:54:06 -0700 (PDT)
    To: [email protected]
    From: [email protected]
    Subject: test only
    Message-Id: <[email protected]>
    Date: Thu, 10 Apr 2008 11:54:06 -0700 (PDT)
    test onlyi
    Why would I get the mail in my maildir? it's clearly to another email address.
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    If you want to get a stable email system, use maildir and not mbox for mail storage. Just redo all steps for the mail configuration from the perfect setup guide for your linux distribution and enable maildir support in ispconfig.
  6. HardyHarvey

    HardyHarvey New Member

    holy cow i think i missed a bunch of the pages to the ultimate install, or maybe just skipped over some? anyways was a while back that i installed it originally.

    It seems to be working for me now. My last concern is that the pop3 session takes only the username and not the domain, but i remember coming across a fix for this in one of the forums.

    IE i would like to have an [email protected] for each domain, each with it's own mailbox. 'telnet localhost pop3' requires that i don't use the trailing so i'm concerned that there would actually be more than one mailbox. for anyone named info at any of the domains we host..

    anyways THANKS! :)

  7. till

    till Super Moderator Staff Member ISPConfig Developer

    The part in front of the @ sign is not the username. Please do not mix up usernames and email addresses, this are 2 different fields in the user settings. Also ISPConfig uses a username prefix to avaoid the problem.
  8. blocker

    blocker Member


    is there a way to get ispconfig to "force-rewrite" the .procmailrc of every user on the system?

  9. blocker

    blocker Member

    maildir mailbox problem after server move

    i have moved a complete ispconfig server to another machine, everything is working perfect except that the old server uses mbox and i want the new to use Maildir

    i have made everything needed for the maildir but users that was moved from the old server still receive their mails in /var/mail/username

    example .procmailrc of such user:

    ## INCLUDERC=/var/www/web47/user/username/.quota.rc
    anybody has an ide whats going on...
  10. falko

    falko Super Moderator Howtoforge Staff

    You can try this:
    postconf -e 'home_mailbox = Maildir/'
    postconf -e 'mailbox_command ='
    /etc/init.d/postfix restart
  11. blocker

    blocker Member

    Hi, thanks for the reply,

    that was of course the first thing i have done regarding the perfect debian setup, but unfortunately it doesnt seem to work...

    Please help, i should move to maildir ASAP, mbox is making troubles, on the server there are 500 domains and more than 5000 mailboxes, every day some mailbox gets locked...

  12. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Post the output of:

    netstat -tap

    2) Post a excerpt of your mail log, that shows when a message is received.
    3) Check with repquota -avug, that the user and group quota of the accounts is not full.
  13. blocker

    blocker Member

    Thanks for the very quick response!!!

    netstat -tap (established connections are excluded):

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 *:imaps                 *:*                     LISTEN     2617/inetd
    tcp        0      0 *:mysql                 *:*                     LISTEN     569/mysqld
    tcp        0      0 *:pop3                  *:*                     LISTEN     26840/popa3d
    tcp        0      0 *:imap2                 *:*                     LISTEN     2617/inetd
    tcp        0      0 *:sunrpc                *:*                     LISTEN     2112/portmap
    tcp        0      0 *:81                    *:*                     LISTEN     343/ispconfig_httpd
    tcp        0      0 *:auth                  *:*                     LISTEN     2617/inetd
    tcp        0      0 *:ftp                   *:*                     LISTEN     7606/proftpd: (acce
    tcp        0      0 *:54869                 *:*                     LISTEN     2754/rpc.statd
    tcp        0      0 *:smtp                  *:*                     LISTEN     20447/master
    tcp6       0      0 *:www                   *:*                     LISTEN     22021/apache2
    tcp6       0      0 *:ssh                   *:*                     LISTEN     2707/sshd
    tcp6       0      0 *:smtp                  *:*                     LISTEN     20447/master
    tcp6       0      0 *:https                 *:*                     LISTEN     22021/apache2
    a piece of the mail.log

    Jun  9 10:28:01 server1 postfix/qmgr[20457]: 94FE5A8F58C: from=<[email protected]>, size=4268, nrcpt=1 (queue active)
    Jun  9 10:28:01 server1 procmail[26485]: Suspicious rcfile "/var/www/web_ID/user/"
    Jun  9 10:28:01 server1 postfix/local[25488]: 94FE5A8F58C: to=<[email protected]>, orig_to=<[email protected]>, relay=local, delay=0.96, delays=0.94/0/0/0.02, dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail -f-)
    Jun  9 10:28:01 server1 postfix/qmgr[20457]: 94FE5A8F58C: removed
    quota should be not full, as i have made the test i have adjusted the quota of the test domain and the test user very high but the mailsystem still saved the mails in /var/mail/username not in $HOME/Maildir, so i decided to revert the settings back to mbox. Now i have the uw-imap daemon and the popa3d, because with courier installed and mbox enabled users are unable to login to their mail accounts.
    BTW - some hint. In 1 of the posts above i have mentioned that the server is moved from another machine - on the old machine mailsystem was mbox. On the new i have set it to Maildir, but EVERY mailaccount of a user that was moved from the old to the new gets the mails in /var/mail/username, BUT newly created users got their mails in $HOME/Maildir, it was not the .procmailrc - i have pasted above an example of the .procmailrc file of an old a user which was setuped to get his mails in $HOME/Maildir but still got them in /var/mail/username

  14. blocker

    blocker Member

    Ok, now my server uses Maildir and it works perfect. The next problem approaches: converting /var/mail/username to $home/Maildir. In the archives i have found this:

    BUT it works only "whole" usernames, usernames containing "_" which are 90% of my usernames do not get converted. I need some help to understand why this happens...

  15. till

    till Super Moderator Staff Member ISPConfig Developer

    I used the mb2md script to convert mailbox files:

    I used the following small php shell script to convert all mbox files at once with the mb2md script:

    // This script converts the content of mailboxes in /var/spool/mail
    // to mail directories
    $dir = "/var/spool/mail/";
    if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && filesize("/var/spool/mail/".$file) > 0 && $file != 'Maildir') {
                            exec('mkdir /tmp/mb2md_temp');
                            $sourcefile = "/var/spool/mail/".$file;
                            $userid = fileowner($sourcefile);
                            $userinfo = posix_getpwuid($userid);
                            $username = $userinfo["name"];
                            $homedir = $userinfo["dir"];
                            $command = "/usr/bin/mb2md -s $sourcefile -d /tmp/mb2md_temp";
                            echo $command."\n";
                            $command = "chown $username /tmp/mb2md_temp/cur/*";
                            echo $command."\n";
                            $command = "mv /tmp/mb2md_temp/cur/* $homedir/Maildir/new/";
                            echo $command."\n";
                            exec("rm -rf /tmp/mb2md_temp");
                            exec("rm -f $sourcefile");
  16. blocker

    blocker Member


    thanks it works PERFECT!!!
  17. blocker

    blocker Member

    I still have problems with the move, some users/domains are receiving in the Maildir some are still receiving in /var/mail :eek:

    users that receive in /var/mail have a .procmailrc which is containing Mildir!, i have also tried removing the .procmailrc file but without it the mails still goes to /var/mail

    Please help!
  18. blocker

    blocker Member

    i remember now something...

    the current server is moved from an old ispconfig server, which had the remoting tool installed (stable+remoting tool). I think the domains/users that still receive their mail in /var/mail are created all with the remoting tool...
    So i think the problem should be somewhere in the DB of ispconfig, but where should i seek...

  19. blocker

    blocker Member

    Yes, whole domains are "jumping" over the global postfix config and over their users .procmailrc - this is really wired
    its like pain in the a$$
  20. blocker

    blocker Member

    deleting the user and then recreate it, does the trick, afterwards the user receives in $HOME/Maildir

    but why is that, i see myself like deleting thousands of users and restoring them
    Last edited: Jun 13, 2008

Share This Page