From c719dc0b1dd696e0cd6b51f09ee13c8263375f7c Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Wed, 07 Sep 2011 05:57:38 -0400 Subject: [PATCH] Fixed a warning in maildrop plugin. --- server/plugins-available/mail_plugin.inc.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 49 insertions(+), 6 deletions(-) diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index 2d7d507..85515f2 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -152,9 +152,42 @@ //* Set the maildir quota if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { - 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'],LOGLEVEL_DEBUG); + if($data['new']['quota'] > 0) { + 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'],LOGLEVEL_DEBUG); + } } + + //* Send the welcome email message + if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt')) { + $tmp = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt'); + } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt')) { + $tmp = file($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt'); + } elseif(file_exists($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt')) { + $tmp = file($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt'); + } else { + $tmp = file($conf['rootpath'].'/conf/mail/welcome_email_en.txt'); + } + + $welcome_mail_subject = trim(substr($tmp[0],8)); + unset($tmp[0]); + $welcome_mail_message = trim(implode($tmp)); + unset($tmp); + + $welcomeFromEmail = $mail_config['admin_mail']; + $welcomeFromName = $mail_config['admin_name']; + + $mailHeaders = "MIME-Version: 1.0" . "\n"; + $mailHeaders .= "Content-type: text/plain; charset=utf-8" . "\n"; + $mailHeaders .= "Content-Transfer-Encoding: 8bit" . "\n"; + $mailHeaders .= "From: $welcomeFromName <$welcomeFromEmail>" . "\n"; + $mailHeaders .= "Reply-To: <$welcomeFromEmail>" . "\n"; + $mailTarget = $data["new"]["email"]; + $mailSubject = "=?utf-8?Q?" . imap_8bit($welcome_mail_subject) . "?="; + + mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders); + + } function user_update($event_name,$data) { @@ -212,8 +245,13 @@ $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. if($mail_config['pop3_imap_daemon'] != 'dovecot') { - 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('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + if($data['new']['quota'] > 0) { + 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('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + } else { + if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); + $app->log('Set Maildir quota to unlimited.',LOGLEVEL_DEBUG); + } } } @@ -253,8 +291,13 @@ //This is to fix the maildrop quota not being rebuilt after the quota is changed. // Courier Layout if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { - exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']); - $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + if($data['new']['quota'] > 0) { + exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name']); + $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + } else { + if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); + $app->log('Set Maildir quota to unlimited.',LOGLEVEL_DEBUG); + } } } -- Gitblit v1.9.1