IMAP Default Folders

Discussion in 'Installation/Configuration' started by themachine, Nov 5, 2005.

  1. themachine

    themachine New Member HowtoForge Supporter

    I'm trying to find the settings for the default MailDir config (if possible) or does ispconfig just run like a 'mkmaildir' command?

    Basically, I was the folders "Drafts" "Sent" "Spam" and "Trash" to exist by default.
     
  2. falko

    falko Super Moderator Howtoforge Staff

    ISPConfig does not create the folders within Maildir. It just tells Postfix/Sendmail to deliver emails to Maildir, and when the first email arrives, then the folders are created.

    But you can use the command maildirmake (see man maildirmake or http://www.die.net/doc/linux/man/man1/maildirmake.1.html ) to create custom folders. To do this automatically, you can change the function user_insert() in /root/ispconfig/scripts/lib/config.lib.php.
     
  3. Cirox

    Cirox New Member

    Hi,

    i think about the right code to put into this user_insert() function to set up a subfolder "Virus" and "Spam" in maildir for each user automaticly. But i really dont know how. Can you write down such code to put into at the right place ? Many thanks!

    greetings cirox
     
    Last edited: Apr 6, 2006
  4. falko

    falko Super Moderator Howtoforge Staff

    Have a look at
    Code:
    man maildirmake
    It should give you an idea.
     
  5. Cirox

    Cirox New Member

    Hi,

    ok i have read the man maildirmake, but i only know how to make shared folders an folders/subfolders for each user individually. But for me it will be important that this described subfolders will be made automaticly when mails arrive for each user which is created.

    So i dont know how to put in in user_insert().

    thanks

    greetings cirox
     
  6. falko

    falko Super Moderator Howtoforge Staff

    Do you have PHP programming knowledge? You could do it with a foreach loop, for example.
     
  7. Cirox

    Cirox New Member

    Hi,

    i dont have php coding knowledge, thats my problem ....

    greetings cirox
     
  8. falko

    falko Super Moderator Howtoforge Staff

    Have a look at the function user_insert() in /root/ispconfig/scripts/lib/config.lib.php. Somewhere around line 702 you could add something like this:

    PHP:
    if($mod->system->server_conf["use_maildir"]){
      
    exec("maildirmake ...");
    }
     
  9. Cirox

    Cirox New Member

    Hi,

    i cant solve the problem, here is the code around line 702:

    Code:
    // User-Mail-Datei anlegen, sonst evtl. Fehler bei Autoresponder
      if(!$mod->system->server_conf["use_maildir"]){
        if(!is_file("/var/spool/mail/".$user_username)){
          $mod->log->phpcaselog(touch("/var/spool/mail/".$user_username), "create /var/spool/mail/".$user_username, $this->FILE, __LINE__);
          $mod->log->caselog("chown $user_username:mail /var/spool/mail/$user_username &> /dev/null", $this->FILE, __LINE__);
          $mod->log->caselog("chmod 600 /var/spool/mail/$user_username", $this->FILE, __LINE__);
        }
      }
    
    now i want to create automaticly two folders "spam" and "virus" for each new mailbox.

    How to put into? Can you change the code, see above?

    greetings cirox
     
  10. falko

    falko Super Moderator Howtoforge Staff

    You would use something like this:

    PHP:
    // User-Mail-Datei anlegen, sonst evtl. Fehler bei Autoresponder
      
    if(!$mod->system->server_conf["use_maildir"]){
        if(!
    is_file("/var/spool/mail/".$user_username)){
          
    $mod->log->phpcaselog(touch("/var/spool/mail/".$user_username), "create /var/spool/mail/".$user_username$this->FILE__LINE__);
          
    $mod->log->caselog("chown $user_username:mail /var/spool/mail/$user_username &> /dev/null"$this->FILE__LINE__);
          
    $mod->log->caselog("chmod 600 /var/spool/mail/$user_username"$this->FILE__LINE__);
        }
      } else {
        
    exec("maildirmake ...");
      }
     
  11. Cirox

    Cirox New Member

    Hi,

    dont worry, i think i am a little bit stupid ;-)

    Now i have this code:

    Code:
    }
      } else {
        exec("maildirmake -f Spam mail/Maildir");
      } 
    
    it wont work. So i dont understand it. If i start squirrelmail, the folders .drafts etc will be created, but my question is how knows maildirmake,if this, see code above, is the right folder to create the folder "Spam" ?

    So i changed the code, like above, then i create a new user in ispconfig and nothing happens. No folder "Spam" for this new user.

    I think the folder is the problem.

    Code:
    }
      } else {
        exec("maildirmake -f Spam /$user_username/Maildir");
      } 
    
    isnt right, too.

    if i create it manually , its no problem:

    Code:
    maildirmake -f Spam /var/www/web9/Maildir/
    

    greetings cirox
     
    Last edited: May 1, 2006
  12. falko

    falko Super Moderator Howtoforge Staff

    You can try to use the full path to maildirmake in the script (run
    Code:
    which maildirmake
    to find out).

    /$user_username/Maildir would translate to something like /web1_someuser/Maildir which cannot be correct.

    Then use the same path in your script (of course, use the correct variables for the web ID and the username).
     
  13. Ovidiu

    Ovidiu Active Member

    sorry to revive this old thread but I found a plugin for squirrelmail that does exactly this. here is the description of the plugin:

    This plugin automates creation of special folders and subscriptions.
    It tries to provide options that are available only in some IMAP
    servers. If your IMAP server provides similar tools, it is strongly
    recommended to use IMAP server's tools instead of this plugin.

    http://www.squirrelmail.org/plugin_view.php?id=245
     
  14. finn

    finn New Member

    Hi Tenaka,
    sorry to revive this old thread again, but I was trying to achieve the same thing and after installing the Squirrelmail package from the ISPConfig site, I noticed that you can set an option in the Squirrelmail config to "Auto Create Special Folders" without installing the plugin.

    I used the config perl script:

    /home/admispconfig/ispconfig/web/squirrelmail/config/conf.pl

    and "Set pre-defined settings for specific IMAP servers" to courier, then option 3 is "Folder Defaults", and option 16 is "Auto Create Special Folders".

    Of course I guess this only works if you're using Squirrelmail.

    Did you find another way?
     

Share This Page