Skip to content

Commit ceedb95

Browse files
Merge pull request #23202 from nextcloud/backport/23182/stable19
[stable19] Fix the user email issue while creating a user
2 parents 4cd6646 + 17705b6 commit ceedb95

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)