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
    [/FONT]

    2)
    Change the the ispconfig setup under Management for maildirs.

    3)
    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?)

    thanks,
    rustin
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Yes.

    You don't need this if you use ISPConfig.


    Correct.

    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

    Hi,

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

    Best regards,
    MvincM
     
  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:

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

    Code:
    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 mail.domain.ca (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;
            boundary="88F5F480CBD.1207853699/mail.domain.ca"
    Message-Id: <[email protected]>
    
    This is a MIME-encapsulated message.
    
    --88F5F480CBD.1207853699/mail.domain.ca
    Content-Description: Notification
    Content-Type: text/plain
    
    This is the Postfix program at host mail.domain.ca.
    
    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 name=ubuntu.domain.ca
        type=A: Host not found
    
    --88F5F480CBD.1207853699/mail.domain.ca
    Content-Description: Delivery report
    Content-Type: message/delivery-status
    
    Reporting-MTA: dns; mail.domain.ca
    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 name=ubuntu.domain.ca type=A: Host not found
    
    --88F5F480CBD.1207853699/mail.domain.ca
    Content-Description: Undelivered Message
    Content-Type: message/rfc822
    
    Received: from someotherdomain.ca (localhost [127.0.0.1])
            by mail.domain.ca (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
    
    
    --88F5F480CBD.1207853699/mail.domain.ca--
    
    harvey@ubuntu:/var/mail$
    
    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 @domain.com 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! :)

    Cheers
    Harvey
     
  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

    Hi,

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

    Regards
     
  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:

    Code:
    MAILDIR=$HOME/Maildir/
    DEFAULT=$MAILDIR
    ORGMAIL=$MAILDIR
    
    INCLUDERC=/var/www/web47/user/username/.mailsize.rc
    ## INCLUDERC=/var/www/web47/user/username/.quota.rc
    INCLUDERC=/var/www/web47/user/username/.antivirus.rc
    INCLUDERC=/var/www/web47/user/username/.local-rules.rc
    INCLUDERC=/var/www/web47/user/username/.html-trap.rc
    INCLUDERC=/var/www/web47/user/username/.spamassassin.rc
    INCLUDERC=/var/www/web47/user/username/.autoresponder.rc
    anybody has an ide whats going on...
     
  10. falko

    falko Super Moderator Howtoforge Staff

    You can try this:
    Code:
    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...

    Regards
     
  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):

    Code:
    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

    Code:
    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/user_domain.com/.procmailrc"
    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

    Thanks!!!
     
  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:
    http://http://www.howtoforge.com/forums/archive/index.php/t-10775.html

    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...

    Thanks!
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    I used the mb2md script to convert mailbox files:

    http://batleth.sapienti-sat.org/projects/mb2md/

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

    Code:
    <?
    
    // 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";
                            exec($command);
                            $command = "chown $username /tmp/mb2md_temp/cur/*";
                            echo $command."\n";
                            exec($command);
                            $command = "mv /tmp/mb2md_temp/cur/* $homedir/Maildir/new/";
                            echo $command."\n";
                            exec($command);
                            exec("rm -rf /tmp/mb2md_temp");
                            exec("rm -f $sourcefile");
                    }
            }
            closedir($dh);
            }
    }
    
    
    
    ?>
     
  16. blocker

    blocker Member

    YOU MADE MY DAY DUDE :D

    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...

    thanks
     
  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