From e94a9fb5e4b6a2bc07e0bb4cf8ea35fc70c4bbf0 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Thu, 10 May 2012 12:31:27 -0400 Subject: [PATCH] Merged revisions 3049-3051,3053-3054,3058,3070,3074-3077,3082,3086-3088,3091-3092,3094-3095 from stable branch. --- server/plugins-available/mail_plugin.inc.php | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 45 insertions(+), 6 deletions(-) diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index a69c4c0..4c6912f 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -91,18 +91,18 @@ $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']); + //exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']); + $app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); } // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. if($mail_config['pop3_imap_daemon'] == 'dovecot') { - exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + $app->system->mkdirpath($maildomain_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->log('Created Directory: '.$maildomain_path,LOGLEVEL_DEBUG); $maildomain_path .= '/Maildir'; } @@ -157,6 +157,44 @@ $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')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt'); + } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_en.txt'); + } elseif(file_exists($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt')) { + $lines = file($conf['rootpath'].'/conf/mail/welcome_email_'.$conf['language'].'.txt'); + } else { + $lines = file($conf['rootpath'].'/conf/mail/welcome_email_en.txt'); + } + + //* Get from address + $parts = explode(':',trim($lines[0])); + unset($parts[0]); + $welcome_mail_from = implode(':',$parts); + unset($lines[0]); + + //* Get subject + $parts = explode(':',trim($lines[1])); + unset($parts[0]); + $welcome_mail_subject = implode(':',$parts); + unset($lines[1]); + + //* Get message + $welcome_mail_message = trim(implode($lines)); + unset($tmp); + + $mailHeaders = "MIME-Version: 1.0" . "\n"; + $mailHeaders .= "Content-type: text/plain; charset=utf-8" . "\n"; + $mailHeaders .= "Content-Transfer-Encoding: 8bit" . "\n"; + $mailHeaders .= "From: $welcome_mail_from" . "\n"; + $mailHeaders .= "Reply-To: $welcome_mail_from" . "\n"; + $mailTarget = $data["new"]["email"]; + $mailSubject = "=?utf-8?B?".base64_encode($welcome_mail_subject)."?="; + + mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders); + } function user_update($event_name,$data) { @@ -187,13 +225,14 @@ //* 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']); + //exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']); + $app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); } // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. if($mail_config['pop3_imap_daemon'] == 'dovecot') { - exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + $app->system->mkdirpath($maildomain_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); $maildomain_path .= '/Maildir'; } -- Gitblit v1.9.1