HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=29)
-   -   ISPConfig3 automate Sent, Junk, Drafts folders (http://www.howtoforge.com/forums/showthread.php?t=31283)

ihamouda 13th February 2009 17:49

ISPConfig3 automate Sent, Junk, Drafts folders
 
Could somebody put me on the right direction.
I want to automate the creation of some IMAP folders with the creation of the email account.
I'm using ISPConfig3
I know some php, and I know maildirmake.
I just need to know which file to modify and around which line number

Thanks

till 18th February 2009 09:56

Take a look in the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php

andypl 23rd April 2009 11:20

Quote:

Originally Posted by till (Post 170129)
Take a look in the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php

I do not know the way to PHP and so I wanted to find out
what to add in this file to the newly created email account have directory
.Spam

rdv25772 23rd April 2009 12:14

Look and learn from excisting code
 
I learn by looking at code already used and alternate it as I would like to use it. I tried also to find out how something is working.

You might to look into the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php as Till stated and see how the Sent, Junk and Drafts folders are created. I will do the same.

Good luck

andypl 23rd April 2009 16:02

Quote:

Originally Posted by till (Post 170129)
Take a look in the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php

I added these two lines to function user_insert

Code:

                       
exec('mkdir -p '.escapeshellcmd($data['new']['maildir']).'/.Spam');
exec('mkdir -p '.escapeshellcmd($data['new']['maildir']).'/.NoSpam');


Code:

//* Create the maildir, if it doesn not exist, set permissions, set quota.
                if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
                        exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
                        $app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
                        //* Create .Spam and .NoSpam folder
                        exec('mkdir -p '.escapeshellcmd($data['new']['maildir']).'/.Spam');
                        exec('mkdir -p '.escapeshellcmd($data['new']['maildir']).'/.NoSpam');
                        //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
                        exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota b$
                        $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLE$

but there does not create any directories.

ihamouda 23rd April 2009 17:00

you need to add the maildirmake command not the mkdir command like the follwoing:

to add a .Spam folder use the -f option and don't forget the su -c surrounding the whole command


exec("su -c 'maildirmake -f Spam ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);

andypl 24th April 2009 10:22

Quote:

Originally Posted by ihamouda (Post 183871)
you need to add the maildirmake command not the mkdir command like the follwoing:

to add a .Spam folder use the -f option and don't forget the su -c surrounding the whole command


exec("su -c 'maildirmake -f Spam ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);

Still not working.

Code:

        function user_insert($event_name,$data) {
                global $app, $conf;

                //* get the config
                $app->uses("getconf");
                $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');

                $maildomain_path = $data['new']['maildir'];
                $tmp_basepath = $data['new']['maildir'];
                $tmp_basepath_parts = explode('/',$tmp_basepath);
                unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]);
                $base_path = implode('/',$tmp_basepath_parts);

                //* Create the mail domain directory, if it does not exist
                if(!empty($base_path) && !is_dir($base_path)) {
                        exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']);
                        $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG);
                }

                //* Create the maildir, if it doesn not exist, set permissions, set quota.
                if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
                        exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //* Create .Spam and .NoSpam folder
                        exec("su -c 'maildirmake -f Spam ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
                        $app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
                        //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
                        exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota b$
                        $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLE$
                }

                //* Set the maildir quota
                exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']);
                $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGL$
        }


ihamouda 24th April 2009 13:13

Re ; still not working
 
here is it, cut and paste from my working file:
Code:

if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
                        exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                        exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
                        $app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
                        //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
                        exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911
                        $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                }


Ovidiu 5th May 2009 14:28

looks good, but how do you get ispcfg3 to deliver spam into the Junk folder? :-)

ihamouda 5th May 2009 14:33

Re: Spam filter
 
If your spam is tagged in the subject, let's say your subject contains ***SPAM***, yo can just create a domain wide filter from the ISPConfig 3 interface to move to the .Junk


All times are GMT +2. The time now is 02:03.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.