Skip to content

Commit 7d9d0c6

Browse files
author
thom
committed
#1804 Option to disable welcome messages
1 parent 1e4f8d0 commit 7d9d0c6

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

install/tpl/system.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ webmail_url=/webmail
1616
dkim_path=/var/lib/amavis/dkim
1717
smtp_enabled=y
1818
smtp_host=localhost
19+
enable_welcome_mail=y
1920

2021
[monitor]
2122

server/plugins-available/mail_plugin.inc.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function user_insert($event_name, $data) {
135135
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Trash'", $data["new"]["email"]);
136136
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Junk'", $data["new"]["email"]);
137137
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Drafts'", $data["new"]["email"]);
138-
138+
139139
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? INBOX'", $data["new"]["email"]);
140140
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Sent'", $data["new"]["email"]);
141141
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Trash'", $data["new"]["email"]);
@@ -149,26 +149,26 @@ function user_insert($event_name, $data) {
149149
$app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG);
150150
$maildomain_path .= '/Maildir';
151151
}
152-
152+
153153
//* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
154154
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
155155
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']);
156156
$app->system->exec_safe("su -c ? vmail", "mv -f " . $data['new']['maildir']." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']);
157157
$app->log('Moved invalid maildir to corrupted Maildirs folder: '.$data['new']['maildir'], LOGLEVEL_WARN);
158158
}
159-
159+
160160
//* Create the maildir, if it doesn not exist, set permissions, set quota.
161161
if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
162-
162+
163163
$app->system->maildirmake($maildomain_path, $user, '', $group);
164-
164+
165165
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
166166
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
167167
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
168168
$app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".$maildomain_path."' ".$user, LOGLEVEL_DEBUG);
169169
}
170170
}
171-
171+
172172
if(!is_dir($data['new']['maildir'].'/.Sent')) {
173173
$app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
174174
}
@@ -181,11 +181,11 @@ function user_insert($event_name, $data) {
181181
if(!is_dir($data['new']['maildir'].'/.Junk')) {
182182
$app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
183183
}
184-
184+
185185
// Set permissions now recursive
186186
$app->system->exec_safe('chown -R ?:? ?', $user, $group, $data['new']['maildir']);
187187
$app->log('Set ownership on '.$data['new']['maildir'], LOGLEVEL_DEBUG);
188-
188+
189189
//* Set the maildir quota
190190
if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') {
191191
if($data['new']['quota'] > 0) {
@@ -194,6 +194,11 @@ function user_insert($event_name, $data) {
194194
}
195195
}
196196
}
197+
198+
$global_config = $app->getconf->get_global_config('mail');
199+
if($global_config['enable_welcome_mail'] == 'n') {
200+
return;
201+
}
197202

