PDA

View Full Version : ISPConfig3 automate Sent, Junk, Drafts folders


ihamouda
13th February 2009, 18:49
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, 10:56
Take a look in the file /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php

andypl
23rd April 2009, 12:20
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, 13:14
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, 17:02
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


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



//* 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, 18: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, 11:22
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.

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, 14:13
here is it, cut and paste from my working file:
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);
}

Tenaka
5th May 2009, 15:28
looks good, but how do you get ispcfg3 to deliver spam into the Junk folder? :-)

ihamouda
5th May 2009, 15:33
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

Tenaka
5th May 2009, 23:41
sounds all like good advice, still 2 more questions:

- can't find a domain wide filter, only the mailboxes seem to have a fitler attached, I wouldn't want to set this filter up for every emailbox manually or am I just not seeing the right place to put the filter?
- modifying /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php accordingly to your file, when is this applied? how to apply it retroactively to existing mailboxes?

OnePercentile
28th June 2009, 23:21
I've used this information. It looks good, but when creating a new email account no "Junk" folder appears within SquirrelMail .. Additionally, there appears to be no domain filter rule. Am I missing something? This thread seems to have died with no resolution. Thanks
Jordan

here is it, cut and paste from my working file:
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);
}

jbryner
30th June 2009, 06:27
I'd love to add this, but after looking at mail_plugin.inc.php, I am at a little bit of a loss about where to put it and what to replace. I found reference to create mailbox, but... Any help you could give me would be great. My apologies for not being quite up to speed on php. Am learning (slowly)

int0x21
30th June 2009, 16:06
Im having a little trouble with the filter
How would a filter look to make something tagged with ***SPAM*** end up in .Spam folder

radim_h
4th October 2009, 20:31
Seems simple but it doesnt work for me folders are not created :(

Nothing in ispc debug log:
04.10.2009-19:47 - DEBUG - Set Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
04.10.2009-19:47 - DEBUG - Found 2 changes, starting update process.
04.10.2009-19:47 - DEBUG - Processed datalog_id 801
04.10.2009-19:47 - DEBUG - Processed datalog_id 802
04.10.2009-19:47 - DEBUG - Remove Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock


here is it, cut and paste from my working file:
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);
}

radim_h
6th October 2009, 15:23
and one more question, please..

in original script /usr/local/ispconfig/server/plugins-enabled/mail_plugin.inc.php

there are two same blocks starting with:

//* 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']);


At line 105

And line 156

Are you modyfying both of them ??

radim_h
8th October 2009, 22:51
no one has any idea, what's wrong? :(

radim_h
25th October 2009, 01:40
http://bugtracker.ispconfig.org/index.php?do=details&task_id=943