diff --git a/src/MailsystemManager.php b/src/MailsystemManager.php
index f7486b0..0fe4383 100644
--- a/src/MailsystemManager.php
+++ b/src/MailsystemManager.php
@@ -15,10 +15,9 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Logger\LoggerChannelFactoryInterface;
 use Drupal\Core\Mail\MailInterface;
 use Drupal\Core\Mail\MailManager;
+use Drupal\Core\Render\RendererInterface;
 use Drupal\Core\StringTranslation\TranslationInterface;
-use Drupal\Core\Theme\Registry;
 use Drupal\Core\Theme\ThemeInitializationInterface;
-use Drupal\Core\Theme\ThemeManager;
 use Drupal\Core\Theme\ThemeManagerInterface;
 
 /**
@@ -46,10 +45,35 @@ class MailsystemManager extends MailManager {
   protected $themeInitialization;
 
   /**
-   * {@inheritdoc}
+   * Constructs the MailManager object.
+   *
+   * @param \Traversable $namespaces
+   *   An object that implements \Traversable which contains the root paths
+   *   keyed by the corresponding namespace to look for plugin implementations.
+   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
+   *   Cache backend instance to use.
+   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
+   *   The module handler to invoke the alter hook with.
+   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
+   *   The configuration factory.
+   * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
+   *   The logger channel factory.
+   * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
+   *   The string translation service.
+   * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
+   *   The theme manager.
+   * @param \Drupal\Core\Theme\ThemeInitializationInterface $theme_initialization
+   *   The theme initialization.
+   * @param \Drupal\Core\Render\RendererInterface $renderer
+   *   The renderer (argument included since Core 8.2 and later versions).
    */
-  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory, TranslationInterface $string_translation, ThemeManagerInterface $theme_manager, ThemeInitializationInterface $theme_initialization) {
-    parent::__construct($namespaces, $cache_backend, $module_handler, $config_factory, $logger_factory, $string_translation);
+  public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, LoggerChannelFactoryInterface $logger_factory, TranslationInterface $string_translation, ThemeManagerInterface $theme_manager, ThemeInitializationInterface $theme_initialization, RendererInterface $renderer) {
+    if (version_compare(\Drupal::VERSION, '8.2', '<')) {
+      parent::__construct($namespaces, $cache_backend, $module_handler, $config_factory, $logger_factory, $string_translation);
+    }
+    else {
+      parent::__construct($namespaces, $cache_backend, $module_handler, $config_factory, $logger_factory, $string_translation, $renderer);
+    }
     $this->themeManager = $theme_manager;
     $this->themeInitialization = $theme_initialization;
   }
diff --git a/src/MailsystemServiceProvider.php b/src/MailsystemServiceProvider.php
index 934c68c..73d7ac4 100644
--- a/src/MailsystemServiceProvider.php
+++ b/src/MailsystemServiceProvider.php
@@ -28,10 +28,17 @@ class MailsystemServiceProvider implements ServiceProviderInterface, ServiceModi
    */
   public function alter(ContainerBuilder $container) {
     // Overrides mail-factory class to use our own mail manager.
-    $container->getDefinition('plugin.manager.mail')
-      ->setClass('Drupal\mailsystem\MailsystemManager')
-      ->addArgument(new Reference('theme.manager'))
-      ->addArgument(new Reference('theme.initialization'));
+    $definition = $container->getDefinition('plugin.manager.mail');
+    // Replace the last plugin.manager.mail service identifier (renderer)
+    // provided since Core 8.2.
+    $definition->replaceArgument(6, new Reference('theme.manager'));
+    $definition->addArgument(new Reference('theme.initialization'));
+
+    if (version_compare(\Drupal::VERSION, '8.2', '>=')) {
+      $definition->addArgument(new Reference('renderer'));
+    }
+
+    $definition->setClass('Drupal\mailsystem\MailsystemManager');
   }
 
 }
diff --git a/tests/src/Unit/MailsystemManagerTest.php b/tests/src/Unit/MailsystemManagerTest.php
index f7c0a19..0f317bb 100644
--- a/tests/src/Unit/MailsystemManagerTest.php
+++ b/tests/src/Unit/MailsystemManagerTest.php
@@ -68,10 +68,9 @@ class MailsystemManagerTest extends UnitTestCase {
 
     $theme_manager = $this->prophesize(ThemeManager::class);
     $theme_initialization = $this->prophesize(ThemeInitialization::class);
-    $default_theme_registry = $this->prophesize(Registry::class);
-    $mail_theme_registry = $this->prophesize(Registry::class);
+    $renderer = $this->getMock('\Drupal\Core\Render\RendererInterface');
 
-    $this->mailManager = new MailsystemManager($namespaces, $cache_backend, $module_handler, $this->configFactory, $logger_factory, $string_translation, $theme_manager->reveal(), $theme_initialization->reveal(), $default_theme_registry->reveal(), $mail_theme_registry->reveal());
+    $this->mailManager = new MailsystemManager($namespaces, $cache_backend, $module_handler, $this->configFactory, $logger_factory, $string_translation, $theme_manager->reveal(), $theme_initialization->reveal(), $renderer);
   }
 
   public function testGetInstances_Default() {
