diff --git a/mailsystem.module b/mailsystem.module
index 006f8c3..ca66417 100644
--- a/mailsystem.module
+++ b/mailsystem.module
@@ -5,6 +5,8 @@
  * Provide UI for controlling the mail_system variable.
  */
 
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\mailsystem\Hook\MailsystemHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
@@ -29,7 +31,7 @@ function mailsystem_get_mail_theme() {
 
     case 'domain':
       // Fetch the theme for the current domain.
-      // @todo: Reimplement this as soon as module port or similar module is around.
+      // @todo Reimplement this as soon as module port or similar module is around.
       if (FALSE && \Drupal::moduleHandler()->moduleExists('domain_theme')) {
         // Assign the selected theme, based on the active domain.
         global $_domain;
@@ -45,20 +47,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..d5de8e7 100644
--- a/src/Form/AdminForm.php
+++ b/src/Form/AdminForm.php
@@ -2,13 +2,10 @@
 
 namespace Drupal\mailsystem\Form;
 
-use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\Core\Extension\ModuleExtensionList;
-use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Extension\ThemeHandlerInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Mail\MailManagerInterface;
 use Drupal\Core\Url;
 use Drupal\mailsystem\MailsystemManager;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -197,7 +194,7 @@ class AdminForm extends ConfigFormBase {
             '#title_display' => 'hidden',
             '#options' => $this->getOptions(),
             '#empty_option' => $this->t('- Default -'),
-            '#default_value' => isset($settings['formatter']) ? $settings['formatter'] : '',
+            '#default_value' => $settings['formatter'] ?? '',
           ];
           $row['sender'] = [
             '#type' => 'select',
@@ -205,7 +202,7 @@ class AdminForm extends ConfigFormBase {
             '#title_display' => 'hidden',
             '#options' => $this->getOptions(),
             '#empty_option' => $this->t('- Default -'),
-            '#default_value' => isset($settings['sender']) ? $settings['sender'] : '',
+            '#default_value' => $settings['sender'] ?? '',
           ];
           $row['remove'] = [
             '#type' => 'checkbox',
@@ -361,12 +358,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);
@@ -384,7 +381,7 @@ class AdminForm extends ConfigFormBase {
    */
   protected function getPluginLabel($plugin_id) {
     $definition = $this->mailManager->getDefinition($plugin_id);
-    return isset($definition['label']) ? $definition['label'] : $this->t('Unknown Plugin');
+    return $definition['label'] ?? $this->t('Unknown Plugin');
   }
 
   /**
diff --git a/src/Hook/MailsystemHooks.php b/src/Hook/MailsystemHooks.php
new file mode 100644
index 0000000..16753f7
--- /dev/null
+++ b/src/Hook/MailsystemHooks.php
@@ -0,0 +1,33 @@
+<?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, 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..e109043 100644
--- a/tests/modules/mailsystem_test/mailsystem_test.module
+++ b/tests/modules/mailsystem_test/mailsystem_test.module
@@ -5,20 +5,13 @@
  * Enables the use of personal and site-wide contact forms.
  */
 
-use Drupal\Core\StringTranslation\TranslatableMarkup;
-use Drupal\user\Entity\User;
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\mailsystem_test\Hook\MailsystemTestHooks;
 
 /**
  * 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..76e753c
--- /dev/null
+++ b/tests/modules/mailsystem_test/src/Hook/MailsystemTestHooks.php
@@ -0,0 +1,33 @@
+<?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 = User::load(\Drupal::currentUser()->id());
+        $username = [
+          '#theme' => 'username',
+          '#account' => $account,
+        ];
+        $message['subject'] = new TranslatableMarkup('Testing mail theme.');
+        $message['body'][] = (string) DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.3.0', fn() => \Drupal::service('renderer')->renderInIsolation($username), fn() => \Drupal::service('renderer')->renderPlain($username));
+        break;
+    }
+  }
+
+}
