diff --git a/mailsystem.module b/mailsystem.module
index 006f8c3..c96a312 100644
--- a/mailsystem.module
+++ b/mailsystem.module
@@ -4,7 +4,8 @@
  * @file
  * Provide UI for controlling the mail_system variable.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\mailsystem\Hook\MailsystemHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
@@ -45,20 +46,7 @@ function mailsystem_get_mail_theme() {
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function mailsystem_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    case 'help.page.mailsystem':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('<a href=":mailsystem">Mail System</a> Provides an Administrative UI and Developers API for managing the used mail backend/plugin.</a>',
-          [
-            ':mailsystem' => 'http://drupal.org/project/mailsystem',
-          ]
-        ) . '</p>';
-
-      $output .= '<h3>' . t('Uses') . '</h3>';
-      $output .= '<p>' . t('Allows to use different backends for formatting and sending e-mails by default, per module and per mail key. Additionally, a theme can be configured that is used for sent mails.') . '</p>';
-
-      return $output;
-  }
+  return \Drupal::service(MailsystemHooks::class)->help($route_name, $route_match);
 }
diff --git a/mailsystem.services.yml b/mailsystem.services.yml
new file mode 100644
index 0000000..c2476cc
--- /dev/null
+++ b/mailsystem.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\mailsystem\Hook\MailsystemHooks:
+    class: Drupal\mailsystem\Hook\MailsystemHooks
+    autowire: true
diff --git a/src/Form/AdminForm.php b/src/Form/AdminForm.php
index 7ffb858..09da845 100644
--- a/src/Form/AdminForm.php
+++ b/src/Form/AdminForm.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\mailsystem\Form;
 
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Extension\ModuleExtensionList;
 use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -361,12 +362,12 @@ class AdminForm extends ConfigFormBase {
     $list = [];
     if (method_exists($this->moduleHandler, 'invokeAllWith')) {
       $this->moduleHandler->invokeAllWith('mail', function (callable $hook, string $module) use (&$list) {
-        $list[$module] = $this->moduleHandler->getName($module);
+        $list[$module] = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal::service('extension.list.module')->getName($module), fn() => $this->moduleHandler->getName($module));
       });
     }
     else {
       foreach ($this->moduleHandler->getImplementations('mail') as $module) {
-        $list[$module] = $this->moduleHandler->getName($module);
+        $list[$module] = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal::service('extension.list.module')->getName($module), fn() => $this->moduleHandler->getName($module));
       }
     }
     asort($list);
diff --git a/src/Hook/MailsystemHooks.php b/src/Hook/MailsystemHooks.php
new file mode 100644
index 0000000..7c28802
--- /dev/null
+++ b/src/Hook/MailsystemHooks.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\mailsystem\Hook;
+
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for mailsystem.
+ */
+class MailsystemHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_help().
+     */
+    #[Hook('help')]
+    public function help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match)
+    {
+        switch ($route_name) {
+            case 'help.page.mailsystem':
+                $output = '';
+                $output .= '<h3>' . $this->t('About') . '</h3>';
+                $output .= '<p>' . $this->t('<a href=":mailsystem">Mail System</a> Provides an Administrative UI and Developers API for managing the used mail backend/plugin.</a>', [
+                    ':mailsystem' => 'http://drupal.org/project/mailsystem',
+                ]) . '</p>';
+                $output .= '<h3>' . $this->t('Uses') . '</h3>';
+                $output .= '<p>' . $this->t('Allows to use different backends for formatting and sending e-mails by default, per module and per mail key. Additionally, a theme can be configured that is used for sent mails.') . '</p>';
+                return $output;
+        }
+    }
+}
diff --git a/tests/modules/mailsystem_test/mailsystem_test.module b/tests/modules/mailsystem_test/mailsystem_test.module
index 6ce14a1..8ce98e0 100644
--- a/tests/modules/mailsystem_test/mailsystem_test.module
+++ b/tests/modules/mailsystem_test/mailsystem_test.module
@@ -4,21 +4,16 @@
  * @file
  * Enables the use of personal and site-wide contact forms.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\mailsystem_test\Hook\MailsystemTestHooks;
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Drupal\user\Entity\User;
 
 /**
  * Implements hook_mail().
  */
+#[LegacyHook]
 function mailsystem_test_mail($key, &$message, $params) {
-  switch ($key) {
-    case 'theme_test':
-      $account = User::load(\Drupal::currentUser()->id());
-      $username = ['#theme' => 'username', '#account' => $account];
-
-      $message['subject'] = new TranslatableMarkup('Testing mail theme.');
-      $message['body'][] = (string) \Drupal::service('renderer')->renderPlain($username);
-      break;
-  }
+  \Drupal::service(MailsystemTestHooks::class)->mail($key, $message, $params);
 }
diff --git a/tests/modules/mailsystem_test/mailsystem_test.services.yml b/tests/modules/mailsystem_test/mailsystem_test.services.yml
new file mode 100644
index 0000000..1a9760c
--- /dev/null
+++ b/tests/modules/mailsystem_test/mailsystem_test.services.yml
@@ -0,0 +1,5 @@
+
+services:
+  Drupal\mailsystem_test\Hook\MailsystemTestHooks:
+    class: Drupal\mailsystem_test\Hook\MailsystemTestHooks
+    autowire: true
diff --git a/tests/modules/mailsystem_test/src/Hook/MailsystemTestHooks.php b/tests/modules/mailsystem_test/src/Hook/MailsystemTestHooks.php
new file mode 100644
index 0000000..488bda2
--- /dev/null
+++ b/tests/modules/mailsystem_test/src/Hook/MailsystemTestHooks.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\mailsystem_test\Hook;
+
+use Drupal\Component\Utility\DeprecationHelper;
+use Drupal\Core\StringTranslation\TranslatableMarkup;
+use Drupal\user\Entity\User;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for mailsystem_test.
+ */
+class MailsystemTestHooks
+{
+    /**
+     * Implements hook_mail().
+     */
+    #[Hook('mail')]
+    public static function mail($key, &$message, $params)
+    {
+        switch ($key) {
+            case 'theme_test':
+                $account = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
+                $username = [
+                    '#theme' => 'username',
+                    '#account' => $account,
+                ];
+                $message['subject'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Testing mail theme.');
+                $message['body'][] = (string) \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal::service('renderer')->renderInIsolation($username), fn() => \Drupal::service('renderer')->renderPlain($username));
+                break;
+        }
+    }
+}
