Merge pull request #23202 from nextcloud/backport/23182/stable19

[stable19] Fix the user email issue while creating a user
This commit is contained in:
Christoph Wurst 2020-11-10 08:51:35 +01:00 committed by GitHub
commit ceedb95a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -335,19 +335,21 @@ class UsersController extends AUserData {
} }
// Send new user mail only if a mail is set // Send new user mail only if a mail is set
if ($email !== '' && $this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') { if ($email !== '') {
$newUser->setEMailAddress($email); $newUser->setEMailAddress($email);
try { if ($this->config->getAppValue('core', 'newUser.sendEmail', 'yes') === 'yes') {
$emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken); try {
$this->newUserMailHelper->sendMail($newUser, $emailTemplate); $emailTemplate = $this->newUserMailHelper->generateTemplate($newUser, $generatePasswordResetToken);
} catch (\Exception $e) { $this->newUserMailHelper->sendMail($newUser, $emailTemplate);
// Mail could be failing hard or just be plain not configured } catch (\Exception $e) {
// Logging error as it is the hardest of the two // Mail could be failing hard or just be plain not configured
$this->logger->logException($e, [ // Logging error as it is the hardest of the two
'message' => "Unable to send the invitation mail to $email", $this->logger->logException($e, [
'level' => ILogger::ERROR, 'message' => "Unable to send the invitation mail to $email",
'app' => 'ocs_api', 'level' => ILogger::ERROR,
]); 'app' => 'ocs_api',
]);
}
} }
} }