diff --git a/install/tpl/system.ini.master b/install/tpl/system.ini.master index c42966a01c12bd90906d4795f79de1184eb3bf11..928068a6e11c5081b459929796534b0ad623bf60 100644 --- a/install/tpl/system.ini.master +++ b/install/tpl/system.ini.master @@ -16,7 +16,6 @@ webmail_url=/webmail dkim_path=/var/lib/amavis/dkim smtp_enabled=y smtp_host=localhost -enable_welcome_mail=y [monitor] diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index c584b6821592531b7f6ee3ffa11994bb74097fbb..4d5ac826d3780f4d264f07c0060a9f0ffe13bd56 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -135,7 +135,7 @@ class mail_plugin { $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Trash'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Junk'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Drafts'", $data["new"]["email"]); - + $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? INBOX'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Sent'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Trash'", $data["new"]["email"]); @@ -149,26 +149,26 @@ class mail_plugin { $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG); $maildomain_path .= '/Maildir'; } - + //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->system->exec_safe("su -c ? vmail", "mv -f " . $data['new']['maildir']." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']); $app->log('Moved invalid maildir to corrupted Maildirs folder: '.$data['new']['maildir'], LOGLEVEL_WARN); } - + //* Create the maildir, if it doesn not exist, set permissions, set quota. if(!empty($maildomain_path) && !is_dir($maildomain_path)) { - + $app->system->maildirmake($maildomain_path, $user, '', $group); - + //* This is to fix the maildrop quota not being rebuilt after the quota is changed. if($mail_config['pop3_imap_daemon'] != 'dovecot') { if(is_dir($maildomain_path)) $app->system->exec_safe("su -c ? ?", "maildirmake -q ".$data['new']['quota']."S ".$maildomain_path, $user); // Avoid maildirmake quota bug, see debian bug #214911 $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".$maildomain_path."' ".$user, LOGLEVEL_DEBUG); } } - + if(!is_dir($data['new']['maildir'].'/.Sent')) { $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); } @@ -181,11 +181,11 @@ class mail_plugin { if(!is_dir($data['new']['maildir'].'/.Junk')) { $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); } - + // Set permissions now recursive $app->system->exec_safe('chown -R ?:? ?', $user, $group, $data['new']['maildir']); $app->log('Set ownership on '.$data['new']['maildir'], LOGLEVEL_DEBUG); - + //* Set the maildir quota if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { if($data['new']['quota'] > 0) { @@ -195,63 +195,61 @@ class mail_plugin { } } - $global_config = $app->getconf->get_global_config('mail'); - if($global_config['enable_welcome_mail'] == 'y') { - //* Send the welcome email message - $tmp = explode('@', $data["new"]["email"]); - $domain = $tmp[1]; - unset($tmp); - $html = false; - if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.html')) { - $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.html'); - $html = true; - } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.html')) { - $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.html'); - $html = true; - } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.txt')) { - $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.txt'); - } elseif(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"; - if($html) { - $mailHeaders .= "Content-Type: text/html; charset=utf-8" . "\n"; - $mailHeaders .= "Content-Transfer-Encoding: quoted-printable" . "\n"; - } else { - $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)."?="; + //* Send the welcome email message + $tmp = explode('@', $data["new"]["email"]); + $domain = $tmp[1]; + unset($tmp); + $html = false; + if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.html')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.html'); + $html = true; + } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.html')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.html'); + $html = true; + } elseif(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.txt')) { + $lines = file($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$domain.'.txt'); + } elseif(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'); + } - //* Send the welcome email only on the "master" mail server to avoid duplicate emails - if($conf['mirror_server_id'] == 0) mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders); + //* 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"; + if($html) { + $mailHeaders .= "Content-Type: text/html; charset=utf-8" . "\n"; + $mailHeaders .= "Content-Transfer-Encoding: quoted-printable" . "\n"; + } else { + $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)."?="; + + //* Send the welcome email only on the "master" mail server to avoid duplicate emails + if($conf['mirror_server_id'] == 0) mail($mailTarget, $mailSubject, $welcome_mail_message, $mailHeaders); + } function user_update($event_name, $data) { @@ -263,7 +261,7 @@ class mail_plugin { // Maildir-Format must not be changed on this way !! $data['new']['maildir_format'] = $data['old']['maildir_format']; - + $maildomain_path = $data['new']['maildir']; $tmp_basepath = $data['new']['maildir']; $tmp_basepath_parts = explode('/', $tmp_basepath); @@ -317,7 +315,7 @@ class mail_plugin { $app->system->exec_safe('mv -f ? ?'. $data['old']['maildir'], $data['new']['maildir']); $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG); } - + //* Create the maildir, if it doesn not exist, set permissions, set quota. if(!is_dir($data['new']['maildir'].'/mdbox')) { $app->system->exec_safe("su -c 'doveadm mailbox create -u ? INBOX'", $data["new"]["email"]); @@ -325,7 +323,7 @@ class mail_plugin { $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Trash'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Junk'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox create -u ? Drafts'", $data["new"]["email"]); - + $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? INBOX'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Sent'", $data["new"]["email"]); $app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Trash'", $data["new"]["email"]); @@ -340,18 +338,18 @@ class mail_plugin { $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG); $maildomain_path .= '/Maildir'; } - + //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); $app->system->exec_safe("su -c ? ?", "mv -f ".$data['new']['maildir']." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 'vmail'); $app->log('Moved invalid maildir to corrupted Maildirs folder: '.$data['new']['maildir'], LOGLEVEL_WARN); } - + //* Create the maildir, if it doesn not exist, set permissions, set quota. if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) { $app->system->maildirmake($maildomain_path, $user, '', $group); - + //* This is to fix the maildrop quota not being rebuilt after the quota is changed. if($mail_config['pop3_imap_daemon'] != 'dovecot') { if($data['new']['quota'] > 0) { @@ -363,7 +361,7 @@ class mail_plugin { } } } - + if(!is_dir($data['new']['maildir'].'/.Sent')) { $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); } @@ -376,11 +374,11 @@ class mail_plugin { if(!is_dir($data['new']['maildir'].'/.Junk')) { $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); } - + // Set permissions now recursive $app->system->exec_safe('chown -R ?:? ?', $user, $group, $data['new']['maildir']); $app->log('Set ownership on '.$data['new']['maildir'], LOGLEVEL_DEBUG); - + // Move mailbox, if domain has changed and delete old mailbox if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) { if(is_dir($data['new']['maildir'])) { @@ -472,7 +470,7 @@ class mail_plugin { } else { $app->log('Possible security violation when deleting the mail domain mailfilter directory: '.$old_maildomain_path, LOGLEVEL_ERROR); } - + //* Delete the mail-backups $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; diff --git a/server/plugins-available/mailman_plugin.inc.php b/server/plugins-available/mailman_plugin.inc.php index da033b80ccfc846e9f82a7f54e97ea99393408d7..e6251aedf10637a4891900f3ec2c9e13455660b9 100644 --- a/server/plugins-available/mailman_plugin.inc.php +++ b/server/plugins-available/mailman_plugin.inc.php @@ -71,12 +71,9 @@ class mailman_plugin { function insert($event_name, $data) { global $app, $conf; - $global_config = $app->getconf->get_global_config('mail'); - $opt_quiet = ($global_config['enable_welcome_mail'] == 'n') ? "-q" : ""; - $this->update_config(); - $pid = $app->system->exec_safe("nohup /usr/lib/mailman/bin/newlist ? -u ? -e ? ? ? ? >/dev/null 2>&1 & echo $!;", $opt_quiet, $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); + $pid = $app->system->exec_safe("nohup /usr/lib/mailman/bin/newlist -u ? -e ? ? ? ? >/dev/null 2>&1 & echo $!;", $data["new"]["domain"], $data["new"]["domain"], $data["new"]["listname"], $data["new"]["email"], $data["new"]["password"]); // wait for /usr/lib/mailman/bin/newlist-call $running = true; do { @@ -90,9 +87,9 @@ class mailman_plugin { } if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); - + exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); - + // Fix list URL $app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]); @@ -103,7 +100,7 @@ class mailman_plugin { // The purpose of this plugin is to rewrite the main.cf file function update($event_name, $data) { global $app, $conf; - + $this->update_config(); if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { @@ -111,7 +108,7 @@ class mailman_plugin { exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } - + if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); } @@ -124,7 +121,7 @@ class mailman_plugin { $app->system->exec_safe("nohup /usr/lib/mailman/bin/rmlist -a ? >/dev/null 2>&1 &", $data["old"]["listname"]); exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); - + if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman');