19declare(strict_types=1);
38 private readonly NewAccountMailRepository $account_mail_repository
51 throw new InvalidArgumentException(
52 'Permanent link target must not be empty'
78 isset($mailData[
'body'], $mailData[
'subject']) &&
79 is_string($mailData[
'body']) &&
80 $mailData[
'body'] !==
'' &&
81 is_string($mailData[
'subject']) &&
82 $mailData[
'subject'] !==
''
88 $this->
logger->debug(sprintf(
89 'Trying to send configurable email dependent welcome email to user %s (id: %s|language: %s) ...',
95 $mailData = $this->account_mail_repository->getFor($user->
getLanguage());
97 if ($mailData->getBody() ===
'' && $mailData->getSubject() ===
'') {
98 $this->
logger->debug(sprintf(
99 'Either subject or email missing, trying to determine email configuration via default language: %s',
100 $this->
language->getDefaultLanguage()
103 $mailData = $this->account_mail_repository->getFor($this->
language->getDefaultLanguage());
105 if ($mailData->getBody() ===
'' && $mailData->getSubject() ===
'') {
106 $this->
logger->debug(
'Did not find any valid email configuration, skipping attempt ...');
112 $accountMail->setUser($user);
113 $accountMail->setPermanentLinkTarget($this->permanent_link_target);
115 if ($this->
settings->passwordGenerationEnabled()) {
116 $accountMail->setUserPassword($rawPassword);
119 $accountMail->send();
121 $this->
logger->debug(
'Welcome email sent');
129 bool $usedRegistrationCode
131 if (!$user->getEmail()) {
132 $this->
logger->debug(sprintf(
133 'Missing email address, did not send account registration mail for user %s (id: %s) ...',
140 $this->
logger->debug(sprintf(
141 'Sending language variable dependent welcome email to user %s (id: %s|language: %s) as fallback ...',
153 $this->
setBody($this->
language->txt(
'reg_mail_body_salutation') .
' ' . $user->getFullname() .
',');
164 if ($this->
settings->passwordGenerationEnabled()) {
169 if ($this->
getMode() === self::MODE_DIRECT_REGISTRATION) {
175 } elseif ($this->
getMode() === self::MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION) {
183 $this->
appendBody($user->getProfileAsString($this->language));
188 $this->
logger->debug(
'Welcome email sent');
191 public function send(
ilObjUser $user,
string $rawPassword =
'',
bool $usedRegistrationCode =
false): void
193 if (!$this->trySendingUserDefinedAccountMail($user, $rawPassword)) {
194 $this->sendLanguageVariableBasedAccountMail($user, $rawPassword, $usedRegistrationCode);
Class ilAccountRegistrationMail.
trySendingUserDefinedAccountMail(ilObjUser $user, string $rawPassword)
string $permanent_link_target
sendLanguageVariableBasedAccountMail(ilObjUser $user, string $rawPassword, bool $usedRegistrationCode)
const MODE_DIRECT_REGISTRATION
send(ilObjUser $user, string $rawPassword='', bool $usedRegistrationCode=false)
withDirectRegistrationMode()
const MODE_REGISTRATION_WITH_EMAIL_CONFIRMATION
isEmptyMailConfigurationData(array $mailData)
__construct(private readonly ilRegistrationSettings $settings, private readonly ilLogger $logger, private readonly NewAccountMailRepository $account_mail_repository)
withEmailConfirmationRegistrationMode()
withPermanentLinkTarget(string $permanent_link_target)
Component logger with individual log levels by component id.
appendBody(string $a_body)
static _getInstallationSignature()
sendMimeMail(string $a_rcp)
initLanguageByIso2Code(string $a_code='')
setSubject(string $a_subject)
Class ilObjAuthSettingsGUI.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))