@@ -335,19 +335,21 @@ public function addUser(string $userid,
335335 }
336336
337337 // Send new user mail only if a mail is set
338- if ($ email !== '' && $ this -> config -> getAppValue ( ' core ' , ' newUser.sendEmail ' , ' yes ' ) === ' yes ' ) {
338+ if ($ email !== '' ) {
339339 $ newUser ->setEMailAddress ($ email );
340- try {
341- $ emailTemplate = $ this ->newUserMailHelper ->generateTemplate ($ newUser , $ generatePasswordResetToken );
342- $ this ->newUserMailHelper ->sendMail ($ newUser , $ emailTemplate );
343- } catch (\Exception $ e ) {
344- // Mail could be failing hard or just be plain not configured
345- // Logging error as it is the hardest of the two
346- $ this ->logger ->logException ($ e , [
347- 'message ' => "Unable to send the invitation mail to $ email " ,
348- 'level ' => ILogger::ERROR ,
349- 'app ' => 'ocs_api ' ,
350- ]);
340+ if ($ this ->config ->getAppValue ('core ' , 'newUser.sendEmail ' , 'yes ' ) === 'yes ' ) {
341+ try {
342+ $ emailTemplate = $ this ->newUserMailHelper ->generateTemplate ($ newUser , $ generatePasswordResetToken );
343+ $ this ->newUserMailHelper ->sendMail ($ newUser , $ emailTemplate );
344+ } catch (\Exception $ e ) {
345+ // Mail could be failing hard or just be plain not configured
346+ // Logging error as it is the hardest of the two
347+ $ this ->logger ->logException ($ e , [
348+ 'message ' => "Unable to send the invitation mail to $ email " ,
349+ 'level ' => ILogger::ERROR ,
350+ 'app ' => 'ocs_api ' ,
351+ ]);
352+ }
351353 }
352354 }
353355
0 commit comments