@@ -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 ' ];
0 commit comments