]> git.mxchange.org Git - friendica.git/blobdiff - mod/lostpass.php
Set Sitename / site email as sender for system emails
[friendica.git] / mod / lostpass.php
index 3d397677bc9a9a5f065143564ec7e034074c9083..04316a0996fcbbadb3cc4a033ebbc03f5d2e2a44 100644 (file)
@@ -5,7 +5,6 @@
  */
 
 use Friendica\App;
-use Friendica\Core\Config;
 use Friendica\Core\Renderer;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -38,7 +37,7 @@ function lostpass_post(App $a)
                info(DI::l10n()->t('Password reset request issued. Check your email.') . EOL);
        }
 
-       $sitename = Config::get('config', 'sitename');
+       $sitename = DI::config()->get('config', 'sitename');
        $resetlink = DI::baseUrl() . '/lostpass/' . $pwdreset_token;
 
        $preamble = Strings::deindent(DI::l10n()->t('
@@ -65,17 +64,14 @@ function lostpass_post(App $a)
                Site Location:  %2$s
                Login Name:     %3$s', $resetlink, DI::baseUrl(), $user['nickname']));
 
-       notification([
-               'type'     => SYSTEM_EMAIL,
-               'language' => $user['language'],
-               'to_name'  => $user['username'],
-               'to_email' => $user['email'],
-               'uid'      => $user['uid'],
-               'subject'  => DI::l10n()->t('Password reset requested at %s', $sitename),
-               'preamble' => $preamble,
-               'body'     => $body
-       ]);
+       $email = DI::emailer()
+                  ->newSystemMail(DI::app(), (!empty($user['language'])) ? DI::l10n()->withLang($user['language']) : DI::l10n())
+                  ->withMessage(DI::l10n()->t('Password reset requested at %s', $sitename), $preamble, $body)
+                  ->forUser($user['uid'] ?? 0)
+                  ->withRecipient($user['email'])
+                  ->build();
 
+       DI::emailer()->send($email);
        DI::baseUrl()->redirect();
 }
 
@@ -143,7 +139,7 @@ function lostpass_generate_password($user)
 
                info("Your password has been reset." . EOL);
 
-               $sitename = Config::get('config', 'sitename');
+               $sitename = DI::config()->get('config', 'sitename');
                $preamble = Strings::deindent(DI::l10n()->t('
                        Dear %1$s,
                                Your password has been changed as requested. Please retain this
@@ -160,16 +156,13 @@ function lostpass_generate_password($user)
                        You may change that password from your account settings page after logging in.
                ', DI::baseUrl(), $user['nickname'], $new_password));
 
-               notification([
-                       'type'     => SYSTEM_EMAIL,
-                       'language' => $user['language'],
-                       'to_name'  => $user['username'],
-                       'to_email' => $user['email'],
-                       'uid'      => $user['uid'],
-                       'subject'  => DI::l10n()->t('Your password has been changed at %s', $sitename),
-                       'preamble' => $preamble,
-                       'body'     => $body
-               ]);
+               $email = DI::emailer()
+                          ->newSystemMail(DI::app(), (!empty($user['language'])) ? DI::l10n()->withLang($user['language']) : DI::l10n())
+                          ->withMessage(DI::l10n()->t('Your password has been changed at %s', $sitename), $preamble, $body)
+                          ->forUser($user['uid'] ?? 0)
+                          ->withRecipient($user['email'])
+                          ->build();
+               DI::emailer()->send($email);
        }
 
        return $o;