Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 13th February 2009, 18:49
ihamouda ihamouda is offline
Junior Member
 
Join Date: Jan 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
Default 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
Reply With Quote
Sponsored Links
  #2  
Old 18th February 2009, 10:56
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,009
Thanks: 840
Thanked 5,651 Times in 4,461 Posts
Default

Take a look in the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 23rd April 2009, 12:20
andypl andypl is offline
Senior Member
 
Join Date: Mar 2006
Location: Warsaw, Poland
Posts: 100
Thanks: 1
Thanked 5 Times in 4 Posts
Default

Quote:
Originally Posted by till View Post
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
Reply With Quote
  #4  
Old 23rd April 2009, 13:14
rdv25772 rdv25772 is offline
Junior Member
 
Join Date: Apr 2009
Location: Deventer, The Netherlands
Posts: 26
Thanks: 2
Thanked 6 Times in 5 Posts
Default 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
Reply With Quote
  #5  
Old 23rd April 2009, 17:02
andypl andypl is offline
Senior Member
 
Join Date: Mar 2006
Location: Warsaw, Poland
Posts: 100
Thanks: 1
Thanked 5 Times in 4 Posts
Default

Quote:
Originally Posted by till View Post
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.
Reply With Quote
  #6  
Old 23rd April 2009, 18:00
ihamouda ihamouda is offline
Junior Member
 
Join Date: Jan 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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']);
Reply With Quote
The Following User Says Thank You to ihamouda For This Useful Post:
rdv25772 (24th April 2009)
  #7  
Old 24th April 2009, 11:22
andypl andypl is offline
Senior Member
 
Join Date: Mar 2006
Location: Warsaw, Poland
Posts: 100
Thanks: 1
Thanked 5 Times in 4 Posts
Default

Quote:
Originally Posted by ihamouda View Post
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$
        }
Reply With Quote
  #8  
Old 24th April 2009, 14:13
ihamouda ihamouda is offline
Junior Member
 
Join Date: Jan 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
Default 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);
		}
Reply With Quote
The Following User Says Thank You to ihamouda For This Useful Post:
Stown (9th September 2009)
  #9  
Old 5th May 2009, 15:28
Ovidiu Ovidiu is offline
Senior Member
 
Join Date: Sep 2005
Posts: 1,269
Thanks: 84
Thanked 25 Times in 21 Posts
Default

looks good, but how do you get ispcfg3 to deliver spam into the Junk folder? :-)
Reply With Quote
  #10  
Old 5th May 2009, 15:33
ihamouda ihamouda is offline
Junior Member
 
Join Date: Jan 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default 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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig3 mail issues warlock Developers' Forum 19 26th January 2009 11:34
Move junk mail to a folder instead of deleting grant Tips/Tricks/Mods 20 23rd October 2008 00:09
Mail folders aren't being created bswinnerton Installation/Configuration 3 4th May 2008 17:24


All times are GMT +2. The time now is 14:21.


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