[critical] increasing mailbox size deletes all mail

Discussion in 'General' started by mmmexp, Oct 20, 2014.

  1. mmmexp

    mmmexp New Member


    after i have increased a mailbox size (when mailbox was full) all of the mails got deleted (every folder, everything). the user Maildir got reacreated as an empty one.

    This is happening for past two weeks for me and i can't find a reason for it.

    It happens even randomly, like adding something to 'send copy to' field (but not for all users, just random mailboxes).
  2. srijan

    srijan New Member HowtoForge Supporter

  3. mmmexp

    mmmexp New Member

    srijan, i don't see there any relevant information to my problem i.e. why email gets deleted?

    i tested even now:
    i have lowered mailbox quota a little bit and that mailbox just disappeared (ispconfig shows mailbox exist, but in /var/vmail/domain directory there is no mail anymore).
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    I guess you must have changed something in the base setup e.g that you changed the path layout for the mailboxes after you created the mailbox or something similar which causes that the maildir layout is considered as broken as essential subfolders were not found by the system. Additionally, such broken mailboxes dont get deleted, they just get moved to a save backup directory in /var/vmail/

    I maintain many mailservers for our customers and they change the quota of their meilboxes regularily and not a single mailbox got broken in the past years, so you can be sure that this is something specifixc to your server e.g. caused by a reconfiguration of the base paths aftter the initial setup.
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Another possibility is that you cahnged mailserver type from courier to dovecot or vice versa in system > server config mail without adjusting maildir paths.
  6. mmmexp

    mmmexp New Member

    till, it may be so.

    But how could i find the exact cause? (for example bad mailbox path or something like this?)

    i mean client was using his mailbox just fine and then he hit the limit of his mailobx (400mb), i have increased it to 500mb and /var/vmail/domain.com/xxx/Maildir/cur got emptied as well as other directories.

    then i tested another mailbox like this, i created it, then pumped in mail up to 80mb, then lowered limit to 50mb and whole directory got deleted (but ispconfig shows email exists).

    where does that gets configured? i need it badly.
  7. mmmexp

    mmmexp New Member

    yes i changed it when server was empty. (dovecot is default)

    i have created one domain to test and it was working fine.

    (all other domains/mails were added through API) and majority works fine, but some of mails have this problem - if i adjust quota - it disappears.
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Did you enable debug mode and then run the change in debug mode to see the exact output?

    The quota change is just triggering a mailbox update whcih caues also a check of the structure. And like I explained, it does not get emptied, the content gets moved to a directory for corrupted mailboxes.

    You are doing all this in the current version?
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Then it might be that you set a wrong value with the api. Compare a mailbox added with the api with a mailbox that you added manually, especially the fields that contain paths in the mail_user table in the dbispconfig database.
  10. mmmexp

    mmmexp New Member


    Till, you mentioned this "directory for corrupted mailboxes" but i don't find it, where does it move corrupted mailboxes?
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    The directory is /var/vmail/corrupted/

    But it might be that this function has been added in the p2 release and not p1 that you are using.
  12. mmmexp

    mmmexp New Member

    I see. I'll just update then.

    I have compared two rows one created through api and one through ispconfig and it has not difference.

    I tried on other mailbox, just changed any value, then at first minutes the directory or mailbox disappear and then on the second minute it gets recreated.

    So it deletes because it doesn't like something in directory structure like you have said, but if i compare directory structure that was before with that which is now - it is the same.

    Do you know the triggers (or where i can find them?) by which directory gets reacreated?
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Its in the mail_plugin.inc.php:

    //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
    		if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
    			if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
    			exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
    			$app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
  14. mmmexp

    mmmexp New Member

    Cool. Just added file content put function to that section so i could see the $maildomain_path when making any changes to mailbox.

    those mailboxes i moved through api got maildir format like this:


    but $maildomain_path requires that format should look like this:

    /var/mail/domain.com/mailbox (no slash at the end).

    i changed it in db directly and now everything is fine. lol. (postfix admin database had maildir with / at the end)

    maybe the checking is too strict (while / or no / , mailbox works anyway)

    quite trivial difference but teaches mindfulness.

    thanks again.

Share This Page