diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php
index 1c5d6a8..60f796e 100644
--- a/src/Form/SettingsForm.php
+++ b/src/Form/SettingsForm.php
@@ -56,9 +56,9 @@ class SettingsForm extends ConfigFormBase {
         $default_sender = $this->config('mailsystem.settings')
           ->get('defaults.sender');
         if ($default_sender != $this::MAIL_KEY) {
-          drupal_set_message($this->t('It seems you are using the mailsystem module to control your mail, but the default sender is not set to Sparkpost. If this is not on purpose you should probably <a href="@url">adjust the settings at this page.</a>', [
+          $this->messenger()->addWarning($this->t('It seems you are using the mailsystem module to control your mail, but the default sender is not set to Sparkpost. If this is not on purpose you should probably <a href="@url">adjust the settings at this page.</a>', [
             '@url' => Url::fromRoute('mailsystem.settings')->toString(),
-          ]), 'warning');
+          ]));
         }
       }
       else {
@@ -68,12 +68,12 @@ class SettingsForm extends ConfigFormBase {
         $default_system = $this->config($config_collection)
           ->get($config_key);
         if ($default_system != $this::MAIL_KEY) {
-          drupal_set_message($this->t('You seem to be using %system as your mail system instead of %sparkpost. If this is not on purpose, you should change the configration for %config_key in %config to %sparkpost.', [
+          $this->messenger()->addWarning($this->t('You seem to be using %system as your mail system instead of %sparkpost. If this is not on purpose, you should change the configration for %config_key in %config to %sparkpost.', [
             '%system' => $default_system,
             '%sparkpost' => $this::MAIL_KEY,
             '%config_key' => $config_key,
             '%config' => $config_collection,
-          ]), 'warning');
+          ]));
         }
       }
       $form['api_hostname'] = [
diff --git a/src/Form/TestMailForm.php b/src/Form/TestMailForm.php
index a9c6190..285188c 100644
--- a/src/Form/TestMailForm.php
+++ b/src/Form/TestMailForm.php
@@ -108,9 +108,9 @@ class TestMailForm extends FormBase {
     // Send.
     $message = $this->mailManager->mail('sparkpost', 'test_mail_form', $to, LanguageInterface::LANGCODE_NOT_SPECIFIED, $params);
     if ($message['result']) {
-      drupal_set_message($this->t('Sparkpost test email sent to %to.', [
+      $this->messenger()->addStatus($this->t('Sparkpost test email sent to %to.', [
         '%to' => $to,
-      ]), 'status');
+      ]));
     }
     else {
       $form_state->setRebuild();