198203
//* Send the welcome email message
199204
$tmp = explode('@', $data["new"]["email"]);
@@ -261,7 +266,7 @@ function user_update($event_name, $data) {
261266

262267
// Maildir-Format must not be changed on this way !!
263268
$data['new']['maildir_format'] = $data['old']['maildir_format'];
264-
269+
265270
$maildomain_path = $data['new']['maildir'];
266271
$tmp_basepath = $data['new']['maildir'];
267272
$tmp_basepath_parts = explode('/', $tmp_basepath);
@@ -315,15 +320,15 @@ function user_update($event_name, $data) {
315320
$app->system->exec_safe('mv -f ? ?'. $data['old']['maildir'], $data['new']['maildir']);
316321
$app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG);
317322
}
318-
323+
319324
//* Create the maildir, if it doesn not exist, set permissions, set quota.
320325
if(!is_dir($data['new']['maildir'].'/mdbox')) {
321326
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? INBOX'", $data["new"]["email"]);
322327
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Sent'", $data["new"]["email"]);
323328
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Trash'", $data["new"]["email"]);
324329
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Junk'", $data["new"]["email"]);
325330
$app->system->exec_safe("su -c 'doveadm mailbox create -u ? Drafts'", $data["new"]["email"]);
326-
331+
327332
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? INBOX'", $data["new"]["email"]);
328333
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Sent'", $data["new"]["email"]);
329334
$app->system->exec_safe("su -c 'doveadm mailbox subscribe -u ? Trash'", $data["new"]["email"]);
@@ -338,18 +343,18 @@ function user_update($event_name, $data) {
338343
$app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
339344
$maildomain_path .= '/Maildir';
340345
}
341-
346+
342347
//* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
343348
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
344349
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']);
345350
$app->system->exec_safe("su -c ? ?", "mv -f ".$data['new']['maildir']." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 'vmail');
346351
$app->log('Moved invalid maildir to corrupted Maildirs folder: '.$data['new']['maildir'], LOGLEVEL_WARN);
347352
}
348-
353+
349354
//* Create the maildir, if it doesn not exist, set permissions, set quota.
350355
if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) {
351356
$app->system->maildirmake($maildomain_path, $user, '', $group);
352-
357+
353358
//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
354359
if($mail_config['pop3_imap_daemon'] != 'dovecot') {
355360
if($data['new']['quota'] > 0) {
@@ -361,7 +366,7 @@ function user_update($event_name, $data) {
361366
}
362367
}
363368
}
364-
369+
365370
if(!is_dir($data['new']['maildir'].'/.Sent')) {
366371
$app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
367372
}
@@ -374,11 +379,11 @@ function user_update($event_name, $data) {
374379
if(!is_dir($data['new']['maildir'].'/.Junk')) {
375380
$app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
376381
}
377-
382+
378383
// Set permissions now recursive
379384
$app->system->exec_safe('chown -R ?:? ?', $user, $group, $data['new']['maildir']);
380385
$app->log('Set ownership on '.$data['new']['maildir'], LOGLEVEL_DEBUG);
381-
386+
382387
// Move mailbox, if domain has changed and delete old mailbox
383388
if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) {
384389
if(is_dir($data['new']['maildir'])) {
@@ -470,7 +475,7 @@ function domain_delete($event_name, $data) {
470475
} else {
471476
$app->log('Possible security violation when deleting the mail domain mailfilter directory: '.$old_maildomain_path, LOGLEVEL_ERROR);
472477
}
473-
478+
474479
//* Delete the mail-backups
475480
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
476481
$backup_dir = $server_config['backup_dir'];

server/plugins-available/mailman_plugin.inc.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ function onLoad() {
7171
function insert($event_name, $data) {
7272
global $app, $conf;
7373

74+
$global_config = $app->getconf->get_global_config('mail');
75+
$opt_quiet = ($global_config['enable_welcome_mail'] == 'n') ? "-q" : "";
76+
7477
$this->update_config();
7578

76-
$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"]);
79+
$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"]);
7780
// wait for /usr/lib/mailman/bin/newlist-call
7881
$running = true;
7982
do {
@@ -87,9 +90,9 @@ function insert($event_name, $data) {
8790
}
8891
if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
8992
if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman');
90-
93+
9194
exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
92-
95+
9396
// Fix list URL
9497
$app->system->exec_safe('/usr/sbin/withlist -l -r fix_url ?', $data["new"]["listname"]);
9598

@@ -100,15 +103,15 @@ function insert($event_name, $data) {
100103
// The purpose of this plugin is to rewrite the main.cf file
101104
function update($event_name, $data) {
102105
global $app, $conf;
103-
106+
104107
$this->update_config();
105108

106109
if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') {
107110
$app->system->exec_safe("nohup /usr/lib/mailman/bin/change_pw -l ? -p ? >/dev/null 2>&1 &", $data["new"]["listname"], $data["new"]["password"]);
108111
exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
109112
$app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']);
110113
}
111-
114+
112115
if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
113116
if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman');
114117
}
@@ -121,7 +124,7 @@ function delete($event_name, $data) {
121124
$app->system->exec_safe("nohup /usr/lib/mailman/bin/rmlist -a ? >/dev/null 2>&1 &", $data["old"]["listname"]);
122125

123126
exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &');
124-
127+
125128
if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
126129
if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman');
127130

0 commit comments

Comments
 (0)